> ## 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 @struktoai/mirage-mastra.

[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.

## Install

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

## Usage

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

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 |
| - | - |
| `MIRAGE_SYSTEM_PROMPT` | The default system prompt: how the Mirage filesystem differs from a plain one. |
| `buildSystemPrompt` | Returns `MIRAGE_SYSTEM_PROMPT` followed by a description of the mounted paths and any extra instructions, ready to use as an agent's system prompt. |
| `BuildSystemPromptOptions` | Options for `buildSystemPrompt`: which mounts to describe and what to append. |
| `mirageTools` | Returns Mirage's tools (`shell`, `read`, `write`, `edit`, `ls`, `grep`, `glob`) as Mastra tools, limited to what the session's profile allows. |

## 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.