api.mcp

forAgent()

api.mcp.forAgent(names?) → Promise<Server[]>

Servers ready for the engine: allowed tools and tokens. This is what agents.create({ mcp }) reads — you rarely call it yourself.

tokens includednull means all[] means none
Using Python?

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

await api.mcp.forAgent();            // every connected server
await api.mcp.forAgent(["example"]); // these
await api.mcp.forAgent([]);          // none — and no request is made
api.mcp.for_agent()              # every connected server
api.mcp.for_agent(["example"])   # these
api.mcp.for_agent([])            # none — and no request is made

null and [] are different, and both are useful

PassedMeans
null or nothingEvery connected server
["a", "b"]Those two
[]None. It returns immediately without asking.
« All connected » stays bounded

Only allowed tools come out, so taking every server is not the open door it sounds like. A server with nothing allowed contributes nothing.

It carries tokens

The engine needs them to contact each server, so this is the one listing that includes them. They are decrypted for the authenticated owner and for nobody else — do not log what this returns.

The agent reads it for you

api.agents.create({ runtime: "local", machine: pc, model, mcp: ["example"] });
// mcp absent  → every connected server
// mcp: []     → none
api.agents.create(runtime="local", machine=pc, model=model, mcp=["example"])
# mcp absent → every connected server
# mcp=[]     → none

It is re-read at the start of every run, so a server connected from another window is available without restarting whatever holds the package.

When to call it directly

When you are building the engine's tool shape yourself — createMcpTools() takes exactly what this returns. For declarations alone, tools() is the one to use.