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 connectedWhich 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
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 loop | agents.create({ mcp }) | |
|---|---|---|
| Who runs the round trip | you | the engine |
| Permission per call | yours to build | the category, through onPermission |
| Budget | yours | counted and enforced |
| Works on | any provider | any provider |