CX · Reference guidemcp
PlaygroundDownloadsAboutv0.17.0

mcp

A minimal MCP (Model Context Protocol) client (EXPERIMENTAL x/ tier, #6 S9). MCP is JSON-RPC 2.0 over a transport; this client composes the landed substrate — cx-stdlib/jsonrpc (message model), cx-stdlib/jsonschema (validates tool inputs), the real cx-stdlib/http client (Streamable-HTTP transport), and cx-stdlib/json — with no new transport and no V backing. Pure request builders (initialize/list-tools/call-tool) + response extractors (tools-of, result-text) + validate-args are split from the effectful transport (rpc-call, list-tools, call-tool). A remote tool composes as a cx-x/run Runnable via the call-site closure idiom. stdio transport + the initialize-handshake session state are later increments.

Experimental x/ tier — imported as cx-x/mcp. Bundled and gated in-tree like any other module, but EXEMPT from the frozen-surface stability promise (std-lib README, decision D3): a semver-breaking change is allowed here while the surface settles, and the frozen-surface canary never counts it. Pin behaviour you depend on with your own fixtures.

mcp:initialize-request

[$mcp:initialize-request] -> map — Build the MCP initialize JSON-RPC request (the session handshake).

mcp:list-tools-request

[$mcp:list-tools-request] -> map — Build the MCP tools/list JSON-RPC request.

mcp:call-tool-request

[$mcp:call-tool-request] -> map — Build the MCP tools/call JSON-RPC request for a tool name + arguments object.

mcp:tools-of

[$mcp:tools-of] -> any — Extract the tools array from a tools/list response value.

mcp:result-text

[$mcp:result-text] -> string — Extract the first text content block from a tools/call response value.

mcp:validate-args

[$mcp:validate-args] -> element — Validate an arguments object against a tool's JSON-Schema inputSchema ([ok]/[invalid …]). Call before call-tool.

mcp:rpc-call

[$mcp:rpc-call] -> any — POST one JSON-RPC request to the MCP endpoint (Streamable HTTP) and return the parsed reply.

mcp:list-tools

[$mcp:list-tools] -> any — Fetch the MCP server's tool list (net).

mcp:call-tool

[$mcp:call-tool] -> string — Invoke a remote MCP tool (net) and return its first text result. Compose as a cx-x/run Runnable via a call-site closure.