---
title: "Add MCP server"
method: PUT
path: "/api/experimental/mcp/{server}"
tags: ["mcp"]
---

# Add MCP server

`PUT /api/experimental/mcp/{server}`

## Request

- Base URL: `https://opencode.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://opencode.ai/api/experimental/mcp/{server}`
- Auth: none required

Add an MCP server at runtime or replace an existing one, connecting it immediately.

## Path parameters

- `server` string, required

## Query parameters

- `location` object, nullable
  - `directory` string, nullable

## Request body

- object
  - `config` union, required
    - McpLocalConfigEncoded
      - `type` 'local', required
      - `command` string[], required
      - `cwd` string
      - `environment` object
      - `disabled` boolean
      - `codemode` boolean
      - `timeout` object
        - `startup` integer
        - `catalog` integer
        - `execution` integer
      - `protocol` 'legacy' | 'auto' | '2026-07-28': MCP protocol negotiation. "legacy" (default) opens with the initialize handshake and speaks protocol revisions up to 2025-11-25. "auto" probes for the 2026-07-28 revision and falls back to legacy when the server does not support it. "2026-07-28" requires that revision and fails otherwise.
    - McpRemoteConfigEncoded
      - `type` 'remote', required
      - `url` string, required
      - `headers` object
      - `oauth` union
        - McpOAuthConfigEncoded
          - `client_id` string
          - `client_secret` string
          - `scope` string
          - `callback_port` integer
          - `redirect_uri` string
          - `auth_server_metadata_url` string
        - false
      - `disabled` boolean
      - `codemode` boolean
      - `timeout` object
        - `startup` integer
        - `catalog` integer
        - `execution` integer
      - `protocol` 'legacy' | 'auto' | '2026-07-28': MCP protocol negotiation. "legacy" (default) opens with the initialize handshake and speaks protocol revisions up to 2025-11-25. "auto" probes for the 2026-07-28 revision and falls back to legacy when the server does not support it. "2026-07-28" requires that revision and fails otherwise.

## Response `204`

<No Content>

## Other responses

- `400`: InvalidRequestError
- `401`: UnauthorizedError
- `404`: LocationNotFoundError

---

[API](https://skmtc.dev/kaaass/apis/opencode.md) - [All operations](https://skmtc.dev/kaaass/apis/opencode/llms.txt) - [OpenAPI document](https://skmtc.dev/kaaass/apis/opencode/revisions/4e083d954707?raw)
