Skip to content

MCP server (experimental)

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.

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 (default 9820) 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-mcp or --enable-mcp --enable-hub=false): runs as a stateless HTTP facade against a remote Hub configured by server.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//readyz probes.

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.

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.

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.

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:read
  • agent:read
  • agent:list (required by list_agents)
  • agent:message
  • inbox:read
  • inbox:write
Terminal window
scion hub token create \
--name "mcp-client" \
--project <project-uuid> \
--scopes project:read,agent:read,agent:list,agent:message,inbox:read,inbox:write

You can also repeat --scopes once per selector. Revoke a token with scion hub token revoke <token-id>.

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_message using {project, agent} (returns conversation_id and cursor), and read_messages, wait_for_messages, events/poll, and events/stream on the visitor’s own direct-message conversations.
  • Not available / refused: list_conversations returns a structured not_available result (visitors obtain conversation_id from send_message). Resource reads (scion://conversations/...) are refused (Hub 403, JSON-RPC -32023), and send_message by conversation_id, another user’s DM, and group conversations are refused (403).

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.

schema_version: "1"
default_harness_config: claude
secrets:
- key: SCION_MCP_TOKEN
mcp_servers:
scion:
transport: streamable-http
url: https://mcp.example.com/mcp
headers:
Authorization: "Bearer ${SCION_MCP_TOKEN}"

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: codex
secrets:
- key: SCION_MCP_TOKEN
~/.codex/config.toml
[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" }
schema_version: "1"
default_harness_config: antigravity
secrets:
- key: SCION_MCP_TOKEN
mcp_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.

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).

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 advertises conversation.message.created (arguments: conversation_id required, filter optional others | 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 the POST /mcp response emitting notifications/events/active, notifications/events/event, notifications/events/heartbeat, notifications/events/error, and notifications/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).

  • 1 MiB request limit: POST /mcp enforces a 1 MiB (1,048,576 bytes) maximum request body size across both standard MCP calls and events/* calls, returning HTTP 413 Payload Too Large when 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 (Authorization or X-Scion-Federation-Token, User-Agent, X-Scion-Client: mcp, and observed client X-Forwarded-For) are forwarded to the Hub; cookies and IAP assertion headers are stripped. If a request includes an Origin header, it must match server.mcp.allowed_origins or the server responds 403 (DNS-rebinding protection).
  • Stream caps and audit logging: At most max_streams_per_principal concurrent wait_for_messages and events/stream calls are allowed per principal per replica (excess calls receive JSON-RPC -32025). Every Hub call originated by the MCP server carries X-Scion-Client: mcp, which the Hub sanitises and records in its request log and audit events (client: "mcp"). Note that X-Scion-Client is client-asserted — any caller that can reach the Hub directly can send the same header, so the client field is a diagnostic hint rather than cryptographic proof that a request came through the MCP server.