Skip to content

feat(extensions): add MCP servers by form or pasted config, with sealed tokens and per-tool switches - #468

Merged
adeelahmad merged 3 commits into
mainfrom
claude/project-thread-r960xc-c6-mcp
Oct 17, 2026
Merged

adeelahmad merged 3 commits into
mainfrom
claude/project-thread-r960xc-c6-mcp

Conversation

@adeelahmad

Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: an admin added an MCP server only by writing YAML on /extensions. Its token sat in plain text in the manifest, where anyone who could see the extension could read it, and every tool the server listed was on, asking first unless the server marked it read-only.

After: Extensions → Add MCP server (admins) has a short form. It takes a name and either an address with headers, or a command with arguments and environment. Paste a config reads Claude's .mcp.json / mcpServers, VS Code's mcp.json (servers) or a single server, one or many at a time. It guesses names from the package or address, points out ${VAR} values to fill in, and leaves out SSE servers with a note. Test lists the server's tools before anything is saved, and Enter adds it. Tokens and keys in headers and env are sealed when saved and never shown again: the page, the API and the manifest show ••••. Saving •••• keeps the saved value, unless the server now goes to another host or another command or package. Each server's page lists its tools with a switch and Asks first, and conversations use the change at once.

How: a new domain/mcp_servers.py does three jobs. It reads pasted configs (marketplace's .mcp.json reader now uses the same code). It seals credential-named values with the server key (settings.seal, as notification targets and sources are, since an MCP server belongs to the whole install), bound to extension:<id>.mcp:<server>.<header|env>:<name>@<origin, or a hash of command+args>. It opens them only in run_tool just before the server is reached. extensions.create/save_version open, then check, then seal. _shown and to_manifest mask. The spec gains off and ask, which mcp_tools honours, and they survive tools being listed again. New endpoints: POST /extensions/mcp/read, POST /extensions/mcp/test, PATCH /extensions/{id}/tools. The upgrade step mcp-sealed-secrets seals values already saved in plain text, in every version, and is safe to run twice.

Motivation and Context

Chat gaps plan, module C6 ("Tool and MCP server settings, and a browser"), first of three PRs. Next: the services action for the mcp, browser and sandbox profiles plus a Playwright MCP preset, then a "Tools and MCP servers" settings body and the mcp_servers / add_mcp_server MCP tools.

Screenshots (if appropriate):

Steps to reproduce (if appropriate):

  1. As an admin, open Extensions → Add MCP server → Paste a config, and paste {"mcpServers": {"tracker": {"type": "http", "url": "https://…/mcp", "headers": {"Authorization": "Bearer ${TOKEN}"}}}}.
  2. Fill in the token, click Test, then press Enter.
  3. On the server's page the manifest shows Authorization: ••••, and each tool has a switch and "Asks first".

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests.
  • My change requires documentation updates, and I have updated docs/ accordingly.
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

Done questions (AGENTS.md)

  • Goal: delivers what the user wanted, merged on green CI. (First of three C6 PRs; merges on green.)
  • Agents: usable through the API, MCP or an assistant tool. The three endpoints are in the API, and the assistant already saves MCP extensions in chat (save_extension, asks first); •••• in its manifests keeps the saved value. The MCP tools mcp_servers / add_mcp_server come in the third PR.
  • Zero setup: no new prerequisite, .env edit or manual step.
  • Fewest clicks and keystrokes: name field focused, names guessed, Enter saves, one server pasted goes straight into the form, "Add all" for many, and each tool switch saves at once.
  • Configurable: n/a, no new settings. The per-tool choices live in each server's spec, editable on its page.
  • Light: default install still runs on a Raspberry Pi with cloud models. No new dependency.
  • Private and secure: credentials are sealed and never shown, and bound to the extension and destination. The threat model is updated (a new §1.7 row, P-SECRETS widened with what stays unsealed).
  • Cost: no model calls; MCP calls go through the ledger as before (mcp.list, mcp.call).
  • User decides: defaults unchanged (read-only runs at once, others ask). Every MCP tool still asks first after outside text.
  • Upgrades: the mcp-sealed-secrets step, safe twice (test_every_step_is_safe_to_repeat covers an old-shape MCP server); documented in docs/database.md › Upgrades.
  • Honest: docs describe only what's merged here.
  • Tests, docs and generated files updated (make openapi).
  • Open standards; dependencies keep Lens MIT. No new dependencies; reads the MCP config formats as other apps write them.
  • Result reported with evidence; "refine later" items written down. Refine later: secrets in a server's address or arguments aren't sealed (documented); OAuth for remote servers; SSE transport.

Local checks: ruff check, ruff format --check and mypy are clean. pytest passed on tests/api/test_mcp_servers.py, test_extensions.py, test_marketplaces.py, test_prompt_injection.py, test_approvals.py, test_mcp.py, test_automation_tools.py and tests/domain/test_migrations.py. On the frontend, tsc --noEmit and eslint are clean and jest passed on the mcp-server, extensions and marketplace UI tests. OpenAPI regeneration made no further changes, mkdocs build --strict passed, and ci/validate_threat_model.py passed.


Generated by Claude Code

…ed tokens and per-tool switches

Admins add an MCP server on Extensions with a short form (an address and
headers, or a command with args and env) or by pasting a config from
Claude or VS Code; Test lists its tools before saving. Header and env
values that carry credentials are sealed with the server key, bound to
the extension and where they go, and shown as "••••"; an upgrade step
seals the ones saved before. Each tool gets a switch and "asks first",
kept in the server's spec as off and ask.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B
The last check asked for 2026-10-17's note after the call without a date had made today's note, so on that day it
found the note the deleted root had left behind. It now asks for a day no earlier call makes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B

Copy link
Copy Markdown
Owner Author

FastAPI (embedded SurrealDB) 1/2 failed on tests/api/test_notebook.py::test_daily_notes. The failure isn't from this PR: the test depends on the date and fails on main all day on 2026-10-17. I reproduced it locally on main. The fix is in #470, and I ported it here in 654c7a2. It does nothing once main has it.


Generated by Claude Code

# Conflicts:
#	CHANGELOG.md
#	docs/database.md
#	fastapi_backend/app/domain/migrations.py
#	fastapi_backend/tests/domain/test_migrations.py
#	nextjs-frontend/app/openapi-client/index.ts
#	nextjs-frontend/app/openapi-client/sdk.gen.ts
@adeelahmad
adeelahmad merged commit d26e858 into main Oct 17, 2026
11 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-r960xc-c6-mcp branch October 17, 2026 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants