McpClient

Overview

The MCP client itself, exported from the package. Use it for a server you hold yourself — api.mcp is the same client plus the account's record of it.

exportedhttpsstateless
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

import { McpClient } from "iagenify";

const client = new McpClient({ url: "https://mcp.example.com/sse", token, name: "example" });

await client.initialize();
const tools = await client.listTools();
const result = await client.call("search_docs", { query: "retry policy" });
from iagenify import McpClient

client = McpClient("https://mcp.example.com/sse", token=token, name="example")

client.initialize()
tools = client.list_tools()
result = client.call("search_docs", {"query": "retry policy"})
client.close()
urlstringrequired

The server's address.

tokenstring|nullnull

Cleaned on the way in — surrounding spaces, quotes and a copied « Bearer » are removed.

namestring"mcp"

Used to prefix tool names and in the header the specification asks for.

fetchImplfunction

A fetch of your own, for a runtime that needs it.

The methods

CallDoes
initialize()Shakes hands and agrees a revision.
listTools()Every tool, paginated.
call(name, args)Runs one.

And the pure helpers

ExportDoes
sanitizeSchema()A tool schema reduced to what providers accept.
toolNameFor()The prefixed, trimmed tool name.
createMcpTools()Servers into engine-shaped tools.
MCP_PROTOCOL_VERSIONThe revision this client prefers.

It knows nothing about the account

No address check, no token storage, no allowed list

Those belong to api.mcp. Holding the client directly means the address is yours to vet — which is fine for a server you wrote, and a bad idea for one a user typed.

Nothing to close

The revision this client prefers made the protocol core stateless: a call is an ordinary request and response. There is no connection to keep open and nothing to resume after a restart.