Skip to content

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

Closed as not planned

Description

@HyeongDoYun

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.

Activity

  1. github-actions commented on Jan 5, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. geosmart commented on Mar 12, 2026

    @geosmart

    so When will OpenCode add support for per-session MCP servers?

    This is a important feature in production environment

  3. geosmart commented on Mar 12, 2026

    @geosmart

    Does the acp-sdk support passing mcpServers in the session: ACP#Session Setup, NewSessionRequest

    In the source code opencode-agent.ts, the newSession function has a defined mcpServers parameter:agent.ts-mcpServers @haoqixu

    But during the actual chat conversation process, are the mcpServers defined in the session state not being used?

    I test in this way

    curl -X POST 'http://localhost:14096/session' \
    -H 'x-opencode-directory: /tmp' \
    -H 'Content-Type: application/json' \
    -d '{
            "mcpServers": [
                {
                    "type": "http",
                    "name": "custom-mcp-server",
                    "url": "http://xxx/mcp/sse",
                    "headers": [
                        {
                            "name": "Authorization",
                            "value": "Bearer wMU+xxx="
                        },
                        {
                            "name": "Content-Type",
                            "value": "application/json"
                        }
                    ]
                }
            ]
        }
        ' | jq

    does opencode support for per-session MCP servers?

  4. geosmart commented on Mar 12, 2026

    @geosmart

    in opencoder server rest api
    there is no mcpServers in Session.create.schema

  5. github-actions commented on May 12, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions