opencode icon indicating copy to clipboard operation
opencode copied to clipboard

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

Open HyeongDoYun opened this issue 1 week ago • 2 comments

Summary

Adds mcpServers parameter to POST /session endpoint, enabling per-session MCP server configuration via REST API.

Changes

  • Add mcpServers field to Session.create.schema
  • Pass mcpServers to Session.createNext
  • Register MCP servers via MCP.add() during session creation

Motivation

ACP (Agent Client Protocol) already supports per-session MCP via newSession(). This PR brings the same capability to the REST API, allowing external integrations to dynamically configure MCP servers per session.

Usage

POST /session
{
  "title": "My Session",
  "mcpServers": {
    "my-remote-mcp": {
      "type": "remote",
      "url": "https://mcp.example.com/sse"
    },
    "my-local-mcp": {
      "type": "local",
      "command": ["npx", "my-mcp-server"]
    }
  }
}

Testing

  • All existing tests pass (544 pass, 0 fail)

🤖 Generated with opencode

HyeongDoYun avatar Jan 04 '26 23:01 HyeongDoYun