Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Effectful-Tech/clanka/llms.txt
Use this file to discover all available pages before exploring further.
McpClient is an Effect service that wraps the @modelcontextprotocol/sdk client. It manages the connection lifecycle automatically — the underlying MCP Client is acquired when the layer is built and released (via client.close()) when the scope closes — so callers only need to call connect then toolCall.
McpClient service
connect(options)
Open a Streamable HTTP transport to the given MCP server URL. Must be called before any toolCall.
The full HTTP or HTTPS URL of the MCP server endpoint, e.g.
"https://tools.example.com/mcp". Internally passed to StreamableHTTPClientTransport from @modelcontextprotocol/sdk.Resolves to
void on success. Fails with McpClientError if the connection handshake fails.toolCall(options)
Invoke a named tool on the connected MCP server.
The tool name as registered on the MCP server.
A plain object of arguments forwarded verbatim to the server tool.
Resolves to the tool’s response. Returns
response.structuredContent when present, otherwise response.content. Fails with McpClientError if the server returns an error or the transport fails.McpClient.layer
The standard Layer constructor. Provide this layer wherever McpClient is required.
Effect.acquireRelease to guarantee the MCP Client instance is always closed, even if the program fails or is interrupted.
Because
layer uses acquireRelease, it must be provided inside a Scope. Use Effect.scoped or Layer.toRuntime to supply one.McpClientError
The raw underlying exception thrown by the MCP SDK or the transport layer, captured as an Effect
Defect.McpClientError is a tagged Schema error class, so it can be matched with Effect.catchTag("McpClientError", ...) and serialised/deserialised via Effect Schema.
Full example: connect then call a tool
Wrapping McpClient calls as AgentTool
You can expose MCP tools to a Clanka agent by wrapping toolCall inside an AgentTool definition. The agent’s JS sandbox receives the tool and can call it directly.
Transport
McpClient uses StreamableHTTPClientTransport from @modelcontextprotocol/sdk/client/streamableHttp.js. This transport supports MCP’s streaming HTTP protocol and passes an AbortSignal through from Effect’s interruption model, so cancelling an Effect fiber will abort the in-flight HTTP request.