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

# Tools

> Create type-safe tools for your agents

**Tools** are functions that agents can call to perform specific actions. The SDK uses Zod for type-safe validation.

## Create Basic Tool

```typescript theme={null}
import { createTool } from '@runflow-ai/sdk';
import { z } from 'zod';

const weatherTool = createTool({
  id: 'get-weather',
  description: 'Get current weather for a location',
  inputSchema: z.object({
    location: z.string().describe('City name'),
    units: z.enum(['celsius', 'fahrenheit']).optional(),
  }),
  outputSchema: z.object({
    temperature: z.number(),
    condition: z.string(),
  }),
  execute: async (params) => {
    // Implement logic
    const weather = await fetchWeather(params.location);

    return {
      temperature: weather.temp,
      condition: weather.condition,
    };
  },
});
```

## Tool with Runflow API

```typescript theme={null}
const searchDocsTool = createTool({
  id: 'search-docs',
  description: 'Search in documentation',
  inputSchema: z.object({
    query: z.string(),
  }),
  execute: async (params, toolContext) => {
    // Use Runflow API for vector search
    const results = await toolContext.runflow.vectorSearch(params.query, {
      vectorStore: 'docs',
      k: 5,
    });

    return {
      results: results.results.map(r => r.content),
    };
  },
});
```

## Tool with Connector

```typescript theme={null}
const createTicketTool = createTool({
  id: 'create-ticket',
  description: 'Create a support ticket',
  inputSchema: z.object({
    subject: z.string(),
    description: z.string(),
    priority: z.enum(['low', 'medium', 'high']),
  }),
  execute: async (params, toolContext) => {
    // Use connector
    const ticket = await toolContext.runflow.connector(
      'hubspot',
      'create-ticket',
      {
        subject: params.subject,
        content: params.description,
        priority: params.priority,
      }
    );

    return { ticketId: ticket.id };
  },
});
```

## Tool Execution Context

The `execute` function receives two arguments:

* `params`: Validated input parameters (parsed from `inputSchema` via Zod)
* `toolContext`: An object with `{ projectId, companyId, userId, sessionId, runflow }` for accessing platform APIs

## Using Tools in Agents

```typescript theme={null}
const agent = new Agent({
  name: 'Weather Agent',
  instructions: 'You help users check the weather.',
  model: openai('gpt-4o'),
  tools: {
    weather: weatherTool,
    searchDocs: searchDocsTool,
    createTicket: createTicketTool,
  },
});

const result = await agent.process({
  message: 'What is the weather in São Paulo?',
});
```

## Built-in Tools

The SDK includes ready-to-use tools that you can add to any agent:

```typescript theme={null}
import { createWebSearchTool, createScheduleTools } from '@runflow-ai/sdk';

const agent = new Agent({
  name: 'My Agent',
  model: openai('gpt-4o'),
  tools: {
    search: createWebSearchTool({ provider: 'tavily', apiKey: '...' }),
    ...createScheduleTools(),
  },
});
```

* **Web Search** — Search the internet with Tavily, Exa, or Serper
* **Schedule** — Create, list, update, and cancel scheduled executions

## Next Steps

<CardGroup cols={2}>
  <Card title="Web Search" icon="magnifying-glass" href="/core-concepts/web-search">
    Add internet search to your agents
  </Card>

  <Card title="Schedule" icon="clock" href="/core-concepts/schedule">
    Create scheduled executions
  </Card>

  <Card title="HTTP Utilities" icon="globe" href="/core-concepts/http-utilities">
    Use HTTP helpers in tools
  </Card>

  <Card title="Connectors" icon="plug" href="/core-concepts/connectors">
    Use built-in connectors
  </Card>
</CardGroup>
