Skip to content

[FEATURE]: No way to start SDK server without loading user MCP servers #20072

@kud

Description

@kud
  • 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:

  1. A startup option — e.g. createOpencode({ mcp: false }) to skip loading user MCPs entirely
  2. Fix enabled: false in config — honour it at startup when passed via OPENCODE_CONFIG_CONTENT
  3. 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.

Environment

  • @opencode-ai/sdk v1.3.7
  • API: @opencode-ai/sdk/v2
  • Provider: github-copilot/gpt-4.1

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions