api.mcp

Overview

MCP servers the account has connected: an address, a token and a list of allowed tools. Agents use them, and so can your own model loop.

8 methodshttps onlyexec by default
Using Python?

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

A connection belongs to the account, not to an agent: it is an address, a credential and a decision about which of its tools may be used. An agent then says which servers it wants, and api.mcp.tools() hands the same declarations to anyone writing their own loop.

The surface

CallDoes
connect(options)Checks the address, shakes hands, lists its tools, saves the connection.
list()Every connected server, without tokens.
get(name, { refresh })One, with its tools. refresh re-reads them from the server.
update(name, changes)Allowed tools, category, token, label, address.
call(name, tool, args)Runs one tool, without an agent.
disconnect(name)Removes the connection.
tools(names)Declarations for models.turn({ tools }).
forAgent(names)Servers ready for the engine, tokens included.
await api.mcp.connect({
  url: "https://mcp.example.com/sse",
  name: "example",
  token: process.env.EXAMPLE_TOKEN,
  tools: ["search_docs", "get_issue"],      // nothing is allowed without this
  category: "read",
});

const agent = api.agents.create({
  runtime: "local", machine: pc, model: "gemini-3.5-flash",
  mcp: ["example"],
});
import os

api.mcp.connect(
    url="https://mcp.example.com/sse",
    name="example",
    token=os.environ["EXAMPLE_TOKEN"],
    tools=["search_docs", "get_issue"],      # nothing is allowed without this
    category="read",
)

agent = api.agents.create(
    runtime="local", machine=pc, model="gemini-3.5-flash",
    mcp=["example"],
)

The client lives in the package

Why not a provider's own MCP feature

A provider that runs the tool round trips inside its turn gives no exact pre-authorisation, no permission asked per call, and no budget that bites. Here an MCP tool is one more declaration — so it works on every provider, and it needed no route of ours to execute.

Five things that are deliberate

WhyPage
exec by defaultThe protocol's read-only hint is declared by the server itself — not proof.connect()
No tool allowed unless listedEach declaration costs tokens on every turn.Allowed tools
Schemas are sanitisedA raw schema can fail the whole turn, not just that tool.sanitizeSchema()
The address is checked firstBefore the package ever contacts it.Address check
The token is encrypted at restAnd returned only to its owner.Tokens

One transport

Streamable HTTP over https. The revision this client speaks made the protocol core stateless, so a call is an ordinary request and response — nothing to hold open, nothing to resume when the process carrying the package restarts.