OpenProgram Docs

MCP server

Tools

ToolPurposeCapabilityHost side effects
sessions_listList session ids, titles, update timesreplyNone
session_getRead the active branch of one sessionreplyNone
prompt_sendSend a prompt to an existing or new session and return the result; combines codex's codex and codex-replyreplySession append only
prompt_cancelCancel an active prompt this connection startedreplyNone
tools_listList Runtime tools exposed to this client, with schemasreplyNone
tool_callCall one exposed Runtime tool by nameDepends on the toolPasses the three gates below

Not offered: tool registration, configuration rewriting, credential access, direct file tools. File reads go through tool_call. Peers: codex two tools, openclaw nine, hermes ten; exposing every tool is excluded.

Three gates on every tool_call

Allowlist exposed_tools empty by default Tier paired capabilities never interactive Approval mode fixed to ask no one to approve Runs typed, sanitized result JSON-RPC error, as unknown tool isError, names the missing capability isError, fixed reason, no waiting
  1. Allowlistmcp_server.exposed_tools, empty by default

    JSON-RPC error, as unknown tool

  2. Tierpaired capabilities, never interactive

    isError, names the missing capability

  3. Approvalmode fixed to ask, no one to approve

    isError, fixed reason, no waiting

  4. Runstyped, sanitized result

Discovery and execution each compute allowlist ∩ live registry ∩ paired capability. Identity limits come first: for source=mcp, risky tools, process and worktree tools, and out-of-root writes are always denied, and no question waits for an answer.

Request sources

Request sourcePrincipalauthority_tierMissing field
Authenticated local Web, CLI, TUIprincipal_id=owner, interactiveowner, holds approval.requestEntry point must build it; invalid authentication is rejected
Paired channel accountInstance owner; speaker stored separatelypairedMessage without a tier is rejected, not downgraded
External MCP clientInstance owner; client id stored separately, speaker_kind=client, non-interactivepaired ∩ allowlistConnection rejected
Continuation, subagentExplicitly inherits ownerCaller's tier, never higherState error: deny
Cron triggerOwner approved at creationJob capability fixed at approvalNot recomputed as interactive

Tiers come from TIER_CAPABILITIES; missing or unknown tiers deny everything. Paired holds reply, memory.read, memory.source.append, runtime.wait. Full table: sandbox design.

Authentication and transport

AspectRule
Tokenopenprogram mcp token create atomically writes <state_dir>/mcp_server_token (0600) and prints it once. serve never generates one
Validationopenprogram mcp serve compares OPENPROGRAM_MCP_TOKEN with the file in constant time before reading any message. No disable switch
FailureNonzero exit, empty stdout, stderr fixed to Error: MCP server authentication failed
SecrecyThe token never enters JSON-RPC, logs, errors or session content
Client identityFirst 16 lowercase hex characters of the credential's SHA-256. initialize.clientInfo is neither read nor recorded
AuthorityFixed paired, never owner, and independent of the Web owner token
Transportstdio only. It inherits the trust boundary of the launching process
ProtocolLocked mcp 1.30.0, protocol 2025-11-25; the SDK negotiates versions with no custom handshake fields
Streamable HTTPLater and separate: needs OAuth, Origin validation and a deployment lifecycle

Cancellation, progress, errors

Protocol messageMaps to
notifications/cancelledLook up session and token by MCP request id; set the per-turn CancelToken and the tool's cancel event; stop effects; clear requests and questions; audit mcp.request.cancelled
notifications/progressThe tool's on_update, only when the client sent progressToken. Tool start and finish, monotonic per request; no token-level streaming
ConditionResponseReason
Unknown tool nameJSON-RPC error, method levelProtocol failure
Arguments fail the schemaJSON-RPC error, invalid paramsProtocol failure
Missing or wrong startup tokenNonzero exit before the MCP lifecycleAuthentication precedes stdin reads
Tool not allowlistedJSON-RPC error, as unknown toolReveals nothing about unauthorized tools
Tier lacks the capabilityisError: true, names the capabilityTool exists but is unavailable here
Approval denied or unavailableisError: true, fixed gate reasonNo owner present; no tool details passed through
Tool ran and failedisError: true, fixed sanitized body and reason codeNo exceptions, traces or tool-reported reasons cross the boundary
SDK cancels an in-flight requestErrorData(code=0, message="Request cancelled", data=None), no tool resultThe SDK owns the response and may send it first; the handler, in a shielded cancel scope, returns only after the turn is stopped, the request cleared and the audit written
prompt_cancelActive turn on the same connection: cancelled=true; foreign or finished: falseA wrapper, not the SDK notification

Internal Web surface

SurfaceLocationSize
FastAPI routescreate_app() in openprogram/interfaces/server/server.py, routes in routes/About 335 routes
WebSocket /ws_websocket_handler, actions in ws_actions/Unversioned actions and events
Tool registry_registry in openprogram/programs/_host/runtime.pyBy tool name; switches toolset, expose, defer

