opencode
opencode copied to clipboard
feat: add per-session MCP server support for REST API (parity with ACP)
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:
- Create sessions via REST API
- Attach user-specific MCP servers to each session
- 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
mcpServerstoSession.create.schema - Call
MCP.add()increateNext()
All existing tests pass.
Questions
Is this something the team would consider? Happy to adjust the implementation based on feedback.