Skip to content

fix(server): skip startup MCP re-registration already covered by the config file (fixes #3325) - #3389

Open
CountClaw wants to merge 1 commit into
different-ai:devfrom
CountClaw:fix/duplicate-local-mcp-registration
Open

fix(server): skip startup MCP re-registration already covered by the config file (fixes #3325)#3389
CountClaw wants to merge 1 commit into
different-ai:devfrom
CountClaw:fix/duplicate-local-mcp-registration

Conversation

@CountClaw

Copy link
Copy Markdown

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.ts write the server-managed runtime config file (runtime-opencode-config.json) and pass it to the engine as OPENCODE_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 via POST /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 via POST /mcp.

Changes

  • syncAllWorkspacesRuntimeMcpToEngine() now accepts an optional configCoveredWorkspaceId — the managed-engine workspace whose runtime config file the engine already read.
  • For that workspace, it reads the MCP names currently present in the config file and skips their POST /mcp registration, registering only entries absent from the file (e.g. cloud MCPs, runtime-only entries).
  • Other workspaces behave exactly as before (the config file only covers the managed engine's workspace).
  • If the config file is missing or unreadable, the full POST sync runs as before — no behaviour regression.
  • Added two e2e tests in mcp.engine-sync.e2e.test.ts: config-covered MCPs are not re-POSTed, and runtime-only MCPs are still registered.

Testing

  • New e2e cases verified with a focused harness (the full e2e suite has pre-existing Windows-only failures — verified identical on a clean baseline).
  • tsc --noEmit passes.

…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.
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openwork-landing Ready Ready Preview, v0 Jul 31, 2026 4:04pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
openwork-diagnostics Skipped Skipped Jul 31, 2026 4:04pm

@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown
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.

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.

[Bug]: Local MCP servers are started twice on launch

2 participants