opencode
opencode copied to clipboard
feat(session): add per-session MCP server support for REST API
Summary
Adds mcpServers parameter to POST /session endpoint, enabling per-session MCP server configuration via REST API.
Changes
- Add
mcpServersfield toSession.create.schema - Pass
mcpServerstoSession.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