# Per-user static MCP credentials

**Last updated:** 2026-11-17T20:10:49-03:00 (UTC-3)

Some MCP servers authenticate each person with their own API key rather than an OAuth grant. With this feature a console user stores their own key for such a server; the gateway sends it only on calls made with gateway keys that user owns. It complements [per-user OAuth](/docs/features/mcp-execution/) and the [team credentials](/docs/features/mcp-execution/) an administrator sets per team.

| Flag | Default | What it turns on |
| --- | --- | --- |
| `mcp_user_static_credentials` | `false` | The three self-service routes, the **My MCP credentials** panel and the use of stored credentials; an operator control; requires `mcp_user_oauth` (and so `mcp_execution`, `console_users` and the control-plane encryption key) |

## Server opt-in

A server takes a user credential only when its boot (YAML) trust says so, in one of two modes:

| Declaration | Mode | Credential used for a call |
| --- | --- | --- |
| `auth: per_user_static` | required | The calling user's own credential. Without one the call is refused with `401 mcp_auth_required` (and a `connect_url` to **MCP connections**); it never falls back to a team or boot credential. `credential_env` and `oauth` are not allowed |
| `allow_user_credential: true` (default `auth`) | preferred | The calling user's own credential when stored, else the team credential, else the boot `credential_env` |

```yaml
mcp_execution:
  servers:
    - id: billing
      endpoint_url: https://billing.example.com/mcp
      auth: per_user_static
      tools: [{name: invoices, allowed_team_ids: [finance]}]
    - id: wiki
      endpoint_url: https://wiki.example.com/mcp
      credential_env: WIKI_MCP_TOKEN
      allow_user_credential: true
      tools: [{name: search, allowed_team_ids: [support]}]
```

Console-managed servers do not take user credentials. A server declared `auth: per_user_oauth` uses only the user's OAuth grant and cannot also allow a static credential (`allow_user_credential` applies only to the default auth), so OAuth and a static credential never compete for one server.

## Precedence

| Server | User credential | Team credential | Boot `credential_env` | Result |
| --- | --- | --- | --- | --- |
| `per_user_static` | stored | any | — | user (`credential_source: user_static`) |
| `per_user_static` | none, or a key without a user owner | any | — | refused, `mcp_auth_required` |
| `allow_user_credential` | stored | any | any | user (`user_static`) |
| `allow_user_credential` | none | set | any | team (`team`) |
| `allow_user_credential` | none | none | set | boot (`boot`) |
| `per_user_oauth` | — | — | — | the user's OAuth grant only |

A key whose owner is not a console user (a service account) never uses a user credential. A disabled user's credential is never used, and the call is refused (`403 mcp_user_disabled`) instead of falling back. A storage or decryption failure answers `503 mcp_credentials_unavailable` and never falls back to another identity. The [execution trail](/docs/features/mcp-execution-audit/) records the class actually used. Scheduled and manual health checks never use a user credential.

## Storage and lifecycle

- The credential is 16-8192 characters without line breaks and is sent upstream as `Authorization: Bearer <credential>`.
- It is sealed with the control-plane encryption key under a label bound to the server and the user (`gateway_mcp_user_credentials`, migration 192), included in [keyring rotation](/docs/security/keyring-rotation/) re-encryption, and deleted with the user.
- It is never returned after it is saved: the listing shows only whether one is stored and when.
- Saving again rotates it at once; deleting it ends its use.
- Every change is audited without the value: `mcp_user_credential.set`, `.rotate` or `.delete`, target `<server>/<user>`, actor the user.
- There is no administrative read or write of another user's credential. Global administrators and organization administrators manage only their own, through the same self-service routes; no route returns or moves a user's credential. A key is attributed to its owner, though: an administrator who issues a key owned by a user (as for [per-user OAuth](/docs/features/mcp-execution/)) makes calls that use that user's credential. Restrict who may issue user-owned keys accordingly.

## Routes

All need a named console user (the self-service permission `mcp_oauth:self`, held by every named role) and act on that user only; writes need CSRF.

| Route | Does |
| --- | --- |
| `GET /api/v1/admin/mcp/user-credentials` | Each server that takes a user credential: `server_id`, `mode` (`required`, `preferred`), `stored`, `updated_at` |
| `PUT /api/v1/admin/mcp/servers/{id}/user-credential` | `{"credential": "..."}`; 204; stores or rotates |
| `DELETE /api/v1/admin/mcp/servers/{id}/user-credential` | 204, or 404 when none is stored |

## Console

**MCP connections → My MCP credentials** lists the servers that take a user credential with their mode and state, a password field with **Save** (or **Rotate**) and **Delete**. The field is cleared after a save; the value is never shown.

## Upgrade

Migration 192 creates `gateway_mcp_user_credentials` and allows the credential class `user_static` in the execution trail. An older binary rejects the flag name, `auth: per_user_static` and `allow_user_credential` in YAML: remove them before rolling back; stored credentials are then unused.
