Skip to main content
Glama

Export memories as JSON

memory_export
Read-onlyIdempotent

Create a portable JSON backup of project memories, decisions, and pitfalls to restore after destructive maintenance or migrate to another memento instance.

Instructions

Export memories, decisions, and pitfalls as a portable JSON document. Read-only. Use before destructive maintenance (bulk delete, schema migration) so you have a clean restore point, or to transfer state to another memento-mcp instance via memory_import. Includes scope, tags, importance, and supersession links so round-trip preserves structure.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_pathNoAbsolute project path to export. Empty string (default) exports memories across all projects.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYesJSON document (as a string) containing `memories`, `decisions`, and `pitfalls` arrays plus a `meta` object with export timestamp and scope.

Implementation Reference

  • The handler function that exports memories, decisions, and pitfalls as a JSON string. Accepts an optional project_path parameter to filter by project; exports all if empty. Queries projects, memories, decisions, and pitfalls tables and returns a JSON-serialized ExportPayload.
    export async function handleMemoryExport(
      db: Database.Database,
      params: { project_path?: string },
    ): Promise<string> {
      let projectId: string | null = null;
      if (params.project_path) {
        const row = db
          .prepare("SELECT id FROM projects WHERE root_path = ?")
          .get(params.project_path) as { id: string } | undefined;
        projectId = row?.id ?? null;
        if (!projectId) {
          return JSON.stringify({
            schema_version: CURRENT_SCHEMA_VERSION,
            exported_at: new Date().toISOString(),
            projects: [],
            memories: [],
            decisions: [],
            pitfalls: [],
          });
        }
      }
    
      const projectsQuery = projectId
        ? db.prepare("SELECT * FROM projects WHERE id = ?").all(projectId)
        : db.prepare("SELECT * FROM projects").all();
    
      const memoriesQuery = projectId
        ? db
            .prepare(
              "SELECT * FROM memories WHERE (project_id = ? OR scope = 'global') AND deleted_at IS NULL",
            )
            .all(projectId)
        : db.prepare("SELECT * FROM memories WHERE deleted_at IS NULL").all();
    
      const decisionsQuery = projectId
        ? db
            .prepare("SELECT * FROM decisions WHERE project_id = ? AND deleted_at IS NULL")
            .all(projectId)
        : db.prepare("SELECT * FROM decisions WHERE deleted_at IS NULL").all();
    
      const pitfallsQuery = projectId
        ? db
            .prepare("SELECT * FROM pitfalls WHERE project_id = ? AND deleted_at IS NULL")
            .all(projectId)
        : db.prepare("SELECT * FROM pitfalls WHERE deleted_at IS NULL").all();
    
      const payload: ExportPayload = {
        schema_version: CURRENT_SCHEMA_VERSION,
        exported_at: new Date().toISOString(),
        projects: projectsQuery,
        memories: memoriesQuery,
        decisions: decisionsQuery,
        pitfalls: pitfallsQuery,
      };
    
      return JSON.stringify(payload, null, 2);
    }
  • ExportPayload interface defining the schema of the exported JSON structure.
    interface ExportPayload {
      schema_version: number;
      exported_at: string;
      projects: any[];
      memories: any[];
      decisions: any[];
      pitfalls: any[];
    }
  • src/index.ts:622-645 (registration)
    Registration of the 'memory_export' tool on the MCP server, with its title, description, input schema (with optional project_path), annotations, and handler binding to handleMemoryExport.
    server.registerTool(
      "memory_export",
      {
        title: "Export memories as JSON",
        description: [
          "Export memories, decisions, and pitfalls as a portable JSON document. Read-only.",
          "Use before destructive maintenance (bulk delete, schema migration) so you have a clean restore point, or to transfer state to another memento-mcp instance via `memory_import`. Includes scope, tags, importance, and supersession links so round-trip preserves structure.",
        ].join(" "),
        inputSchema: {
          project_path: z.string().default("").describe("Absolute project path to export. Empty string (default) exports memories across all projects."),
        },
        annotations: {
          title: "Export memories as JSON",
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: false,
        },
        outputSchema: {
          message: z.string().describe("JSON document (as a string) containing `memories`, `decisions`, and `pitfalls` arrays plus a `meta` object with export timestamp and scope."),
        },
      },
      async (params) => textResult(await handleMemoryExport(db, params))
    );
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, destructiveHint=false. The description adds context about what the export includes (scope, tags, importance, supersession links) and that round-trip preserves structure, which goes beyond annotations. No contradiction.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, front-loaded with the action and output, followed by usage guidance. Every sentence adds essential information with no redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (one optional parameter, read-only operation, output schema present), the description covers purpose, usage, content, and safety fully. No gaps remain for an agent to misuse the tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has one parameter with 100% description coverage, so the schema already documents project_path well. The description does not add meaning beyond the schema, meeting baseline expectations.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'export' and resource 'memories as JSON', specifying the exact data exported (memories, decisions, pitfalls) and the output format (portable JSON). This distinguishes it from siblings like memory_list (non-export) and memory_import (reverse operation).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly provides precise when-to-use scenarios: before destructive maintenance (bulk delete, schema migration) as a restore point, and for transferring state to another instance via memory_import. Also notes it's read-only, implying safe to use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lfrmonteiro99/memento-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server