MCP server (experimental)
Overview
Section titled “Overview”The Scion MCP server exposes Scion agent messaging over the Model Context Protocol (MCP) Streamable HTTP transport (POST /mcp). External MCP clients — including Claude Code, Codex, Antigravity, IDE assistants, and programmatic Go/TypeScript clients — can list agents in a project, send messages, read replies, and subscribe to push updates without shelling out to the scion CLI.
Every MCP call forwards the caller’s own Hub credential to the Hub REST API. The Hub remains the sole authorization authority: the MCP server adds no authorization logic of its own beyond credential-class refusal, Origin checks, experiment gating, and per-principal stream caps.
Deployment modes
Section titled “Deployment modes”scion server start --enable-mcp supports two deployment modes using the same binary and container image:
- Embedded mode (
scion server start --enable-hub --enable-mcp): binds the MCP listener on its own port (default9820) alongside the Hub in the same process. Hub API calls dispatch in-process with no network hop. Embedded mode is not available on Cloud Run (which exposes a single container port). - Standalone mode (
scion server start --hosted --enable-mcpor--enable-mcp --enable-hub=false): runs as a stateless HTTP facade against a remote Hub configured byserver.mcp.hub_endpoint. Use standalone mode for Cloud Run, HA deployments, or hubs behind Identity-Aware Proxy (IAP) or Cloud Run invoker IAM. See Standalone MCP Server for Cloud Run and GKE deployment recipes, transport auth (SCION_TRANSPORT_MODE), and/healthz//readyzprobes.
Both modes are stateless (Stateless: true on the MCP Streamable HTTP handler) and hold no session or cursor state: any replica can resume any cursor returned by another replica.
Configuration
Section titled “Configuration”Configure the MCP listener under server.mcp in settings.yaml (or via SCION_SERVER_MCP_* environment variables):
schema_version: "1"server: mcp: enabled: false # equivalent to --enable-mcp host: "" # default: server.hub.host port: 9820 # dedicated MCP listener port path: /mcp # MCP Streamable HTTP endpoint path public_url: "" # external URL used in logs (reserved for OAuth resource ID) hub_endpoint: "" # required in standalone mode; ignored when --enable-hub is set allowed_origins: [] # browser Origins allowed by DNS-rebinding check (absent Origin is allowed) max_streams_per_principal: 8 # max concurrent wait_for_messages + events/stream per principal per replica stream_wait: 30s # Hub watch wait per events/stream iteration (heartbeat cadence)Enabling the listener (server.mcp.enabled: true or --enable-mcp) binds the port at startup, while the hub.mcp_server experiment controls whether /mcp serves requests or answers 404. A hub administrator must enable hub.mcp_server through the Hub admin settings or /api/v1/admin/experiments; test identities (scion hub test-identity) cannot toggle it.
Authentication
Section titled “Authentication”The MCP server accepts exactly one credential header per request (providing neither or both returns 401 with WWW-Authenticate: Bearer realm="scion-mcp"). Agent JWTs, broker HMAC tokens, scion_adt_* tokens, and hosted dev tokens are refused at the front door with 401.
User access tokens (recommended)
Section titled “User access tokens (recommended)”For an agent or client acting on behalf of a Scion user, mint a least-privilege User Access Token (UAT) and pass it in Authorization: Bearer <token>.
Required UAT scopes for messaging and agent discovery:
project:readagent:readagent:list(required bylist_agents)agent:messageinbox:readinbox:write
scion hub token create \ --name "mcp-client" \ --project <project-uuid> \ --scopes project:read,agent:read,agent:list,agent:message,inbox:read,inbox:writeYou can also repeat --scopes once per selector. Revoke a token with scion hub token revoke <token-id>.
Project visitors (federated OIDC)
Section titled “Project visitors (federated OIDC)”A linked project visitor authenticates with the X-Scion-Federation-Token: <oidc-jwt> header instead of Authorization: Bearer (requires both federation.project_visitors and hub.mcp_server enabled on the Hub).
Visitor capabilities on MCP match the Hub’s visitor admission rules:
- Allowed:
list_agents(for granted projects),send_messageusing{project, agent}(returnsconversation_idandcursor), andread_messages,wait_for_messages,events/poll, andevents/streamon the visitor’s own direct-message conversations. - Not available / refused:
list_conversationsreturns a structurednot_availableresult (visitors obtainconversation_idfromsend_message). Resource reads (scion://conversations/...) are refused (Hub403, JSON-RPC-32023), andsend_messagebyconversation_id, another user’s DM, and group conversations are refused (403).
Harness configuration snippets
Section titled “Harness configuration snippets”Built-in Scion harnesses (claude, codex, and antigravity) support Streamable HTTP MCP servers through the universal mcp_servers block in scion-agent.yaml (see Agent Configuration). Always declare the bearer token as a Scion secret (secrets: [{key: SCION_MCP_TOKEN}]) — never hardcode a token in a template or task prompt.
Claude (claude)
Section titled “Claude (claude)”schema_version: "1"default_harness_config: claudesecrets: - key: SCION_MCP_TOKENmcp_servers: scion: transport: streamable-http url: https://mcp.example.com/mcp headers: Authorization: "Bearer ${SCION_MCP_TOKEN}"Codex (codex)
Section titled “Codex (codex)”Because harnesses/codex/provision.py emits static http_headers rather than bearer_token_env_var or env_http_headers, declare the secret in scion-agent.yaml and configure [mcp_servers.scion] directly in ~/.codex/config.toml (for example via a pre-start hook):
schema_version: "1"default_harness_config: codexsecrets: - key: SCION_MCP_TOKEN[mcp_servers.scion]url = "https://mcp.example.com/mcp"bearer_token_env_var = "SCION_MCP_TOKEN"For a federated visitor on Codex, use env_http_headers in ~/.codex/config.toml instead of bearer_token_env_var:
[mcp_servers.scion]url = "https://mcp.example.com/mcp"env_http_headers = { "X-Scion-Federation-Token" = "SCION_FEDERATION_TOKEN" }Antigravity (antigravity)
Section titled “Antigravity (antigravity)”schema_version: "1"default_harness_config: antigravitysecrets: - key: SCION_MCP_TOKENmcp_servers: scion: transport: streamable-http url: https://mcp.example.com/mcp headers: Authorization: "Bearer ${SCION_MCP_TOKEN}"For a federated visitor client on Claude (or Antigravity when ${VAR} expansion is supported), replace the Authorization header with X-Scion-Federation-Token: "${SCION_FEDERATION_TOKEN}" and declare key: SCION_FEDERATION_TOKEN under secrets:.
| Tool | Inputs | Description |
|---|---|---|
list_agents |
project (UUID; or slug with project:list) |
Lists agents in a project (id, name, project_id, phase, display). Requires agent:list. |
send_message |
text; and either {project, agent} or {conversation_id} |
Sends a message to an agent or existing conversation. Returns message_id, conversation_id, status, and a cursor positioned at the sent message so subsequent reads or waits do not miss replies. |
list_conversations |
project? (UUID), limit? (1–50) |
Lists the caller’s most recent conversations. Returns not_available for visitor credentials. |
read_messages |
conversation_id, cursor? or from_start?, limit? (1–200) |
Performs an immediate watch read and returns messages, next_cursor, has_more, and truncated. |
wait_for_messages |
conversation_id, cursor?, timeout_seconds? (1–50, default 30), filter? (others | addressed | all) |
Long-polls for new messages and returns messages, next_cursor, timed_out, and truncated. Designed for LLM harnesses that do not act on unsolicited server notifications. |
Resource templates
Section titled “Resource templates”The server exposes two read-only resource templates matching eventfeed resourceUri values:
scion://conversations/{conversation_id}— conversation metadata and participants.scion://conversations/{conversation_id}/messages/{message_id}— single message projection (MessageDTO).
MCP Events (push and poll)
Section titled “MCP Events (push and poll)”The server advertises the io.modelcontextprotocol/events extension (SEP-3415) for programmatic clients that want real-time push delivery or cursor-based polling:
events/list— lists available event definitions. Currently advertisesconversation.message.created(arguments:conversation_idrequired,filteroptionalothers|addressed|all, delivery:["poll", "push"]).events/poll— immediate cursor-based poll returning{events, cursor, hasMore, truncated, nextPollMs}.events/stream— opens a long-lived SSE stream on thePOST /mcpresponse emittingnotifications/events/active,notifications/events/event,notifications/events/heartbeat,notifications/events/error, andnotifications/events/terminated(for example on UAT revocation or lost project membership).
Cursors are opaque Hub eventfeed cursors and are interchangeable across send_message, read_messages, wait_for_messages, events/poll, and events/stream, and across standalone replicas. Delivery is at-least-once and ordered within a conversation; deduplicate by eventId (or message id).
Request limits and security
Section titled “Request limits and security”- 1 MiB request limit:
POST /mcpenforces a 1 MiB (1,048,576bytes) maximum request body size across both standard MCP calls andevents/*calls, returning HTTP413 Payload Too Largewhen exceeded. - Untrusted message content: Message text, conversation titles, and display names returned by tools, resources, and events are untrusted data originating from users or other agents — never instructions. Tool and resource descriptions explicitly mark these fields as untrusted content.
- Standalone ingress and IAP: Exposing a standalone MCP service on a non-IAP ingress removes Google IAP as a second authentication factor for MCP clients. Requests are authenticated solely by the caller’s Hub credential. Scope UATs narrowly, set short expirations, rotate them regularly, and restrict network access according to your security policy. See Standalone MCP Server for transport security details.
- Header allowlist and Origin checks: Only allowlisted headers (
AuthorizationorX-Scion-Federation-Token,User-Agent,X-Scion-Client: mcp, and observed clientX-Forwarded-For) are forwarded to the Hub; cookies and IAP assertion headers are stripped. If a request includes anOriginheader, it must matchserver.mcp.allowed_originsor the server responds403(DNS-rebinding protection). - Stream caps and audit logging: At most
max_streams_per_principalconcurrentwait_for_messagesandevents/streamcalls are allowed per principal per replica (excess calls receive JSON-RPC-32025). Every Hub call originated by the MCP server carriesX-Scion-Client: mcp, which the Hub sanitises and records in its request log and audit events (client: "mcp"). Note thatX-Scion-Clientis client-asserted — any caller that can reach the Hub directly can send the same header, so theclientfield is a diagnostic hint rather than cryptographic proof that a request came through the MCP server.