# MCP administration API

## PUT /api/v1/admin/mcp/servers/{id}

`PUT /api/v1/admin/mcp/servers/{id}` · operation `upsertAdminMCPServer`

Create or override Streamable HTTP MCP registry metadata. This does not contact or proxy the server. The mcp_management flag, admin session, CSRF and current control version are required. A team:&lt;team_id&gt; scope limits discovery to keys bound to that team.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, pattern `^[a-z][a-z0-9_-]{0,63}$` |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `version` (integer (int64), required)
  - `server` ([MCPServer](/docs/api/schemas/m/#mcpserver), required)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | MCP server override updated; metadata and new version | — |
| `201` | MCP server created; metadata and new version | — |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | Configuration version conflict | — |
| `422` | Invalid server, scope or URL; managed URLs cannot contain query/fragment | — |


## DELETE /api/v1/admin/mcp/servers/{id}

`DELETE /api/v1/admin/mcp/servers/{id}` · operation `deleteAdminMCPServerOverride`

Remove a console MCP server or revert its override to YAML. A YAML-only server remains operator-owned; disable it through a PUT override to hide it from discovery.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `version` (integer (int64), required)

**Responses**

| Status | Description | Body |
|---|---|---|
| `204` | Override removed | — |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | MCP override not found or feature disabled | — |
| `409` | YAML server is operator-owned or version conflict | — |


## GET /api/v1/admin/mcp/health

`GET /api/v1/admin/mcp/health` · operation `listAdminMCPHealth`

Cached results of explicit MCP health checks run by this process. Reading never contacts an MCP server. Results for servers that left the registry or lost boot execution trust are hidden; results older than stale_after_seconds are marked stale and are never refreshed automatically. Requires mcp_health_checks, mcp_execution and mcp_registry, and the mcp:read console permission.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Cached results | `application/json`: object |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |

Response `200` fields:

- `application/json`: object
  - `items` (array of [MCPHealthResult](/docs/api/schemas/m/#mcphealthresult), required)
  - `stale_after_seconds` (integer, required)


## GET /api/v1/admin/mcp/boot-servers/{id}/snapshots

`GET /api/v1/admin/mcp/boot-servers/{id}/snapshots` · operation `listAdminMCPBootSnapshots`

T168, flag mcp_boot_discovery_history (requires mcp_health_checks): snapshots of a boot (YAML) server with execution trust, newest first, recorded by manual (source test) and scheduled (source scheduled) health checks when the listed tools changed; at most limit_per_server are kept. Read-only: boot trust and grants stay in YAML. Requires the mcp:read console permission.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, pattern `^[a-z][a-z0-9_-]{0,63}$` |  |
| `before` | query | integer (int64), min 1 | Only snapshots older than this snapshot ID, to page back through the history. |
| `limit` | query | integer, default `20`, min 1, max 100 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Snapshots | `application/json`: object |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled, or no boot server with execution trust has this ID | — |

Response `200` fields:

- `application/json`: object
  - `trust` (`"boot"`, required)
  - `limit_per_server` (integer, required)
  - `data` (array of object, required)
    - `id` (integer (int64), required)
    - `captured_at` (string (date-time), required)
    - `source` (string, required, one of `"test"`, `"scheduled"`)
    - `parent_id` (integer (int64))
    - `request_id` (string)
    - `endpoint_url` (string, required)
    - `protocol_version` (string, one of `"2025-11-25"`, `"2026-07-28"`)
    - `tools` (integer, required) — Tools in the validated profile
    - `unsupported` (integer, required)


## GET /api/v1/admin/mcp/boot-servers/{id}/snapshots/diff

`GET /api/v1/admin/mcp/boot-servers/{id}/snapshots/diff` · operation `diffAdminMCPBootSnapshots`

T168: the same tool diff as the console-managed history (added, removed, schema_changed, support_changed, description_changed; descriptions are compared by hash and never stored) between two snapshots of a boot server, plus missing_grants: the YAML grants the to snapshot does not offer in the validated profile.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, pattern `^[a-z][a-z0-9_-]{0,63}$` |  |
| `from` | query | integer (int64), min 1 | Default: the parent of to (none for the first snapshot, or when it left the bounded history) |
| `to` | query | integer (int64), min 1 | Default: the latest snapshot |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Diff | `application/json`: object |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled, server or snapshot not found | — |

Response `200` fields:

- `application/json`: object
  - `from` (integer (int64))
  - `to` (integer (int64), required)
  - `unchanged` (integer, required)
  - `changes` (array of object, required)
  - `missing_grants` (array of string, required)


## GET /api/v1/admin/mcp/scheduled-health

`GET /api/v1/admin/mcp/scheduled-health` · operation `listAdminMCPScheduledHealth`

T168, flag mcp_scheduled_health (requires mcp_health_checks): the effective schedule and last background result of every server a background check may contact (enabled boot servers with execution trust and active console-managed servers, except those whose calls need a user's own credential), with the effective bounds of mcp_execution.scheduled_health. Reading never contacts a server. Requires the mcp:read console permission and PostgreSQL.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Schedule | `application/json`: object |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | storage_unavailable | — |

Response `200` fields:

- `application/json`: object
  - `items` (array of [MCPScheduledHealthItem](/docs/api/schemas/m/#mcpscheduledhealthitem), required)
  - `scheduled_health` ([MCPScheduledHealthConfig](/docs/api/schemas/m/#mcpscheduledhealthconfig), required)


## PUT /api/v1/admin/mcp/servers/{id}/scheduled-health

`PUT /api/v1/admin/mcp/servers/{id}/scheduled-health` · operation `setAdminMCPScheduledHealth`

T168, flag mcp_scheduled_health: the console override of one server's schedule. true checks it every interval (it becomes due at once), false never, null returns it to YAML servers[].scheduled_health or scheduled_health.default_enabled. Audited as mcp_scheduled_health.enable, .disable or .inherit. Answers the listing. Requires the mcp:manage console permission.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, pattern `^[a-z][a-z0-9_-]{0,63}$` |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `enabled` (boolean or null, required)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The updated listing, as GET /api/v1/admin/mcp/scheduled-health | — |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled, or a server no background check may contact | — |
| `503` | storage_unavailable | — |


## GET /api/v1/admin/mcp/executions

`GET /api/v1/admin/mcp/executions` · operation `listMCPExecutions`

Durable MCP execution trail (T030.001). One record per authorized tools/list and tools/call through the REST facade or the MCP ingress, newest first, written before anything is sent. Records hold IDs (execution, request, trace, server, tool, key, team, user, ingress session), the credential class used (none, boot, team, user_oauth, user_oauth_reused, token_exchange), the delegated subject, argument and result sizes, state, whether the call was sent, HTTP status, problem code and the tool-level isError flag; never arguments, results, credentials or upstream session IDs. States - started (authorized, not sent), dispatched (sent, outcome pending), succeeded, failed, refused (not sent), uncertain (sent without a proven outcome; a dispatched record older than one minute is reported as uncertain). Requires mcp_execution_audit and mcp_execution and the mcp_audit:read console permission (admin, viewer, operator). Records older than mcp_execution.audit.retention_days are deleted in bounded batches.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `server_id` | query | string, max length 128 |  |
| `team_id` | query | string, max length 128 |  |
| `key_id` | query | string, max length 128 |  |
| `tool` | query | string, max length 128 |  |
| `request_id` | query | string, max length 128 |  |
| `session_id` | query | string, max length 128 |  |
| `state` | query | string, one of `"started"`, `"dispatched"`, `"succeeded"`, `"failed"`, `"refused"`, `"uncertain"` |  |
| `surface` | query | string, one of `"rest"`, `"mcp"`, `"code_mode"` |  |
| `from` | query | string (date-time) |  |
| `to` | query | string (date-time) |  |
| `limit` | query | integer, default `50`, min 1, max 200 | Most rows on this page, 1-200 (50 by default). |
| `cursor` | query | string, max length 64 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | One page of records | `application/json`: object |
| `400` | invalid_filter or invalid_cursor | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | storage_unavailable | — |

Response `200` fields:

- `application/json`: object
  - `data` (array of [MCPExecution](/docs/api/schemas/m/#mcpexecution), required)
  - `next_cursor` (string)
  - `retention_days` (integer, required)


## GET /api/v1/admin/mcp/submissions

`GET /api/v1/admin/mcp/submissions` · operation `listMCPSubmissions`

Delegated MCP submissions (T030.003.001, flag mcp_submissions with mcp_connect). Console permission mcp_submissions:submit (team_admin, admin). A team administrator sees the submissions of the teams they administer; a global administrator sees all. Each entry is the team view - status, review notes and the approved tools granted to the submitting team - never other teams' grants.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Submissions | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |


## POST /api/v1/admin/mcp/submissions

`POST /api/v1/admin/mcp/submissions` · operation `submitMCPServer`

Proposes a remote MCP server for one team the caller administers (403 team_forbidden otherwise). The same ID and endpoint rules as a console draft (https, or loopback http only with mcp_execution.allow_loopback_http; no credentials, query or fragment); auth is always none, so no credential is submitted. The server enters the review queue as pending_review; nothing is contacted and nothing runs until a global reviewer tests it and approves tools, and approvals of a submission can grant only the submitting team (400 submission_grant_forbidden). Network trust stays the boot egress policy limited to the server origin.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `id` (string, required, pattern `^[a-z][a-z0-9_-]{1,63}$`)
  - `name` (string, required, max length 80)
  - `endpoint_url` (string, required, max length 2048)
  - `team_id` (string, required, max length 128)
  - `notes` (string, max length 500)

**Responses**

| Status | Description | Body |
|---|---|---|
| `201` | Submission created as pending_review | — |
| `400` | invalid_mcp_server or team_not_found | — |
| `403` | Role or team forbidden | — |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | mcp_server_exists | — |


## DELETE /api/v1/admin/mcp/submissions/{id}

`DELETE /api/v1/admin/mcp/submissions/{id}` · operation `withdrawMCPSubmission`

Withdraws a submission of an administered team while it is draft, pending_review or rejected (409 mcp_server_state otherwise; an approved or disabled server stays with its reviewer). Audited; a server with a grant history gets a delete revision.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `version` (integer (int64), required)

**Responses**

| Status | Description | Body |
|---|---|---|
| `204` | Withdrawn | — |
| `404` | Feature disabled, or no such submission for the caller's teams | — |
| `409` | version_conflict or mcp_server_state | — |


## GET /api/v1/admin/mcp/sessions

`GET /api/v1/admin/mcp/sessions` · operation `listMCPSessions`

MCP ingress sessions (T030.003.002, flag mcp_session_management with mcp_ingress), newest first. Console permission mcp_sessions:read: admin, viewer and operator see every team; team roles see only their own teams, applied before filters and paging. An expired open session is reported with termination_reason expired. Session tokens are never returned.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `key_id` | query | string, max length 128 |  |
| `team_id` | query | string, max length 128 |  |
| `server_id` | query | string, max length 128 |  |
| `open` | query | boolean |  |
| `limit` | query | integer, default `50`, min 1, max 200 |  |
| `cursor` | query | string, max length 64 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Sessions with next_cursor | — |
| `400` | invalid_filter or invalid_cursor | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |


## POST /api/v1/admin/mcp/sessions/{id}/terminate

`POST /api/v1/admin/mcp/sessions/{id}/terminate` · operation `terminateMCPSession`

Ends an open session (console permission mcp_sessions:manage: admin and operator for every team, team_admin for administered teams). The next message of the session answers 404 on every replica; calls of the session running on this replica are cancelled (a sent call is recorded uncertain). termination_reason is administrator (admin, operator) or team_administrator; an identity audit row mcp_session.terminate is written in the same statement.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, pattern `^mcs_[0-9a-f]{24}$` |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The ended session | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled, or no open session for the caller's teams | — |


## GET /api/v1/admin/mcp/oauth/reuse

`GET /api/v1/admin/mcp/oauth/reuse` · operation `listMCPCredentialReuse`

Consented credential reuse (T030.006, flag mcp_credential_reuse with mcp_user_oauth). For the session user, every boot per-user OAuth server declaring oauth.reuse_from - source_server_id, audience, scopes, source_connected, the consent if any and current (false when the declaration changed since the consent). Never returns a token. Requires mcp_oauth:self and a named console user.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Offers | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |


## POST /api/v1/admin/mcp/servers/{id}/oauth/reuse

`POST /api/v1/admin/mcp/servers/{id}/oauth/reuse` · operation `consentMCPCredentialReuse`

Records the caller's consent to use their grant of the declared source for this server. Requires an active source grant whose scopes include this server's scopes and a target authorization server (RFC 9728 discovery) equal to the grant issuer. The consent stores source, issuer, client_id, audience, the target endpoint and scopes; every later use re-checks them on the grant actually sent. Audited as mcp_oauth.reuse_consent.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 128 |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The consent | — |
| `404` | Feature disabled, or no server declaring reuse under this ID | — |
| `409` | mcp_reuse_source_not_connected, mcp_reuse_resource_mismatch (the source grant was obtained for another resource; reconnect it), mcp_reuse_scope_not_granted or mcp_reuse_issuer_mismatch | — |
| `503` | Authorization metadata or storage unavailable | — |


## DELETE /api/v1/admin/mcp/servers/{id}/oauth/reuse

`DELETE /api/v1/admin/mcp/servers/{id}/oauth/reuse` · operation `revokeMCPCredentialReuse`

Revokes only this binding (targeted revocation); the source grant and other bindings stay. Disconnecting the source revokes all its bindings. Audited as mcp_oauth.reuse_revoke.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 128 |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `204` | Revoked | — |
| `404` | Feature disabled or no consent | — |


## GET /api/v1/admin/mcp/catalog

`GET /api/v1/admin/mcp/catalog` · operation `listMCPCatalog`

MCP server catalog (ADR 0138), read live from the official MCP Registry (registry.modelcontextprotocol.io, v0 API) instead of a fixed list. Only the latest active version of each server is returned. Remotes are limited to HTTPS streamable HTTP or SSE endpoints the gateway can connect; servers that only ship packages (npm, PyPI, OCI) come with local_only=true, since the gateway does not run stdio servers. Each answer is cached for ten minutes per query; when the registry is down a cached page is served with a Warning header, otherwise 503. Choosing a server only prefills the console draft; nothing runs before the usual review. Requires mcp_catalog and the mcp:read console permission.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `search` | query | string, max length 100 | Text searched in the public MCP Registry, up to 100 characters. |
| `cursor` | query | string, max length 300 | The next_cursor of the previous page. |
| `limit` | query | integer, default `30`, min 1, max 100 | Most servers on this page, 1-100 (30 by default). |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Catalog page: source, servers (name, title, description, version, repository, remotes with transport/url/headers, packages, local_only), next_cursor, fetched_at | — |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | catalog_unavailable: the registry did not answer and nothing is cached | — |


## GET /api/v1/admin/mcp/user-credentials

`GET /api/v1/admin/mcp/user-credentials` · operation `listMCPUserCredentials`

T168, flag mcp_user_static_credentials (requires mcp_user_oauth): the session user's own static credentials. Lists every boot MCP server that takes one, with mode required (auth: per_user_static: calls without it are refused, never falling back) or preferred (allow_user_credential: it comes before the team and boot credentials), whether the user stored one and when. The value is never returned; no route reads another user's. Requires a named console user (mcp_oauth:self, every named role).

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The session user's credentials, metadata only | `application/json`: object |
| `400` | named_user_required | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |

Response `200` fields:

- `application/json`: object
  - `data` (array of object, required)
    - `server_id` (string, required)
    - `mode` (string, required, one of `"required"`, `"preferred"`)
    - `stored` (boolean, required)
    - `updated_at` (string (date-time))


## PUT /api/v1/admin/mcp/servers/{id}/user-credential

`PUT /api/v1/admin/mcp/servers/{id}/user-credential` · operation `setMCPUserCredential`

T168: store or rotate the session user's own credential for a server that takes one; sealed with the control-plane key, sent upstream as Authorization Bearer only on calls made with keys this user owns, never shown again. Audited as mcp_user_credential.set or .rotate (target &lt;server&gt;/&lt;user&gt;), without the value.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `credential` (string, required, min length 16, max length 8192, write-only) — No line breaks

**Responses**

| Status | Description | Body |
|---|---|---|
| `204` | Stored | — |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled, or no server with this ID takes a user credential | — |
| `422` | invalid_credential | — |
| `503` | encryption_unavailable or storage_unavailable | — |


## DELETE /api/v1/admin/mcp/servers/{id}/user-credential

`DELETE /api/v1/admin/mcp/servers/{id}/user-credential` · operation `deleteMCPUserCredential`

T168: delete the session user's own credential for a server; audited as mcp_user_credential.delete. Calls of a per_user_static server are refused from then on; a preferred server falls back to the team or boot credential.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `204` | Deleted | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled, unknown server, or no credential stored | — |


## GET /api/v1/admin/mcp/oauth/connections

`GET /api/v1/admin/mcp/oauth/connections` · operation `listMCPOAuthConnections`

Requires mcp_user_oauth and a named console user (mcp_oauth:self, every named role). Status of the session user on each MCP server declared per_user_oauth (ADR 0091): active, needs_reauth or not_connected. Tokens are never returned.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Connections of the session user | `application/json`: object |
| `400` | Bootstrap token session; connect from a named console user | — |
| `404` | Feature disabled | — |

Response `200` fields:

- `application/json`: object
  - `data` (array of object, required)
    - `server_id` (string, required)
    - `status` (string, required, one of `"active"`, `"needs_reauth"`, `"not_connected"`)
    - `expires_at` (string (date-time))
    - `updated_at` (string (date-time))


## POST /api/v1/admin/mcp/servers/{id}/oauth/connect

`POST /api/v1/admin/mcp/servers/{id}/oauth/connect` · operation `startMCPOAuthConnection`

Starts OAuth 2.1 for the session user: RFC 9728 then RFC 8414/OIDC discovery through the MCP egress guard (authorization servers must be in mcp_execution.allowed_origins), PKCE S256 generated by the gateway, resource (RFC 8707) by default, a single-use state valid 10 minutes, and the pre-registered client or RFC 7591 registration. The browser follows authorize_url.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Authorization URL | `application/json`: object |
| `400` | Bootstrap token session | — |
| `404` | Unknown per-user server or feature disabled | — |
| `502` | Discovery or registration failed, or the authorization server does not advertise S256 (mcp_oauth_pkce_unsupported) | — |

Response `200` fields:

- `application/json`: object
  - `authorize_url` (string (uri), required)


## GET /api/v1/admin/mcp/oauth/callback

`GET /api/v1/admin/mcp/oauth/callback` · operation `completeMCPOAuthConnection`

Redirect target registered at the authorization server (mcp_execution.oauth_redirect_url). The owner comes from the single-use state sealed at start, not from a cookie (the SameSite=Strict session is absent on this cross-site navigation). Always redirects to the console with #mcp-oauth=connected or #mcp-oauth=failed, without details.

**Authentication:** None.

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `state` | query | string, required, max length 256 |  |
| `code` | query | string, max length 4096 |  |
| `error` | query | string |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `303` | Redirect to /ui/#mcp-oauth=connected or /ui/#mcp-oauth=failed | — |


## DELETE /api/v1/admin/mcp/servers/{id}/oauth

`DELETE /api/v1/admin/mcp/servers/{id}/oauth` · operation `disconnectMCPOAuth`

Revokes the session user grant at the provider (RFC 7009) when it publishes revocation_endpoint, then deletes it; the next call answers mcp_auth_required.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Disconnected | `application/json`: object |
| `404` | Not connected, unknown server or feature disabled | — |

Response `200` fields:

- `application/json`: object
  - `revoked_at_provider` (boolean, required)


## GET /api/v1/admin/mcp/servers/{id}/credentials

`GET /api/v1/admin/mcp/servers/{id}/credentials` · operation `listMCPTeamCredentials`

Teams that have their own upstream credential (BYOK) for a server with boot execution trust. Values are never returned. Requires mcp_team_credentials, mcp_execution and mcp_credentials:manage (admin and operator for any team; team_admin only for the teams it administers, and the listing is filtered to them).

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Teams with a stored credential | `application/json`: object |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | Server lacks boot execution trust | — |

Response `200` fields:

- `application/json`: object
  - `items` (array of object, required)
    - `server_id` (string, required)
    - `team_id` (string, required)
    - `updated_at` (string (date-time), required)
  - `boot_credential` (boolean, required)


## PUT /api/v1/admin/mcp/servers/{id}/credentials/{team}

`PUT /api/v1/admin/mcp/servers/{id}/credentials/{team}` · operation `setMCPTeamCredential`

Store (encrypted, audited) the credential used for this team's keys instead of the boot credential. Endpoint, network policy and tool grants stay in boot trust.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |
| `team` | path | string, required |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `credential` (string, required, min length 16, max length 8192, write-only)

**Responses**

| Status | Description | Body |
|---|---|---|
| `204` | Saved | — |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Team not found or feature disabled | — |
| `409` | Server lacks boot execution trust | — |
| `422` | Invalid credential | — |
| `503` | Storage or encryption key unavailable | — |


## DELETE /api/v1/admin/mcp/servers/{id}/credentials/{team}

`DELETE /api/v1/admin/mcp/servers/{id}/credentials/{team}` · operation `deleteMCPTeamCredential`

Remove the team credential; the team's keys fall back to the boot credential.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required |  |
| `team` | path | string, required |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `204` | Removed | — |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | No credential for this team, or feature disabled | — |
| `409` | Server lacks boot execution trust | — |


## POST /api/v1/admin/mcp/servers/{id}/health

`POST /api/v1/admin/mcp/servers/{id}/health` · operation `checkAdminMCPHealth`

Explicitly initialize an MCP session and list tools for one enabled registry server whose URL matches its boot execution trust, using the same network policy, credential environment and shared heavy-operation admission as execution, bounded to 10 seconds. No tool is called. Upstream error text, tool descriptions, credentials and session IDs are never returned or logged; failures are reduced to error_class. Requires mcp_health_checks and the mcp:manage console permission.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, pattern `^[a-z][a-z0-9_-]{0,63}$` |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Check result; an unreachable server is still 200 with reachable=false and error_class | `application/json`: [MCPHealthResult](/docs/api/schemas/m/#mcphealthresult) |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | Server is disabled, not in the registry or lacks boot execution trust for its URL | — |
| `503` | MCP operation capacity is exhausted | — |


## GET /api/v1/admin/mcp/managed-servers

`GET /api/v1/admin/mcp/managed-servers` · operation `listMCPManagedServers`

Requires mcp_connect and mcp_connect:read (admin, viewer). Remote MCP servers added from the console or imported from mcp.json (ADR 0092), with status, drift flag, per-tool approvals and the latest tool snapshot. Servers declared in YAML are not listed here.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Managed servers | `application/json`: object |
| `404` | Feature disabled | — |

Response `200` fields:

- `application/json`: object
  - `data` (array of [MCPManagedServer](/docs/api/schemas/m/#mcpmanagedserver), required)


## POST /api/v1/admin/mcp/managed-servers

`POST /api/v1/admin/mcp/managed-servers` · operation `createMCPManagedServer`

Requires mcp_connect:manage. Always creates a draft: nothing executes until tools of a tested snapshot are approved for explicit teams. The endpoint must be https (loopback http only with mcp_execution.network.allow_loopback_http); only its origin is reachable, and the egress guard still refuses private and special addresses at dial time.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [MCPManagedInput](/docs/api/schemas/m/#mcpmanagedinput)

**Responses**

| Status | Description | Body |
|---|---|---|
| `201` | Draft created | `application/json`: [MCPManagedServer](/docs/api/schemas/m/#mcpmanagedserver) |
| `400` | invalid_mcp_server | — |
| `404` | Feature disabled | — |
| `409` | ID already used by a managed or YAML server | — |


## POST /api/v1/admin/mcp/managed-servers/import

`POST /api/v1/admin/mcp/managed-servers/import` · operation `importMCPManagedServers`

Requires mcp_connect:manage. Reads the mcpServers object of Claude Desktop, Cursor or VS Code (1-50 entries, 64 KiB). Remote entries (url) become drafts; stdio entries (command) are skipped because the gateway never runs local commands; static headers are not imported (the entry becomes a draft with a reason; encrypted headers are phase 2). Nothing becomes executable on import.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `mcpServers` (object, required)
    - any other key: object
      - `url` (string)
      - `type` (string)
      - `command` (string)
      - `headers` (object)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Per-entry outcome | `application/json`: object |
| `400` | invalid_import | — |
| `404` | Feature disabled | — |

Response `200` fields:

- `application/json`: object
  - `imported` (array of [MCPImportOutcome](/docs/api/schemas/m/#mcpimportoutcome), required)
  - `skipped` (array of [MCPImportOutcome](/docs/api/schemas/m/#mcpimportoutcome), required)
  - `errors` (array of [MCPImportOutcome](/docs/api/schemas/m/#mcpimportoutcome), required)


## PUT /api/v1/admin/mcp/managed-servers/{id}

`PUT /api/v1/admin/mcp/managed-servers/{id}` · operation `updateMCPManagedServer`

Requires mcp_connect:manage. Changing endpoint_url or auth returns the server to draft and clears every approval: a reviewed tool set never follows a server to a new address.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [MCPManagedInput](/docs/api/schemas/m/#mcpmanagedinput)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Server after the transition | `application/json`: [MCPManagedServer](/docs/api/schemas/m/#mcpmanagedserver) |
| `400` | Invalid body | — |
| `404` | Feature disabled or server not found | — |
| `409` | version_conflict, or mcp_server_state when the transition is not allowed | — |


## DELETE /api/v1/admin/mcp/managed-servers/{id}

`DELETE /api/v1/admin/mcp/managed-servers/{id}` · operation `deleteMCPManagedServer`

Requires mcp_connect:manage. Refused while the server is active; disable it first. Snapshots and approvals go with it.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [MCPManagedVersion](/docs/api/schemas/m/#mcpmanagedversion)

**Responses**

| Status | Description | Body |
|---|---|---|
| `204` | Deleted | — |
| `400` | Invalid body | — |
| `404` | Feature disabled or server not found | — |
| `409` | version_conflict, or mcp_server_state while active | — |


## POST /api/v1/admin/mcp/managed-servers/{id}/test

`POST /api/v1/admin/mcp/managed-servers/{id}/test` · operation `testMCPManagedServer`

Requires mcp_connect:manage. Connects through the egress guard, lists tools and records a new snapshot only when something changed. Tools whose input schema uses constructs the gateway does not validate (combinators, refs, formats) are recorded with unsupported=true and can never be approved. With per_user_oauth it uses the administrator's own connection.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Snapshot | `application/json`: object |
| `404` | Feature disabled or server not found | — |
| `502` | mcp_upstream_unauthorized, mcp_upstream_unreachable or mcp_upstream_failed (private address, wrong URL or unsupported profile) | — |
| `504` | mcp_upstream_timeout | — |

Response `200` fields:

- `application/json`: object
  - `snapshot_id` (integer (int64), required)
  - `tools` (array of [MCPSnapshotTool](/docs/api/schemas/m/#mcpsnapshottool), required)
  - `protocol_version` (string, one of `"2025-11-25"`, `"2026-07-28"`) — MCP revision the test negotiated (T168)
  - `protocol_fallback` (string) — Empty, legacy_server or server_advertised: why an auto test used 2025-11-25 (T168)


## POST /api/v1/admin/mcp/managed-servers/{id}/approve

`POST /api/v1/admin/mcp/managed-servers/{id}/approve` · operation `approveMCPManagedServer`

Requires mcp_connect:manage. Replaces every approval with the listed tools of one snapshot, each pinned to the schema hash of that snapshot and granted to explicit active teams (no wildcard). schema_sha256, when sent, must equal the snapshot hash: a stale review screen is refused, not approved anyway. Unlisted tools never run.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `snapshot_id` (integer (int64), required)
  - `version` (integer (int64), required)
  - `notes` (string, max length 500)
  - `acknowledge_side_effects` (boolean) — Required (true) to approve an OpenAPI-generated tool whose method is not GET or HEAD (T031.002); ignored for MCP servers
  - `base_snapshot_id` (integer (int64)) — The approved snapshot the reviewer compared against (T030.002). With mcp_discovery_history it is required for a server that already has an approved snapshot and must equal it (and must be omitted for a first approval); ignored while the flag is off. The approval then appends an immutable grant revision.
  - `tools` (array of [MCPToolApproval](/docs/api/schemas/m/#mcptoolapproval), required, min items 1, max items 256)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Active server | `application/json`: [MCPManagedServer](/docs/api/schemas/m/#mcpmanagedserver) |
| `400` | invalid_mcp_server, team_not_found when a granted team is not active, or side_effects_unacknowledged for a non-GET generated tool without acknowledge_side_effects | — |
| `404` | Feature disabled, server or snapshot not found | — |
| `409` | version_conflict, mcp_server_state when a tool is outside the snapshot, unsupported, or its hash differs, or mcp_review_required when base_snapshot_id is missing or is not the approved snapshot (T030.002) | — |


## GET /api/v1/admin/mcp/managed-servers/{id}/snapshots

`GET /api/v1/admin/mcp/managed-servers/{id}/snapshots` · operation `listMCPSnapshots`

Discovery history (T030.002). Requires mcp_discovery_history (and mcp_connect) and mcp_connect:read. Snapshots newest first with provenance - source (test, drift, import, or legacy for rows recorded before migration 151), parent snapshot, request ID - tool and unsupported counts and whether it is the approved snapshot. Never contacts the server.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |
| `before` | query | integer (int64), min 1 | Return snapshots older than this ID |
| `limit` | query | integer, default `20`, min 1, max 100 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Snapshots | `application/json`: object |
| `400` | invalid_filter | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled or server not found | — |

Response `200` fields:

- `application/json`: object
  - `data` (array of object, required)
    - `id` (integer (int64), required)
    - `captured_at` (string (date-time), required)
    - `source` (string, required, one of `"legacy"`, `"test"`, `"drift"`, `"import"`)
    - `parent_id` (integer (int64))
    - `request_id` (string)
    - `tools` (integer, required)
    - `unsupported` (integer, required)
    - `approved` (boolean, required)


## GET /api/v1/admin/mcp/managed-servers/{id}/snapshots/diff

`GET /api/v1/admin/mcp/managed-servers/{id}/snapshots/diff` · operation `diffMCPSnapshots`

Tool-level diff between two snapshots of the same server (T030.002). from defaults to the approved snapshot (none for a never-approved server, so every tool is added), to to the latest snapshot. Each change is added, removed, schema_changed, support_changed (moved in or out of the validated JSON Schema profile) or description_changed. affected_approvals lists currently approved tools that would not run against to (missing, unsupported or a schema other than the approved hash). Requires mcp_discovery_history and mcp_connect:read.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |
| `from` | query | integer (int64), min 1 |  |
| `to` | query | integer (int64), min 1 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Diff | `application/json`: object |
| `400` | invalid_filter | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled, server or snapshot not found, or no snapshot yet | — |

Response `200` fields:

- `application/json`: object
  - `from` (integer (int64))
  - `to` (integer (int64), required)
  - `unchanged` (integer, required)
  - `affected_approvals` (array of string, required)
  - `changes` (array of object, required)
    - `name` (string, required)
    - `change` (string, required, one of `"added"`, `"removed"`, `"schema_changed"`, `"support_changed"`, `"description_changed"`)
    - `before_schema_sha256` (string)
    - `after_schema_sha256` (string)
    - `before_unsupported` (boolean)
    - `after_unsupported` (boolean)
    - `description_changed` (boolean)


## GET /api/v1/admin/mcp/managed-servers/{id}/grant-revisions

`GET /api/v1/admin/mcp/managed-servers/{id}/grant-revisions` · operation `listMCPGrantRevisions`

Immutable grant revisions (T030.002), newest first - one per approval while mcp_discovery_history is on, with the approved snapshot, the reviewed base snapshot, the approvals before and after, actor, notes and request ID. Revisions remain readable after the server is deleted. Requires mcp_discovery_history and mcp_connect:read.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |
| `limit` | query | integer, default `20`, min 1, max 100 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Revisions | `application/json`: object |
| `400` | invalid_filter | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |

Response `200` fields:

- `application/json`: object
  - `data` (array of object, required)
    - `server_id` (string, required)
    - `revision` (integer, required)
    - `reason` (string, required, one of `"approve"`, `"reset"`, `"delete"`) — reset and delete record approvals dropped outside an approval, only for a server that already has a history
    - `server_created_at` (string (date-time)) — Tells incarnations of a reused server ID apart
    - `snapshot_id` (integer (int64)) — Approved snapshot; absent for reset and delete
    - `base_snapshot_id` (integer (int64))
    - `approvals` (array of [MCPToolApproval](/docs/api/schemas/m/#mcptoolapproval), required)
    - `previous` (array of [MCPToolApproval](/docs/api/schemas/m/#mcptoolapproval), required)
    - `actor` (string, required)
    - `notes` (string)
    - `request_id` (string)
    - `created_at` (string (date-time), required)


## POST /api/v1/admin/mcp/openapi-sources

`POST /api/v1/admin/mcp/openapi-sources` · operation `createMCPOpenAPISource`

Requires mcp_openapi_tools (and mcp_connect), mcp_connect:manage. Generates draft API-operation tools from an inline OpenAPI 3.0/3.1 document (JSON or YAML, one document, at most mcp_execution.openapi.max_spec_bytes and max_operations); the gateway never fetches the document, a server URL or a reference (only local #/components references are resolved). Each operation becomes a tool with an explicit method, path, path/query parameter and JSON body mapping; operations outside the profile are kept as unsupported tools with their reasons. The source is a console-managed server of kind openapi in draft: nothing is callable before an approval. base_url is the administrator's choice (https, or loopback http only with mcp_execution.allow_loopback_http) and the egress guard pins every call to its origin. auth none sends no credential; team_credential sends the per-team encrypted MCP credential in the header of security_scheme (http bearer or apiKey in header) to operations that require exactly that scheme.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [MCPOpenAPISourceInput](/docs/api/schemas/m/#mcpopenapisourceinput)

**Responses**

| Status | Description | Body |
|---|---|---|
| `201` | Draft source with its generated operations and diagnostics | `application/json`: [MCPOpenAPISourceResult](/docs/api/schemas/m/#mcpopenapisourceresult) |
| `400` | invalid_request, invalid_mcp_server (ID, name or base_url), invalid_openapi_source (auth and security_scheme) | — |
| `403` | Role forbidden | — |
| `404` | Feature disabled | — |
| `409` | mcp_server_exists | — |
| `422` | unsupported_openapi_document: not OpenAPI 3.0/3.1, more than one YAML document, excessive aliasing, too large, too many operations, or an undeclared/unsupported security scheme | — |


## PUT /api/v1/admin/mcp/openapi-sources/{id}

`PUT /api/v1/admin/mcp/openapi-sources/{id}` · operation `updateMCPOpenAPISource`

Requires mcp_openapi_tools, mcp_connect:manage and the current version. Records the document as a new snapshot; the approved snapshot keeps running unchanged until a reviewer approves the new one. Changing auth, the base URL origin or the credential header returns the source to draft, removes every approval and erases the teams' stored credentials.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [MCPOpenAPISourceInput](/docs/api/schemas/m/#mcpopenapisourceinput)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Source with the new snapshot | `application/json`: [MCPOpenAPISourceResult](/docs/api/schemas/m/#mcpopenapisourceresult) |
| `400` | Invalid input or missing version | — |
| `404` | Feature disabled or source not found | — |
| `409` | version_conflict, or mcp_server_state for a disabled source or a server that is not of kind openapi | — |
| `422` | unsupported_openapi_document | — |


## GET /api/v1/admin/mcp/openapi-sources/{id}/snapshots/{snapshot}

`GET /api/v1/admin/mcp/openapi-sources/{id}/snapshots/{snapshot}` · operation `getMCPOpenAPISnapshot`

Requires mcp_openapi_tools and mcp_connect:read. The exact generated mapping a reviewer approves, with document provenance (SHA-256, OpenAPI version, title, version) and diagnostics.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |
| `snapshot` | path | integer, required, min 1 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Generated mapping of one snapshot | `application/json`: object |
| `404` | Feature disabled, source or snapshot not found | — |


## POST /api/v1/admin/mcp/managed-servers/{id}/reject

`POST /api/v1/admin/mcp/managed-servers/{id}/reject` · operation `rejectMCPManagedServer`

Requires mcp_connect:manage. Marks a draft or pending server as rejected, with optional notes.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [MCPManagedVersion](/docs/api/schemas/m/#mcpmanagedversion)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Server after the transition | `application/json`: [MCPManagedServer](/docs/api/schemas/m/#mcpmanagedserver) |
| `400` | Invalid body | — |
| `404` | Feature disabled or server not found | — |
| `409` | version_conflict, or mcp_server_state when the transition is not allowed | — |


## POST /api/v1/admin/mcp/managed-servers/{id}/disable

`POST /api/v1/admin/mcp/managed-servers/{id}/disable` · operation `disableMCPManagedServer`

Requires mcp_connect:manage. Stops execution at the next request; approvals are kept for audit, and the server stops appearing in /v1/mcp/servers.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, max length 64 |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [MCPManagedVersion](/docs/api/schemas/m/#mcpmanagedversion)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Server after the transition | `application/json`: [MCPManagedServer](/docs/api/schemas/m/#mcpmanagedserver) |
| `400` | Invalid body | — |
| `404` | Feature disabled or server not found | — |
| `409` | version_conflict, or mcp_server_state when the transition is not allowed | — |

