opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat: add per-session MCP server support for REST API (parity with ACP)

Open HyeongDoYun opened this issue 1 week ago • 1 comments

Problem

ACP (newSession()) supports mcpServers parameter for per-session MCP configuration, but REST API POST /session doesn't.

This creates inconsistency for integrations that need dynamic MCP configuration via REST.

Use Case

External platforms (like MCP orchestrators) need to:

  1. Create sessions via REST API
  2. Attach user-specific MCP servers to each session
  3. Currently impossible without ACP

Proposed Solution

Add mcpServers parameter to POST /session endpoint, matching ACP behavior:

POST /session
{
  "title": "My Session",
  "mcpServers": {
    "user-mcp": {
      "type": "remote",
      "url": "https://user-specific-mcp.com/sse"
    }
  }
}

Implementation

I've already implemented this and opened a PR: #6884

Changes are minimal (~15 lines):

  • Add mcpServers to Session.create.schema
  • Call MCP.add() in createNext()

All existing tests pass.

Questions

Is this something the team would consider? Happy to adjust the implementation based on feedback.

HyeongDoYun avatar Jan 05 '26 23:01 HyeongDoYun