Mcp

AI

Stdio MCP client for an external MCP server.

Use Port for raw CLI tools (line/packet/stream bytes). Use Mcp when the child speaks MCP JSON-RPC over stdio (newline-delimited framing). Use Mcp.Server when this process is the MCP server. Use Acp for newline-delimited Agent Client Protocol (e.g. agent acp, acp-bridge). Inside Server.application, connect from init and drive call from update; HTTP handle should reach the core with Process.call / Process.send, never call Mcp directly.

Types

Event

type Event
= Ready
| Notification String Value
| Closed String

Lifecycle and async traffic from the MCP session.

Examples

Mcp.Ready

Values

connect

connect : String -> List Setting -> Cmd msg

Spawn the MCP server process. Forces binary+stream; pass Port.args, Port.env, and Port.cd as needed.

Examples

Mcp.connect "npx" [ Port.args [ "-y", "some-mcp-server" ] ]

call

call : String -> Value -> (Result String Value -> msg) -> Cmd msg

JSON-RPC request. The reply is tagged into msg.

Examples

Mcp.call "tools/list" JE.null GotTools

notify

notify : String -> Value -> Cmd msg

JSON-RPC notification (no reply).

Examples

Mcp.notify "notifications/initialized" JE.null

subscribe

subscribe : (Event -> msg) -> Sub msg

Deliver Event values into the running program.

Examples

Mcp.subscribe GotMcp