[PR #6884] feat(session): add per-session MCP server support for REST API #12153

Open
opened 2026-02-16 18:17:04 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6884

State: open
Merged: No


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

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6884 **State:** open **Merged:** No --- ## 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 ```bash 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
yindo added the pull-request label 2026-02-16 18:17:04 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12153