OwnerAuthMiddleware enforces Host and Origin, cookie or Bearer credentials, CSRF, no-store, and WebSocket authentication before accept, then grants full owner authority. That is neither an MCP client identity nor an external contract, so FastAPI and WebSocket are not MCP transports and clients never receive the Web owner token.

Permission decision and cancellation internals
PartRule
Permission orderpermission_decision: identity limits, then owner rules (deny, plan's read-only limit, ask, outbound hold, allow), then the mode. Default mode bypass; subagents take the parent's mode. See permission decision
Tool wrappingwrap_with_approval returns a tool copy whose execute is gated. External callers cannot bypass it
CancelTokenPer turn, never per session (runtime/execution/run_control/tokens.py). A stop arriving after a turn ends cannot affect the next
Global hooksadd_pre_invocation_hook, set_cancellation_check: each Agent method entry and each Runtime.exec aborts
Unified entryTakes only the canonical execution_id, persists intent, wakes the owner and pending questions. ACP, MCP, Channels and Web share one Control Service
is_errorFirst-class on AgentToolResult and AgentEventToolEnd; read by Runtime, approval, the agent loop, MCP conversion and cache eligibility. details holds diagnostics such as reason_code, denied, timeout. details["is_error"] is an input bridge only
Framework comparison
FrameworkMCP serverACP agent sideInbound HTTP, webhookClient SDK
claude-codeclaude mcp serveNoneNone documentedAgent SDK
codex-clicodex mcp-server, stdio, only codex and codex-replyNone; own app-serverapp-server: stdio, WS, unix; token file, SHA-256, JWTTS @openai/codex-sdk, Python
openclawThree stdio servers, MCP-over-HTTP (bearer, loopback)openclaw acp, through GatewayGateway HTTP API, HMAC webhook plugin@openclaw/sdk (private)
opencodeNone, client onlyopencode acpopencode serve, HTTP Basic; only warns without a password@opencode-ai/sdk, from OpenAPI
hermes-agenthermes mcp serve, FastMCP stdio, ten toolshermes acp, ACP registry entriesHMAC webhook adapter, bearer OpenAI-compatible APINone
pi-aiNoneNoneNoneNot applicable: a provider library
pi-monoNone; README says "No MCP."NoneNone; in-process pi.send()Embedding package only
weclawNoneACP client only, auto-approves everythingPOST /api/send, no authenticationNone
OpenProgramopenprogram mcp serve, authenticated stdio, fixed wrappers, empty allowlistopenprogram acp, stdioInternal Web routes, owner authenticationNone; standard MCP SDK

Protocol approaches

TopicPeers
Push approvalcodex: elicitation/create for exec and patch, custom fields threadId, codex_elicitation, codex_mcp_tool_call_id, codex_event_id, returning ReviewDecision. Low latency, needs client elicitation; its payload lacks ElicitResult action and content
Pull approvalopenclaw, hermes: permissions_list_open and permissions_respond, allow-once, allow-always, deny. Works with generic clients, at a round trip and polling cost. openclaw also pushes through claude/channel/permission
Cancellationcodex looks up the turn in its active-turn registry, and tasks/cancel reports unsupported. openclaw passes extra.signal into callTool. hermes has none
Progresscodex only logs notifications/progress. No surveyed framework emits standard progress
ErrorsAll return {isError: true, content:[text]} for tool failure and JSON-RPC errors for protocol failure. OpenProgram adopts this
Excludedweclaw's unauthenticated send and unconditional session/request_permission approval; opencode's unauthenticated serve when OPENCODE_SERVER_PASSWORD is unset

Out of scope

ItemStateWhy
ACP stdio serverExists, not expanded: openprogram acp, openprogram/interfaces/acp/server.pyOwner authority and interactive permission; MCP tokens, allowlists and tools do not merge into it
Inbound webhookNot builtNo owner is present on arrival, so it needs a job capability fixed at registration, as cron does. Minimum controls, from hermes: per-route HMAC secrets validated at startup, rate limits, idempotency cache, body-size checks before reading
Client SDKNot builtThe standard MCP SDK is the client library. A dedicated SDK needs real integrations that prove these tools too coarse; only two routes have fixed shape assertions
HTTP, SSE, OAuth, Web routes, wider SDK rangeNot builtThe external surface stays authenticated stdio and these tools
Tests
FileCovers
tests/integration/programs/test_mcp_server.pyReal ClientSession over a real openprogram mcp serve subprocess; handwritten frames only supplement raw stdout checks. Token failures before the handshake; clientInfo invariance; the fixed tool list; tools_list equal to the intersection; unknown and unexposed tools; isError rather than hanging; SDK cancellation with no later result, stopped effects, cleared state and audit; progress only with a token and in order; bounded consumer teardown that keeps parent cancellation; concurrency; protocol-only stdout
tests/component/webui/runtime/test_diagnostic_mcp_route_contracts.pyExact shapes of /api/doctor (results, all_ok), /api/mcp/servers (15 keys) and the 404 for a missing server, on a bare FastAPI() with no middleware
Last updated · 2026-11-25