fix(server): skip startup MCP re-registration already covered by the config file (fixes #3325) - #3389
Open
CountClaw wants to merge 1 commit into
Open
Conversation
…config file (fixes different-ai#3325) The engine loads the server-managed OPENCODE_CONFIG file at spawn and on every rebuild, so runtime MCPs already in that file are started by the engine itself. The startup sync in cli.ts and embedded.ts then re-POSTed every entry via POST /mcp, spawning a second, idle child process tree per configured local MCP server. syncAllWorkspacesRuntimeMcpToEngine now accepts the managed workspace id (the one whose runtime config file the engine read); for that workspace it reads the MCP names already present in the file and skips their POST, registering only entries absent from the file. Other workspaces are unchanged. If the file is missing or unreadable the full POST sync runs as before.
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Contributor
|
@Kyou12138 is attempting to deploy a commit to the Different AI Team on Vercel. A member of the Team first needs to authorize it. |
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
Fixes #3325 — every custom-configured local MCP server spawns two child process trees under the opencode sidecar on startup; only one is used.
Root cause
On desktop startup,
cli.ts/embedded.tswrite the server-managed runtime config file (runtime-opencode-config.json) and pass it to the engine asOPENCODE_CONFIG. The engine loads MCP definitions from that file itself at spawn (and on every instance rebuild). Immediately after,syncAllWorkspacesRuntimeMcpToEngine()re-POSTed every runtime-DB MCP entry viaPOST /mcp, so each local MCP server was registered twice and the engine started a second, idle process tree per server. Bundled MCPs (e.g.imagegen-mcp-server) were unaffected because they only ever reach the engine viaPOST /mcp.Changes
syncAllWorkspacesRuntimeMcpToEngine()now accepts an optionalconfigCoveredWorkspaceId— the managed-engine workspace whose runtime config file the engine already read.POST /mcpregistration, registering only entries absent from the file (e.g. cloud MCPs, runtime-only entries).mcp.engine-sync.e2e.test.ts: config-covered MCPs are not re-POSTed, and runtime-only MCPs are still registered.Testing
tsc --noEmitpasses.