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

# Mastra

> Connect Worlds to Mastra

[Mastra](https://mastra.ai/) is an un-opinionated AI framework you can run
alongside your application code. Because it follows Vercel AI SDK standards,
`@wazoo/tools` works with Mastra agents out of the box.

## Installation

Install Mastra core and the Wazoo AI tools:

<CodeGroup>
  ```bash npm theme={null}
  npm i @mastra/core && npx jsr add @wazoo/tools
  ```

  ```bash deno theme={null}
  deno add npm:@mastra/core jsr:@wazoo/tools
  ```

  ```bash pnpm theme={null}
  pnpm add @mastra/core && pnpm dlx jsr add @wazoo/tools
  ```

  ```bash yarn theme={null}
  yarn add @mastra/core && yarn dlx jsr add @wazoo/tools
  ```

  ```bash bun theme={null}
  bun add @mastra/core && bunx jsr add @wazoo/tools
  ```
</CodeGroup>

## Usage

You can pass `@wazoo/tools` directly to a Mastra `Agent`.

```typescript theme={null}
import { Agent } from "@mastra/core/agent";
import { openai } from "@ai-sdk/openai";
import { Client } from "@worlds/sdk";
import { ComunicaSparqlEngine } from "@worlds/sdk/comunica";
import { RdfjsQuadStore, RdfjsSearchIndex } from "@worlds/sdk/rdfjs";
import { QueryEngine } from "@comunica/query-sparql-rdfjs-lite";
import { Store } from "n3";
import { createTools } from "@wazoo/tools";

const store = new Store();
const client = new Client({
  quadStore: new RdfjsQuadStore(store),
  searchIndex: new RdfjsSearchIndex(store),
  sparqlEngine: new ComunicaSparqlEngine({
    queryEngine: new QueryEngine(),
    store,
  }),
});

const { executeSparql, searchEntities } = createTools({
  client,
  sources: ["my-world"],
});

// Create a Mastra agent with Worlds tools
const agent = new Agent({
  name: "WorldsAgent",
  instructions: "You are a knowledge graph assistant.",
  model: openai("gpt-4o"),
  tools: {
    executeSparql,
    searchEntities,
  },
});

const result = await agent.generate("Find all people in my world.");
console.log(result.text);
```

## Granular selection

If you only need specific tools, you can import and initialize them
individually:

```typescript theme={null}
import { Agent } from "@mastra/core/agent";
import { openai } from "@ai-sdk/openai";
import { createSearchEntitiesTool } from "@wazoo/tools";

// client is the @worlds/sdk instance from the usage example above.
const agent = new Agent({
  name: "SearchAgent",
  model: openai("gpt-4o"),
  tools: {
    search: createSearchEntitiesTool(client),
  },
});
```
