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

# Mastra

> Wire mirage tools into a Mastra Agent via the @struktoai/mirage-agents/mastra adapter.

[Mastra](https://mastra.ai) is an opinionated TypeScript framework for AI agents and workflows. Mirage ships a tool factory that gives a Mastra `Agent` a session's seven tools.

<Note>
  Node only. The Mirage adapter is runtime-agnostic, but most Mastra setups (memory, evals, workflows) depend on Node APIs.
</Note>

## Install

```bash theme={null}
pnpm add @struktoai/mirage-agents @struktoai/mirage-node @mastra/core
```

## Usage

```ts theme={null}
import { MountMode, RAMVFS, Workspace } from '@struktoai/mirage-node'
import { Agent } from '@mastra/core/agent'
import { mirageTools } from '@struktoai/mirage-agents/mastra'
import { buildSystemPrompt } from '@struktoai/mirage-agents/openai'

const ws = new Workspace({ '/': new RAMVFS() }, { mode: MountMode.WRITE })

const agent = new Agent({
  id: 'mirage-ram-agent',
  name: 'Mirage RAM Agent',
  instructions: await buildSystemPrompt({
    mountInfo: { '/': 'In-memory filesystem (read/write)' },
  }),
  model: 'openai/gpt-5.4-mini',
  tools: mirageTools(ws),
})

const result = await agent.generate(
  "Create /hello.txt with 'hi from mirage' and list every file under /.",
  { maxSteps: 20 },
)
console.log(result.text)
```

## Exports

| Symbol | Purpose |
| - | - |
| `mirageTools(ws, options?)` | `{ shell, read, write, edit, ls, grep, glob }`, each a Mastra `createTool()` with the id `mirage-<tool>`. They answer as the session's [`session.tools`](/typescript/access/in-app#session-tools) do; `options` takes `sessionId` and `staleWriteProtection`. |

## Examples

* [`examples/typescript/agents/mastra/ram_mastra.ts`](https://github.com/strukto-ai/mirage/blob/main/examples/typescript/agents/mastra/ram_mastra.ts), RAM-only sandbox driven by `gpt-5.4-mini`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.