---
title: "Mastra - AI agent tools"
description: "Use tool definitions for Mastra to let AI agents read and edit Tiptap documents."
canonical_url: "https://tiptap.dev/docs/content-ai/capabilities/ai-toolkit/agents/tools/mastra"
---

# Mastra - AI agent tools

Use tool definitions for Mastra to let AI agents read and edit Tiptap documents.

The `@tiptap-pro/ai-toolkit-ai-sdk` package provides tool definitions you can add to your AI agent built with the [Mastra](https://mastra.ai/) AI Agent framework.

The tool calls generated by the model can then be executed using the [`executeTool` method](https://tiptap.dev/docs/content-ai/capabilities/ai-toolkit/api-reference/execute-tool.md).

## Example usage

Install the package.

```bash
npm install @tiptap-pro/ai-toolkit-ai-sdk
```

Supply the tool definitions to the `tools` parameter of your Mastra Agent.

```ts
import { Agent } from '@mastra/core/agent'
import { openai } from '@ai-sdk/openai'
import { toolDefinitions } from '@tiptap-pro/ai-toolkit-ai-sdk'

const agent = new Agent({
  name: 'Tiptap AI Agent',
  instructions: 'You are an AI assistant that can read and edit Tiptap documents.',
  model: openai('gpt-5.4-mini'),
  tools: toolDefinitions(),
})

const result = await agent.generate('Read the document and summarize it')
```

Combine the tool definitions with your custom tools.

```ts
import { Agent } from '@mastra/core/agent'
import { openai } from '@ai-sdk/openai'
import { createTool } from '@mastra/core/tools'
import { toolDefinitions } from '@tiptap-pro/ai-toolkit-ai-sdk'
import { z } from 'zod'

// Custom weather tool using Mastra's createTool
const weatherTool = createTool({
  id: 'Get Weather Information',
  description: 'Get the weather in a location',
  inputSchema: z.object({
    location: z.string().describe('The location to get weather for'),
  }),
  outputSchema: z.object({
    temperature: z.number(),
  }),
  execute: async ({ context: { location } }) => ({
    temperature: 72,
  }),
})

const agent = new Agent({
  name: 'Tiptap AI Agent with Weather',
  instructions:
    'You are an AI assistant that can read and edit Tiptap documents and get weather information.',
  model: openai('gpt-5.4-mini'),
  tools: {
    // Tool definitions from the AI Toolkit
    ...toolDefinitions(),
    // Custom weather tool
    weather: weatherTool,
  },
})

const result = await agent.generate('Read the document and get the weather in New York')
```

## API reference

### `toolDefinitions`

Creates tool definitions for the Tiptap AI Toolkit compatible with [Mastra](https://mastra.ai/).

#### Parameters (`ToolDefinitionsOptions`)

- `tools?`: `EnabledTools` - Enable/disable specific tools by setting the value to `true` (enabled) or `false` (disabled).
  - `tiptapRead?`: `boolean` - Enable/disable the `tiptapRead` tool (default: `true`)
  - `tiptapEdit?`: `boolean` - Enable/disable the `tiptapEdit` tool (default: `true`)
  - `tiptapReadSelection?`: `boolean` - Enable/disable the `tiptapReadSelection` tool (default: `true`)
  - `getThreads?`: `boolean` - Enable/disable the `getThreads` tool (default: `false`)
  - `editThreads?`: `boolean` - Enable/disable the `editThreads` tool (default: `false`)

#### Returns

An object containing the enabled tool definitions that can be used with [Mastra](https://mastra.ai/)'s tool calling system. To see the full list of tools, see the [Available tools](https://tiptap.dev/docs/content-ai/capabilities/ai-toolkit/agents/tools.md) page.
