Skip to main content
Glama

create_memory

Generate structured memory documents in MCP server projects to store and organize user-specific knowledge and preferences. Includes setup instructions for proper integration and functionality.

Instructions

Create a new structured memory document with optional initial content. IMPORTANT: After using this tool, you MUST show the user the complete installation instructions returned by the tool - the memory will not work without proper MCP server setup and project context configuration.

Input Schema

NameRequiredDescriptionDefault
contentNoOptional initial content for the memory document. Can be brief context (e.g., 'planning a trip to Japan') or full Markdown content. Focus on capturing what you've learned FROM the user (their preferences, requirements, decisions) rather than generating extensive AI content.
nameYesUnique identifier/name for this memory

Input Schema (JSON Schema)

{ "properties": { "content": { "description": "Optional initial content for the memory document. Can be brief context (e.g., 'planning a trip to Japan') or full Markdown content. Focus on capturing what you've learned FROM the user (their preferences, requirements, decisions) rather than generating extensive AI content.", "type": "string" }, "name": { "description": "Unique identifier/name for this memory", "type": "string" } }, "required": [ "name" ], "type": "object" }

Implementation Reference

  • The core handler function `createMemoryTool` that implements the logic for creating a new memory document: validates input parameters, generates a sanitized memory ID, checks for existing memories, handles content creation or generation, constructs the Memory object, persists it to storage, and returns detailed setup instructions for the user.
    export async function createMemoryTool( storageManager: StorageManager, args: any ): Promise<any> { const params = args as CreateMemoryParams; if (!params.name) { throw new Error("Memory document name is required"); } // Generate memory ID from name (sanitize for filename) const memoryId = params.name .toLowerCase() .replace(/[^a-z0-9\s-]/g, "") .replace(/\s+/g, "-") .replace(/-+/g, "-") .trim(); if (!memoryId) { throw new Error("Name must contain at least some alphanumeric characters"); } // Check if memory already exists const existing = await storageManager.readMemory(memoryId); if (existing) { throw new Error(`Memory document with ID '${memoryId}' already exists`); } // Handle content - either use provided content or generate basic structure const title = params.name; let content = ""; if (params.content && params.content.trim()) { // Use provided content directly (full markdown content) content = params.content; } else { // Generate basic structure with title and placeholder content = `# ${title}\n\n## Notes\n\n[Add your notes and organize into sections as needed]`; } // Create memory object const memory: Memory = { metadata: { id: memoryId, created: new Date().toISOString(), updated: new Date().toISOString(), tags: [], status: "active", }, content: content, filePath: "", }; // Save to storage await storageManager.writeMemory(memory); return { content: [ { type: "text", text: `SHOW THIS TO THE USER - Successfully created memory document: "${params.name}" 🚨 **PROJECT SETUP REQUIRED - MEMORY WILL NOT WORK OTHERWISE** 🚨 The memory "${params.name}" has been created but needs to be integrated into your project workflow. **Add these instructions to your project context:** \`\`\` At the start of each conversation, check the project memory "${params.name}" using get_full_memory. Automatically update the memory as you learn new information using add_to_list or update_section. \`\`\` ⚠️ **The memory will be unused until you add these instructions to your project context.**`, }, ], }; }
  • Interface definition `CreateMemoryParams` specifying the input structure for the create_memory tool: required `name` and optional `content`.
    export interface CreateMemoryParams { name: string; content?: string; }
  • src/index.ts:40-58 (registration)
    Tool registration in the `ListToolsRequestSchema` handler: defines `name: "create_memory"`, detailed description, and `inputSchema` matching CreateMemoryParams.
    { name: "create_memory", description: "Create a new structured memory document with optional initial content. IMPORTANT: After using this tool, you MUST show the user the complete installation instructions returned by the tool - the memory will not work without proper MCP server setup and project context configuration.", inputSchema: { type: "object", properties: { name: { type: "string", description: "Unique identifier/name for this memory", }, content: { type: "string", description: "Optional initial content for the memory document. Can be brief context (e.g., 'planning a trip to Japan') or full Markdown content. Focus on capturing what you've learned FROM the user (their preferences, requirements, decisions) rather than generating extensive AI content.", }, }, required: ["name"], }, },
  • src/index.ts:259-260 (registration)
    Tool dispatch in the `CallToolRequestSchema` switch statement: routes `create_memory` calls to `createMemoryTool(storageManager, args)`.
    case "create_memory": return await createMemoryTool(storageManager, args);
  • src/index.ts:10-10 (registration)
    Import statement for the `createMemoryTool` from `./tools/createMemory.js`.
    import { createMemoryTool } from "./tools/createMemory.js";

Other Tools

Related 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/nmeierpolys/mcp-structured-memory'

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