Skip to main content

Module mcp_client

Module mcp_client 

Source
Expand description

The MCP engine client (spec/sync/README.md §6; the reference’s McpEngineClient in @omgbase/sync): reaches “the omgbase side” over the Model Context Protocol, so the Coordinator runs unchanged against a remote engine, and the CLI’s --server mode calls any catalog tool (spec/surface §4) and renders the result it would have computed locally.

Two transports, one JSON-RPC 2.0 client on top:

  • stdio — spawn a command (omg mcp -C /vault, omgbase mcp …) and speak newline-delimited JSON-RPC over its stdin/stdout (the framing of omgbase mcp and of the SDK’s StdioServerTransport); stderr is inherited.
  • Streamable HTTP (feature http) — POST each message to the URL with Accept: application/json, text/event-stream, read the reply from a JSON body or an SSE stream, round-trip Mcp-Session-Id, and send MCP-Protocol-Version once negotiated; extra headers ride on every request (auth beyond a secret path); DELETE ends the session.

The one rule for a --server value lives in parse_engine_spec: an http(s):// value is an HTTP endpoint (used verbatim, base path and all), anything else is whitespace-split and spawned — a URL is never spawned. Synchronous like the rest of the crate: one request in flight, a bounded wait per reply.

Structs§

McpEngineClient
A connected MCP client: initialize done, ready for tools/call.
ToolResult
One tools/call outcome: the JSON the tool’s text content held, and whether the server flagged it (isError; the body is then the error envelope of spec/surface §4 — { error, message, data?, retriable }).

Enums§

EngineSpec
Where a --server value points.

Constants§

CLIENT_NAME
clientInfo.name (the reference’s).
DEFAULT_TIMEOUT
How long one request may wait for its reply (the SDK’s default request timeout).
PROTOCOL_VERSION
The MCP protocol revision this client proposes in initialize (the server may answer with the one it speaks; the reply is what is sent as MCP-Protocol-Version afterwards).

Functions§

is_http_url
Whether s starts with http:// or https:// (case-insensitive).
parse_engine_spec
Classify a raw --server value (the reference’s parseEngineSpec): an http(s):// value is an HTTP endpoint (verbatim; headers ride along); anything else is split on whitespace and spawned. Errors: an empty value, or headers for a command (they have nowhere to go).