> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeroruntime.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Tools & MCP

> TypeScript API reference for Tools & MCP.

## function\_tool

```ts theme={null}
function_tool(options: FunctionToolOptions<P, R>): FunctionTool<ToolArgs<P>, R>
```

Expose a function to the model as a callable tool.

```ts theme={null}
const lookup_order = function_tool(&#123;
  name: 'lookup_order',
  description: 'Find an order by its id.',
  parameters: &#123;
    order_id: &#123; type: 'string', description: "The customer's order number." &#125;,
  &#125;,
  execute: async (&#123; order_id &#125;) =&gt; find(order_id),
&#125;);
```

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(&#123; tools: [...] &#125;)`.

<ParamField path="options" type="FunctionToolOptions<P, R>" required />

<ResponseField name="returns" type="FunctionTool<ToolArgs<P>, R>" />

***

## MCPServerStdio

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

### Options

```ts theme={null}
MCPServerStdio(options: MCPServerStdioOptions)
```

<ParamField path="environment_vars" type="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.
</ParamField>

<ParamField path="executable_path" type="string" required>
  The program to run, e.g. `process.execPath`.
</ParamField>

<ParamField path="process_arguments" type="string[]">
  Its arguments -- typically the server script.
</ParamField>

<ParamField path="session_timeout" type="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.
</ParamField>

<ParamField path="working_directory" type="string | null">
  Directory to run it in.
</ParamField>

### toString

```ts theme={null}
toString(): string
```

<ResponseField name="returns" type="string" />

***

## MCPServerHTTP

A remote MCP server, reached over HTTP.

### Options

```ts theme={null}
MCPServerHTTP(options: MCPServerHTTPOptions)
```

<ParamField path="connection_timeout" type="number">
  Seconds to wait for the connection.
</ParamField>

<ParamField path="endpoint_url" type="string" required>
  The server's URL.
</ParamField>

<ParamField path="request_headers" type="Record<string, string> | null">
  Sent with every request -- an API key usually lives here. Read in this
  process, so the credential stays with you.
</ParamField>

<ParamField path="session_timeout" type="number">
  Seconds to wait for the session, and for each tool call.
</ParamField>

<ParamField path="stream_read_timeout" type="number">
  Seconds a quiet stream may stay open. Long by default: an MCP server that
  has nothing to say is not broken.
</ParamField>

### transport\_mode

```ts theme={null}
transport_mode(): void
```

### toString

```ts theme={null}
toString(): string
```

<ResponseField name="returns" type="string" />
