Skip to content

API Reference

http://your-mcpgate-host:8000/api/v1

Health check (no auth):

http://your-mcpgate-host:8000/health

All admin endpoints require an Authorization header:

Authorization: Bearer <ADMIN_API_KEY>

The /verify endpoint is intentionally unauthenticated — it is the high-frequency path called by MCP servers on every request.


MethodPathAuthDescription
POST/api/v1/keysAdminCreate a new API key
GET/api/v1/keys/{user_id}AdminList all keys for a user
DELETE/api/v1/keys/{key_id}AdminRevoke and delete a key
POST/api/v1/verifyNoneVerify an incoming key
GET/healthNoneHealth check

Create a new API key for a user. Returns the plain-text key once only.

{
"user_id": "user_123",
"name": "Claude Desktop",
"scopes": {"read": true, "write": false},
"expires_in_days": 365
}
FieldTypeRequiredDescription
user_idstring✅ID of the user in your application
namestring—Human-readable label (e.g. “Claude Desktop”)
scopesobject—Arbitrary JSON permissions object
expires_in_daysinteger—Days until expiry. Omit for no expiry. Use -1 to create an already-expired key (testing).
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"key": "mcp_sk_3f8a1c2e9b4d7f6a_4a7b2c9e1d3f8a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b",
"prefix": "mcp_sk_3f8a1c2e9b4d7f6a_...9b",
"user_id": "user_123",
"name": "Claude Desktop",
"created_at": "2026-04-16T10:00:00Z"
}
FieldDescription
idUUID — use this to revoke the key
keyFull plain-text key — shown once, never retrievable again
prefixSafe display string — show to users to identify the key
user_idEchoed from request
nameEchoed from request
created_atUTC timestamp
StatusDescription
401Missing or malformed Authorization header
403Wrong ADMIN_API_KEY
422Missing required field (user_id)

List all keys belonging to a user. Never includes the plain-text key — only safe display fields.

[
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"prefix": "mcp_sk_3f8a1c2e9b4d7f6a_...9b",
"name": "Claude Desktop",
"user_id": "user_123",
"scopes": {"read": true, "write": false},
"is_active": true,
"created_at": "2026-04-16T10:00:00Z",
"last_used_at": "2026-04-16T14:32:11Z",
"expires_at": "2027-04-16T10:00:00Z"
}
]

Returns an empty array [] if the user has no keys. Results are ordered newest first.

FieldDescription
idUUID — use this to revoke
prefixSafe display string
is_activeAlways true for listed keys (inactive keys are deleted)
last_used_atUTC timestamp of last successful verify, or null if never used
expires_atUTC expiry timestamp, or null if no expiry
StatusDescription
401Missing or malformed Authorization header
403Wrong ADMIN_API_KEY

Permanently delete a key. Immediately stops future verifications. This is a hard delete — the key record is removed from the database.

No body. A 204 is returned whether the key existed or not.

StatusDescription
401Missing or malformed Authorization header
403Wrong ADMIN_API_KEY

Verify an incoming API key. This endpoint is not authenticated and optimized for high-frequency use — call it on every MCP request.

Always returns 200 OK. Check the valid field, not the HTTP status code.

{
"key": "mcp_sk_3f8a1c2e9b4d7f6a_4a7b2c9e..."
}
{
"valid": true,
"user_id": "user_123",
"scopes": {"read": true, "write": false},
"error": null
}
{
"valid": false,
"user_id": null,
"scopes": null,
"error": "Invalid API key"
}
errorCause
"Invalid key format"Key doesn’t start with KEY_PREFIX, or has wrong structure
"Invalid API key"Key not found in DB, or bcrypt check failed
"Key expired"Key exists but expires_at is in the past

Liveness check. Used by Kubernetes probes and load balancers.

{
"status": "ok",
"service": "mcpgate"
}

No authentication required.