Skip to content

Add Custom MCP URL support to MCP settings - #4

Draft
kdurmaz-byte wants to merge 1 commit into
mainfrom
claude/terminal-taracida-mac-ai-ujz1vc
Draft

Add Custom MCP URL support to MCP settings#4
kdurmaz-byte wants to merge 1 commit into
mainfrom
claude/terminal-taracida-mac-ai-ujz1vc

Conversation

@kdurmaz-byte

Copy link
Copy Markdown
Owner

Summary

Adds an Add Server URL section to Settings → Tools → MCP, so a remote MCP server can be added by pasting a URL instead of hand-editing mcp.json.

Remote MCP servers are already supported downstream (CHANGELOG.md — "Support for remote MCP servers.", "OAuth support for remote GitHub MCP server."; MCPRegistry.swift already models Remote { url, headers } with streamable/streamable-http/sse transports). The gap was purely in the UI: the settings screen offered a stdio-only example and a button that opens mcp.json in an external editor.

Changes

MCPConfigFileWriter.swift (new)

  • Reads the servers map, rejects duplicate names, writes back atomically so the existing 3-second poll in MCPConfigView never reads a half-written file.
  • That poll already pushes changes to the language server, so no new XPC path or service call was needed to make the server start.
  • Validation helpers for server name, URL scheme/host, and off-machine plaintext http://.
  • A file with no servers key is treated as empty rather than rejected, so the first server can still be added.

MCPCustomURLInstallView.swift (new)

  • Fields: server name, URL, HTTP/SSE transport picker, optional repeatable headers.
  • Inline validation for malformed names, malformed URLs, duplicate names, and blank header names — the submit button and the messages are driven by the same predicate, so a disabled button always has a visible reason.
  • Header values use SecureField and are never logged; they typically carry a bearer token.
  • Plaintext http:// URLs pointing anywhere other than localhost get an explicit warning.
  • Follows MCPManualInstallView's existing DisclosureSettingsRow / TextFieldsContainer styling.

ToolsConfigView.swift

  • Mounts the new section between manual install and the tools list.
  • Config-skeleton creation moved into MCPConfigFileWriter.ensureConfigFileExists() so it is defined once instead of twice.

MCPManualInstallView.swift

  • Example config now shows a remote server entry alongside the stdio one; subtitle mentions local and remote servers.

Notes

  • Writing through JSONSerialization reformats mcp.json (pretty-printed, sorted keys). All entries are preserved — only formatting and key order change.
  • Scope is adding a server. Editing/removing from the UI, and the registry browse-and-install flow, are deliberately left out.

Testing

Not compiled — this was written in a Linux container with no Swift/Xcode toolchain. Needs verification on macOS:

  1. Build and run the Copilot for Xcode scheme.
  2. Settings → Tools → MCP (requires an account with the MCP feature flag enabled).
  3. Add a server via the new section, then cat ~/.config/github-copilot/xcode/mcp.json to confirm the entry.
  4. Confirm the "MCP configuration file updated" toast appears within ~3s and the server shows up in the tools list.
  5. Error paths: duplicate name, malformed URL, blank header name, and a manually corrupted mcp.json.

Generated by Claude Code

Remote MCP servers are already supported by the language server, but the
settings UI only offered a stdio example and a button that opens mcp.json
in an external editor. Adding a remote server meant hand-editing JSON.

Add an "Add Server URL" section that writes the entry to mcp.json directly:

- MCPConfigFileWriter: reads the servers map, refuses duplicate names, and
  writes back atomically so the existing 3s poll in MCPConfigView never sees
  a half-written file. That poll already pushes changes to the language
  server, so no new plumbing is needed to start the server.
- MCPCustomURLInstallView: name, URL, HTTP/SSE transport and optional
  headers, with inline validation for malformed names/URLs, duplicate names
  and blank header names. Header values use SecureField and are never
  logged, since they usually carry a bearer token. Plaintext http:// URLs
  pointing off-machine get an explicit warning.
- Move the config skeleton creation out of MCPConfigView into the writer so
  it is defined once.
- Extend the manual install example with a remote server entry.

Note: writing through JSONSerialization reformats mcp.json (pretty-printed,
sorted keys). All entries are preserved; only formatting and key order change.

Not compiled — this container has no Swift toolchain. Needs a build and a
pass through Settings > Tools > MCP on macOS.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MU6EhCTgQupuVbszHmmT7d
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