Ops MCP: ask the gateway from your IDE

Last updated:

On this page

The gateway ships with a built-in, read-only MCP server at /v1/mcp. It lets an AI assistant in your IDE read the gateway's operational state and answer questions like "why did p95 go up yesterday?", "which model is used most this week?" or "how many errors per class did we have in the last 24 hours?". No SSH and no hand-written calls against the admin API.

Who it is for

The ops MCP is built for on-prem and self-hosted installations of the staik gateway, where your own operators want to connect Claude Code, Cursor or GitHub Copilot to their gateway. It is included in every installation.

The ops MCP shows operations data for the whole installation, not just for its own user. Only give the analyst role to the people who operate the installation, never to individual users or teams on a gateway shared by several of them.

staik Cloud

The ops MCP is not available to customers on staik Cloud (api.staik.se), because it shows operations data for the whole installation, not per customer. It is only used internally by staik's operations.

Access: the analyst role

The MCP requires an API key with an operations role, set through the account's account_tag:

RoleTag (default)/v1/mcp/v1/admin/*
Analystanalyst (ANALYST_ACCOUNT_TAGS)Yes, read-onlyNo (403)
Adminadmin (ADMIN_ACCOUNT_TAGS)Yes, read-onlyYes
Regular usernoneNo (403)No (403)

The analyst role is read-only: it reaches the MCP and no admin endpoints, neither reading nor writing. A missing or invalid key gets 401.

Create an analyst key

On an on-prem installation, create the key with staik-admin in the gateway container:

bash
docker compose exec gateway staik-admin create-key --analyst --email bi@onprem.local

The key (sk-st-...) is printed once. Store it in a password manager or as an environment variable. The examples below read it from STAIK_OPS_KEY:

bash
export STAIK_OPS_KEY=sk-st-your-analyst-key

One key per person

Create a separate analyst key for each person or assistant. You can then revoke one key without affecting anyone else, and the rate limit applies per key.

Where the data goes

Tool results go to the IDE's model

The MCP server sends its results to whichever model your IDE uses. If the IDE runs against an external model (for example a cloud service outside your installation), the operations data leaves the installation. The results are aggregates without prompt text, email addresses or keys, but they still describe your operations: volumes, models, errors and latency. Point the IDE at your own model if the data should stay with you. How to point Claude Code at a staik gateway (with ANTHROPIC_BASE_URL) is covered in the Claude Code guide.

Connect your IDE

The MCP uses the Streamable HTTP transport and authenticates with an Authorization: Bearer header. Replace https://your-gateway with your gateway's address. Use an environment variable for the key instead of writing it into the config file, especially if the file is committed.

bash
# Add the server (scope "project" writes .mcp.json in the repo)
claude mcp add --transport http --scope project staik-ops https://your-gateway/v1/mcp \
  --header 'Authorization: Bearer ${STAIK_OPS_KEY}'

# Or write .mcp.json yourself:
# {
#   "mcpServers": {
#     "staik-ops": {
#       "type": "http",
#       "url": "https://your-gateway/v1/mcp",
#       "headers": { "Authorization": "Bearer ${STAIK_OPS_KEY}" }
#     }
#   }
# }

# Check the connection
claude mcp list

Per client:

  • Claude Code expands ${STAIK_OPS_KEY} in .mcp.json when the server starts. With single quotes around the header in claude mcp add, the reference, not the key, ends up in the file.
  • Cursor reads .cursor/mcp.json in the project, or ~/.cursor/mcp.json for all projects, and uses the ${env:NAME} syntax. Remote servers do not support envFile, so the variable must be set in the environment Cursor is started from.
  • GitHub Copilot in VS Code reads .vscode/mcp.json in the workspace, with servers as the top-level key and ${env:NAME} for environment variables. Newer versions of VS Code also read a .mcp.json in the workspace root in the same format as Claude Code (mcpServers and ${NAME}). Start the server from the MCP view and use it in agent mode.

Tools

All tools are read-only (readOnlyHint: true), return aggregates and use UTC. Results come both as structured data and as JSON text.

ToolArgumentsWhat it answers
get_healthnoneThe state right now: status, database pool, per backend circuit breaker, error rate and p95, node liveness, queues and prompt cache
get_error_summaryhours 1 to 168 (24)Errors per HTTP status and reason, overall error rate
get_latency_p95_historyhours 1 to 168 (24)p95 latency per backend and hour, with circuit state
get_gpu_throughputhours 1 to 168 (24)Decode throughput (completion tokens per second) per GPU group in 15-minute buckets, plus the peak over the last 7 days
get_routing_overviewdays 1 to 30 (7)Routing decisions: how many requests a smaller model could have handled, share with images, tools and cache hits, reasons, latency per model and requests per client program (product name from the User-Agent)
get_usagehours 1 to 720 (24), group_by model, endpoint or node, bucket none, hour (max 168 hours) or dayRequests, tokens, cache hits, average and p95 duration and number of distinct users per group, optionally as a time series
get_model_catalognoneActive models with context window and capabilities, plus ongoing maintenance windows

Example questions

  • "Are all backends healthy right now? If not, which circuit breaker is open?" (get_health)
  • "Why did p95 go up yesterday afternoon? Compare the backends hour by hour." (get_latency_p95_history)
  • "Which model uses the most tokens this week, and how much of it comes from cache?" (get_usage with group_by: model, hours: 168)
  • "How many 429s and 504s did we have in the last 24 hours, and why?" (get_error_summary)
  • "How many requests could a smaller model have handled last week?" (get_routing_overview)

Data protection

By default the tools only return aggregates per model, endpoint, node and time window. The following never leaves the gateway through the MCP: prompt and response text, email addresses, API keys and key prefixes, customer ids, request ids, IP hashes, internal backend and node addresses, and database errors.

If you want per-user detail, enable MCP_ALLOW_PER_USER. get_usage and get_error_summary then include a list of the most active users, but only as a stable pseudonym (user- followed by an HMAC of the customer id). The pseudonym requires a secret salt in MCP_PSEUDONYM_SALT. With an empty salt only aggregates are returned and the gateway logs an error.

Settings

Set as environment variables on the gateway.

VariableDefaultDescription
ANALYST_ACCOUNT_TAGSanalystComma-separated tags that grant the analyst role. create-key --analyst sets the first one
ADMIN_ACCOUNT_TAGSadminTags that grant the admin role, which also reaches the MCP
MCP_ALLOW_PER_USERfalsePer-user rows in the results, always pseudonymised
MCP_PSEUDONYM_SALTemptySecret salt for the pseudonyms. Required for per-user rows. Changing the salt changes every pseudonym
MCP_RATE_LIMIT_PER_MINUTE60Max requests per minute and key. Above the limit you get 429 with Retry-After. 0 disables it
CORS_ALLOWED_ORIGINSemptyAllowed web origins. A request with an unknown Origin gets 403. IDEs send no Origin

Protocol

  • POST /v1/mcp with JSON-RPC 2.0: initialize, ping, tools/list and tools/call. Responses are application/json.
  • The server is stateless: no session and no SSE stream. GET and DELETE return 405.
  • Protocol versions: 2024-11-05, 2025-03-26, 2025-06-18 and 2025-11-25.
  • Invalid arguments give a tool result with isError: true and an explanation, so the model can correct the call.

Test the connection without an IDE:

bash
curl -s https://your-gateway/v1/mcp \
  -H "Authorization: Bearer $STAIK_OPS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}'