-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Description
- 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
const client = await createOpencode({
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)
const client = await createOpencode({ ... })
const statusResult = await client.mcp.status()
const mcpNames = Object.keys(statusResult.data ?? {})
await Promise.all(mcpNames.map(name => client.mcp.disconnect({ name })))
const session = await client.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: falsein config — honour it at startup when passed viaOPENCODE_CONFIG_CONTENT - A
noMcpflag 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.
Environment
@opencode-ai/sdkv1.3.7- API:
@opencode-ai/sdk/v2 - Provider:
github-copilot/gpt-4.1