function_tool
__name__, the prose above its
Args: block, and its type hints — so a well-written docstring is what
the model sees.
Agent subclass are registered automatically; tools defined
elsewhere go in Agent(tools=[...]).
Optional[Callable]
The function, when used bare.
Optional[str]
Override the exposed name. Everything else the model is told comes off the function itself, so this is the only knob.
The function, marked as a tool.
MCPServerStdio
A local MCP server, run as a subprocess and spoken to over stdio.Fields
str
required
The program to run, e.g.
sys.executable.List[str]
default:"…"
Its arguments — typically the server script.
Optional[Dict[str, str]]
Environment for the child.
None inherits this process’s, which is usually what you want: the server needs the same API keys you already have.Optional[Union[str, Path]]
Directory to run it in.
float
default:"5.0"
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.
str
default:"stdio"
Always
stdio. Set for you — it is what tells the SDK which transport to connect with.MCPServerHTTP
A remote MCP server, reached over HTTP.Fields
str
required
The server’s URL.
Optional[Dict[str, str]]
Sent with every request — an API key usually lives here. Read in this process, so the credential stays with you.
float
default:"10.0"
Seconds to wait for the connection.
float
default:"300.0"
Seconds a quiet stream may stay open. Long by default: an MCP server that has nothing to say is not broken.
float
default:"5.0"
Seconds to wait for the session, and for each tool call.
str
default:"http"
Always
http. Set for you.