api.mcp

tools()

api.mcp.tools(names?) → Promise<Declaration[]>

The allowed tools of those servers, as declarations ready for models.turn({ tools }). For anyone writing their own loop — MCP does not depend on our engine.

ready for turn()sanitisednames are prefixed
Using Python?

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

const tools = await api.mcp.tools(["example"]);
// [{ name: "example_search_docs", description: "…", parameters: { … } }]

const turn = await api.models.turn({
  model: "gemini-3.5-flash",
  messages: [{ role: "user", content: "Find the retry policy." }],
  tools,
});
tools = api.mcp.tools(["example"])
# [{"name": "example_search_docs", "description": "…", "parameters": {…}}]

turn = api.models.turn(
    model="gemini-3.5-flash",
    messages=[{"role": "user", "content": "Find the retry policy."}],
    tools=tools,
)
namesstring[]|nullall connected

Which servers. [] returns nothing.

Names carry the server

example_search_docs — two servers can both offer search, and a third-party tool must never be able to take the name of one of ours. The name is trimmed to 64 characters.

The schemas are sanitised

This is not a precaution, it is required

A provider refuses a raw MCP schema — a reference, an unusual construct — and fails the whole turn, not just that tool. One third-party server could break every answer. sanitizeSchema() reduces each one to what providers understand, and a schema with no usable type becomes a string parameter rather than a tool that cannot be declared at all.

No tokens in it

Declarations only. To actually run one, call api.mcp.call(), which reads the connection itself.

Against giving them to an agent

tools() + your loopagents.create({ mcp })
Who runs the round tripyouthe engine
Permission per callyours to buildthe category, through onPermission
Budgetyourscounted and enforced
Works onany providerany provider