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

# Mastra Integration

> Give Mastra agents persistent, cross-session memory with Memanto tools.

# Mastra + Memanto

<img src="https://mintcdn.com/memanto/7cqii5_wGejS32un/logo/integrations/mastra.svg?fit=max&auto=format&n=7cqii5_wGejS32un&q=85&s=93b83b060d49ed8313c2b02b9ef5e4bb" alt="Mastra" width="64" style={{marginBottom: "1.5rem"}} data-path="logo/integrations/mastra.svg" />

Add persistent memory to any [Mastra](https://mastra.ai/) agent with three ready-made tools, shipped as part of the `@moorcheh-ai/memanto` TypeScript SDK.

## Prerequisites

* Node.js 20+
* [Moorcheh API key](https://console.moorcheh.ai/api-keys) (or an on-prem Memanto backend — see [On-Prem](/on-prem/overview))
* `@mastra/core` and `zod` installed in your app (optional peer dependencies of `@moorcheh-ai/memanto`)

## Install

```bash theme={null}
npm install @moorcheh-ai/memanto @mastra/core zod
```

`@mastra/core` and `zod` are optional peer dependencies of `@moorcheh-ai/memanto` — install them yourself in the host app; `createMemantoMastraTools` fails fast with a clear error if they're missing.

## Quick Start

```ts theme={null}
import { Agent } from "@mastra/core/agent";
import { Memanto } from "@moorcheh-ai/memanto";
import { createMemantoMastraTools } from "@moorcheh-ai/memanto/mastra";

const memanto = new Memanto({ agentId: "my-agent" });

const agent = new Agent({
  id: "assistant",
  name: "Assistant",
  instructions:
    "You have long-term memory. Persist durable facts with rememberMemory " +
    "and look them up with recallMemory / answerMemory before answering.",
  model: "openai/gpt-4o",
  tools: createMemantoMastraTools(memanto),
});
```

`createMemantoMastraTools` returns an object with three [Mastra tools](https://mastra.ai/docs/agents/using-tools-and-mcp) — pass it straight into an agent's `tools` map.

## Available Tools

| Tool             | Backed by                                                  | Description                                                                                                                                           |
| ---------------- | ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `recallMemory`   | [Recall](/api-reference/search/recall)                     | Semantic search over stored memories. `query` (required), `limit` (1-50), `type` (filter by memory type).                                             |
| `rememberMemory` | [Remember](/api-reference/data/remember)                   | Persist a durable fact/preference/decision/instruction. `content` (required), `type` (optional — server auto-classifies if omitted), `title`, `tags`. |
| `answerMemory`   | [Generate AI Answer](/api-reference/ai/generate-ai-answer) | RAG-synthesized answer over stored memories. `question` (required), `limit` (1-100).                                                                  |

## Options

```ts theme={null}
createMemantoMastraTools(memanto, {
  include: ["recallMemory", "answerMemory"], // expose a subset — omit for all three
  defaultLimit: 10,                           // default limit for recall/answer when the model doesn't specify one
});
```

## Memory Types

`type` fields are constrained to Memanto's 13 supported types via a shared `MEMORY_TYPES` export:

```ts theme={null}
import { MEMORY_TYPES } from "@moorcheh-ai/memanto/mastra";
// ["fact", "preference", "goal", "decision", "artifact", "learning", "event",
//  "instruction", "relationship", "context", "observation", "commitment", "error"]
```

See the [Memory Types Reference](/reference/memory-types) for what each type means.

## On-Prem

The integration talks to Memanto through the `Memanto` client, so it works identically against an on-prem backend — no code changes, just configure the backend once with the CLI. See [On-Prem Overview](/on-prem/overview) and the [TypeScript SDK Reference](/sdk/typescript#on-prem-no-api-key).

## Next Steps

* [TypeScript SDK Reference](/sdk/typescript) for the full `Memanto` client API
* [Vercel AI SDK Integration](/integrations/vercel-ai-sdk) for the equivalent AI SDK tools
* [OpenAI Integration](/integrations/openai) for the equivalent OpenAI `runTools()` tools
* [Memory Types Reference](/reference/memory-types)
