Add Custom MCP URL support to MCP settings - #4
Draft
kdurmaz-byte wants to merge 1 commit into
Draft
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.swiftalready modelsRemote { url, headers }withstreamable/streamable-http/ssetransports). The gap was purely in the UI: the settings screen offered a stdio-only example and a button that opensmcp.jsonin an external editor.Changes
MCPConfigFileWriter.swift(new)serversmap, rejects duplicate names, writes back atomically so the existing 3-second poll inMCPConfigViewnever reads a half-written file.http://.serverskey is treated as empty rather than rejected, so the first server can still be added.MCPCustomURLInstallView.swift(new)SecureFieldand are never logged; they typically carry a bearer token.http://URLs pointing anywhere other than localhost get an explicit warning.MCPManualInstallView's existingDisclosureSettingsRow/TextFieldsContainerstyling.ToolsConfigView.swiftMCPConfigFileWriter.ensureConfigFileExists()so it is defined once instead of twice.MCPManualInstallView.swiftNotes
JSONSerializationreformatsmcp.json(pretty-printed, sorted keys). All entries are preserved — only formatting and key order change.Testing
Not compiled — this was written in a Linux container with no Swift/Xcode toolchain. Needs verification on macOS:
Copilot for Xcodescheme.cat ~/.config/github-copilot/xcode/mcp.jsonto confirm the entry.mcp.json.Generated by Claude Code