Connect an MCP server
Connects an external MCP server. Only remote transports are
supported (sse, streamable_http) — there is no way to run a local
subprocess-based (stdio) server. Pass an Idempotency-Key header to
safely retry this request. For auth_type: "oauth2", supply
oauth_config (client_id/client_secret/authorization_url/token_url/
scopes) here, then complete
POST /mcp-servers/{mcp_server_id}/oauth/authorize to get a URL for the
dev to open in a browser and finish the provider’s consent screen —
the server isn’t actually usable until that completes.
Authorizations
A long-lived, privileged API key (ek_... prefix), minted once from the dashboard. Intended for trusted server-side use only; never expose it in client-side code. Send as Authorization: Bearer ek_.... Required by every Calls, Batches, Agents, Tools, MCP Servers, Documents, and Realtime route.
Body
sse, streamable_http none, static, oauth2 Only the pre-authorization fields a dev supplies to connect an OAuth2 MCP server. access_token/refresh_token/expires_at are never client input — they're populated by the /oauth/authorize + /oauth/callback flow (see api/v1/_mcp_servers.py) and preserved across a later update.
Response
Successful Response
ok, error