Skip to main content
Glama

create_memory

Store structured project knowledge and user preferences in memory documents to enable informed AI responses through proper MCP server configuration.

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

TableJSON Schema
NameRequiredDescriptionDefault
nameYesUnique identifier/name for this memory
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.

Implementation Reference

  • The core handler function `createMemoryTool` that executes the `create_memory` tool: validates input, sanitizes name to ID, checks for existence, generates or uses content, creates and saves Memory object, returns user instructions.
    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.**`,
          },
        ],
      };
    }
  • src/index.ts:259-260 (registration)
    Tool dispatch in the CallToolRequestSchema handler switch statement, calling the createMemoryTool.
    case "create_memory":
      return await createMemoryTool(storageManager, args);
  • src/index.ts:10-10 (registration)
    Import of the createMemoryTool handler function.
    import { createMemoryTool } from "./tools/createMemory.js";
  • src/index.ts:41-58 (registration)
    Tool registration in ListToolsRequestSchema: name, description, and inputSchema for 'create_memory'.
      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"],
      },
    },
  • Type definition for CreateMemoryParams used in the handler for input validation.
    export interface CreateMemoryParams {
      name: string;
      content?: string;
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behaviors: it creates a new document (implying mutation), requires showing installation instructions post-invocation, and hints at setup dependencies ('MCP server setup and project context configuration'). However, it doesn't cover aspects like error conditions, permissions needed, or what happens if the name isn't unique, leaving some gaps.

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

Conciseness4/5

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

The description is appropriately sized with two sentences: the first states the purpose and key parameter detail, and the second provides critical usage instructions. It's front-loaded with the core action and avoids unnecessary elaboration, though the second sentence is somewhat lengthy but justified by its importance.

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

Completeness4/5

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

Given the tool's complexity (a creation tool with setup dependencies), no annotations, and no output schema, the description does a good job by explaining the creation action and post-invocation requirements. However, it lacks details on the return value (e.g., what 'installation instructions' entail) and doesn't address potential errors or uniqueness constraints, which could be improved for full completeness.

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?

The schema description coverage is 100%, so the schema already fully documents the two parameters (name and content). The description adds minimal semantic value beyond the schema—it mentions 'optional initial content' and provides an example ('e.g., planning a trip to Japan'), but this is largely redundant with the schema's descriptions. Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose4/5

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

The description clearly states the action ('Create a new structured memory document') and resource ('memory document'), making the purpose understandable. However, it doesn't explicitly differentiate this tool from sibling tools like 'update_section' or 'add_to_list' that might also create or modify memory content, so it doesn't reach the highest score.

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?

The description provides explicit usage guidance with '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.' This clearly indicates when and how to use this tool, including critical post-invocation steps, which is comprehensive guidance.

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

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