---
title: "Add MCP server"
method: POST
path: "/mcp"
---

# Add MCP server

`POST /mcp`

Dynamically add a new Model Context Protocol (MCP) server to the system.

## Query parameters

- `directory` string
- `workspace` string

## Request body

- object
  - `name` string, required
  - `config` union, required
    - McpLocalConfig
      - `type` 'local', required — Type of MCP server connection
      - `command` string[], required — Command and arguments to run the MCP server
      - `environment` object — Environment variables to set when running the MCP server
      - `enabled` boolean — Enable or disable the MCP server on startup
      - `timeout` number — Timeout in ms for MCP server requests. Defaults to 5000 (5 seconds) if not specified.
    - McpRemoteConfig
      - `type` 'remote', required — Type of MCP server connection
      - `url` string, required — URL of the remote MCP server
      - `enabled` boolean — Enable or disable the MCP server on startup
      - `headers` object — Headers to send with the request
      - `oauth` union — OAuth authentication configuration for the MCP server. Set to false to disable OAuth auto-detection.
        - McpOAuthConfig
          - `clientId` string — OAuth client ID. If not provided, dynamic client registration (RFC 7591) will be attempted.
          - `clientSecret` string — OAuth client secret (if required by the authorization server)
          - `scope` string — OAuth scopes to request during authorization
          - `redirectUri` string — OAuth redirect URI (default: http://127.0.0.1:19876/mcp/oauth/callback).
        - false
      - `timeout` number — Timeout in ms for MCP server requests. Defaults to 5000 (5 seconds) if not specified.

## Response `200`

MCP server added successfully

- object

## Other responses

- `400` — Bad request

---

[API](https://skmtc.net/kaaass/apis/opencode.md) · [All operations](https://skmtc.net/kaaass/apis/opencode/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/kaaass/opencode/versions/8bb9a15bd144/schema)
