Skip to main content

function_tool

Expose a function to the model as a callable tool.
The name, description and parameter schema are stated rather than derived: JavaScript keeps neither comments nor type annotations at runtime, so there is nothing to read a tool schema off. What you write here is exactly what the model is shown. Tools declared as fields on an Agent subclass are registered automatically; tools defined elsewhere go in Agent({ tools: [...] }).
FunctionToolOptions<P, R>
required
FunctionTool<ToolArgs<P>, R>

MCPServerStdio

A local MCP server, run as a subprocess and spoken to over stdio.

Options

Record<string, string> | null
Environment for the child. null inherits this process’s, which is usually what you want: the server needs the same API keys you already have.
string
required
The program to run, e.g. process.execPath.
string[]
Its arguments — typically the server script.
number
Seconds to wait for the connection and for each tool call. The vendor’s default is 5, which is tight for a server that starts an interpreter; its own examples pass 30.
string | null
Directory to run it in.

toString

string

MCPServerHTTP

A remote MCP server, reached over HTTP.

Options

number
Seconds to wait for the connection.
string
required
The server’s URL.
Record<string, string> | null
Sent with every request — an API key usually lives here. Read in this process, so the credential stays with you.
number
Seconds to wait for the session, and for each tool call.
number
Seconds a quiet stream may stay open. Long by default: an MCP server that has nothing to say is not broken.

transport_mode

toString

string