You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: No way to start SDK server without loading user MCP servers #20072
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
When using @opencode-ai/sdk to embed OpenCode programmatically (e.g. a CLI tool that makes a one-shot model call), the server always loads all MCP servers from the user's ~/.config/opencode/opencode.jsonc at startup. There is currently no way to prevent this.
Why this matters
The GitHub Copilot API hard-caps tool count at 128 tools. A power user with many MCP servers can easily exceed this, causing a HTTP 400 error from the API:
Error: 400 Bad Request — tools count exceeds maximum allowed (128)
What was tried
1. Passing enabled: false via OPENCODE_CONFIG_CONTENT
constclient=awaitcreateOpencode({config: JSON.stringify({mcp: {github: {enabled: false},playwright: {enabled: false},// ... all user MCPs}})})
Result: All MCPs still connect at startup. The enabled: false config is silently ignored.
2. Disconnecting after startup (current workaround)
constclient=awaitcreateOpencode({ ... })conststatusResult=awaitclient.mcp.status()constmcpNames=Object.keys(statusResult.data??{})awaitPromise.all(mcpNames.map(name=>client.mcp.disconnect({ name })))constsession=awaitclient.session.create({ ... })
This works (MCPs end up "status": "disabled"), but is wasteful — every MCP connects then immediately disconnects on every invocation.
Requested change
Please add one of:
A startup option — e.g. createOpencode({ mcp: false }) to skip loading user MCPs entirely
Fix enabled: false in config — honour it at startup when passed via OPENCODE_CONFIG_CONTENT
A noMcp flag on the server or session level
Note on potential duplicates:#17605 and #4525 address project-level MCP overrides. This request is specifically about SDK/embedded use — programmatic consumers that should not inherit the user's global MCP config at all.
The issue does not use one of the required templates (Bug Report, Feature Request, or Question). Feature requests must use the Feature Request template, which requires a verification checkbox and a proper description field. The title should also start with [FEATURE]: instead of [SDK].
Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
changed the title [-][SDK] MCP servers cannot be disabled at startup — no way to start server without loading user MCPs[/-][+][FEATURE]: No way to start SDK server without loading user MCP servers[/+]on Mar 30, 2026
Before calling createOpencode(), temporarily redirect XDG_CONFIG_HOME to a temp directory containing a minimal opencode/config.json with an empty MCP section. Since the SDK spawns opencode serve with { ...process.env } at call time, the child process picks up the isolated config and starts with zero MCP servers.
import{mkdirSync,writeFileSync}from'node:fs';import{join}from'node:path';import{tmpdir}from'node:os';// Create isolated config: <tmp>/aicc-<pid>/opencode/config.jsonconstisolatedDir=join(tmpdir(),`aicc-${process.pid}`,'opencode');mkdirSync(isolatedDir,{recursive: true});writeFileSync(join(isolatedDir,'config.json'),'{"mcp":{}}');constoriginalXDG=process.env.XDG_CONFIG_HOME;process.env.XDG_CONFIG_HOME=join(tmpdir(),`aicc-${process.pid}`);try{opencode=awaitcreateOpencode({ signal, port });}finally{if(originalXDG===undefined)deleteprocess.env.XDG_CONFIG_HOME;elseprocess.env.XDG_CONFIG_HOME=originalXDG;}
This works on macOS and Linux where opencode respects XDG_CONFIG_HOME. It's a bit of a hack but eliminates the overhead of connecting/disconnecting all user MCP servers on every CLI invocation.
I ran into the same fundamental problem from the end-user / TUI side and did a deep-dive into the root causes. One significant finding: chrome-devtools and morphllm-fast-apply are spawned by the opencode binary itself rather than from user configuration, so even isolating XDG_CONFIG_HOME into an empty opencode.json ({"mcp":{}}) does not prevent these built-in MCPs from loading when running the full TUI or desktop app.
This means the XDG_CONFIG_HOME workaround you documented works for SDK callers, but end users still have no supported way to start a lean OpenCode session with zero MCP overhead.
I've submitted a feature request (#22188) asking for an official kill switch (e.g. disabled_mcp_servers array or respecting enabled: false for built-ins). It references your workaround as the current best option for the SDK path, but highlights that a broader fix is needed for the binary-bundled defaults.
Activity
github-actions commentedon Mar 30, 2026
This issue doesn't fully meet our contributing guidelines.
What needs to be fixed:
[FEATURE]:instead of[SDK].Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
If you believe this was flagged incorrectly, please let a maintainer know.
[-][SDK] MCP servers cannot be disabled at startup — no way to start server without loading user MCPs[/-][+][FEATURE]: No way to start SDK server without loading user MCP servers[/+]kud commentedon Mar 30, 2026
Workaround (until this is fixed in the SDK)
For anyone hitting this, here's what we ended up doing in @kud/ai-conventional-commit-cli:
Before calling
createOpencode(), temporarily redirectXDG_CONFIG_HOMEto a temp directory containing a minimalopencode/config.jsonwith an empty MCP section. Since the SDK spawnsopencode servewith{ ...process.env }at call time, the child process picks up the isolated config and starts with zero MCP servers.This works on macOS and Linux where opencode respects
XDG_CONFIG_HOME. It's a bit of a hack but eliminates the overhead of connecting/disconnecting all user MCP servers on every CLI invocation.iMaxTomas commentedon Apr 12, 2026
I ran into the same fundamental problem from the end-user / TUI side and did a deep-dive into the root causes. One significant finding:
chrome-devtoolsandmorphllm-fast-applyare spawned by theopencodebinary itself rather than from user configuration, so even isolatingXDG_CONFIG_HOMEinto an emptyopencode.json({"mcp":{}}) does not prevent these built-in MCPs from loading when running the full TUI or desktop app.This means the
XDG_CONFIG_HOMEworkaround you documented works for SDK callers, but end users still have no supported way to start a lean OpenCode session with zero MCP overhead.I've submitted a feature request (#22188) asking for an official kill switch (e.g.
disabled_mcp_serversarray or respectingenabled: falsefor built-ins). It references your workaround as the current best option for the SDK path, but highlights that a broader fix is needed for the binary-bundled defaults.github-actions commentedon Jul 3, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.