Skip to main content
Glama

get_memory

Retrieve your project's conventions, decisions, and gotchas. Filter by category, type, or keyword. Use before proposing patterns or libraries to ensure alignment with team practices.

Instructions

Routes to the active/current project automatically when known. Retrieves team conventions, architectural decisions, and known gotchas. CALL BEFORE suggesting patterns, libraries, or architecture.

Filters: category (tooling/architecture/testing/dependencies/conventions), type (convention/decision/gotcha), query (keyword search).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNoFilter by category
typeNoFilter by memory type
queryNoKeyword search across memory and reason
projectNoOptional project selector for this call. Accepts a project root path, file path, file:// URI, or a relative subproject path under a configured root.
project_directoryNoDeprecated compatibility alias for older clients. Prefer project.

Implementation Reference

  • The main handler function for get_memory. Reads memories from file, applies filters (category/type/query), limits to 20 unfiltered results, enriches with confidence decay, and returns JSON response.
    export async function handle(
      args: Record<string, unknown>,
      ctx: ToolContext
    ): Promise<ToolResponse> {
      const { category, type, query } = args as {
        category?: MemoryCategory;
        type?: MemoryType;
        query?: string;
      };
    
      try {
        const memoryPath = ctx.paths.memory;
        const allMemories = await readMemoriesFile(memoryPath);
    
        if (allMemories.length === 0) {
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(
                  {
                    status: 'success',
                    message:
                      "No team conventions recorded yet. Use 'remember' to build tribal knowledge or memory when the user corrects you over a repeatable pattern.",
                    memories: [],
                    count: 0
                  },
                  null,
                  2
                )
              }
            ]
          };
        }
    
        const filtered = filterMemories(allMemories, { category, type, query });
        const limited = applyUnfilteredLimit(filtered, { category, type, query }, 20);
    
        // Enrich with confidence decay
        const enriched = withConfidence(limited.memories);
        const staleCount = enriched.filter((m) => m.stale).length;
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(
                {
                  status: 'success',
                  count: enriched.length,
                  totalCount: limited.totalCount,
                  truncated: limited.truncated,
                  ...(staleCount > 0 && {
                    staleCount,
                    staleNote: `${staleCount} memor${staleCount === 1 ? 'y' : 'ies'} below 30% confidence. Consider reviewing or removing.`
                  }),
                  message: limited.truncated
                    ? 'Showing 20 most recent. Use filters (category/type/query) for targeted results.'
                    : undefined,
                  memories: enriched
                },
                null,
                2
              )
            }
          ]
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(
                {
                  status: 'error',
                  message: 'Failed to retrieve memories.',
                  error: error instanceof Error ? error.message : String(error)
                },
                null,
                2
              )
            }
          ]
        };
      }
    }
  • Tool definition with inputSchema: accepts optional category, type, and query filters.
    export const definition: Tool = {
      name: 'get_memory',
      description:
        'Retrieves team conventions, architectural decisions, and known gotchas.\n' +
        'CALL BEFORE suggesting patterns, libraries, or architecture.\n\n' +
        'Filters: category (tooling/architecture/testing/dependencies/conventions), type (convention/decision/gotcha), query (keyword search).',
      inputSchema: {
        type: 'object',
        properties: {
          category: {
            type: 'string',
            description: 'Filter by category',
            enum: ['tooling', 'architecture', 'testing', 'dependencies', 'conventions']
          },
          type: {
            type: 'string',
            description: 'Filter by memory type',
            enum: ['convention', 'decision', 'gotcha', 'failure']
          },
          query: {
            type: 'string',
            description: 'Keyword search across memory and reason'
          }
        }
      }
    };
  • Tool registered as d10 in the TOOLS array, with project selector wrapper applied.
    export const TOOLS: Tool[] = [d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11].map(
      withProjectSelector
    );
  • Dispatch case routing 'get_memory' to the handler (h10) imported from get-memory.ts.
    case 'get_memory':
      return h10(args, ctx);
  • Reads and parses the memories JSON file. Returns empty array on any error.
    export async function readMemoriesFile(memoryPath: string): Promise<Memory[]> {
      try {
        const content = await fs.readFile(memoryPath, 'utf-8');
        return normalizeMemories(JSON.parse(content));
      } catch {
        return [];
      }
    }
Behavior2/5

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

No annotations are provided, and the description only mentions automatic routing to the active project. It fails to disclose behavioral traits such as read-only nature, side effects, error handling, or limitations, which is a significant gap for a retrieval tool.

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?

The description is extremely concise: two sentences plus a line listing filters. Every sentence provides essential information without extraneous words, making it easy to scan.

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

Completeness3/5

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

With no output schema and no annotations, the description covers purpose and usage well but lacks details on return values, result count, pagination, or error conditions. It is adequate but not fully complete for a tool that influences important decisions.

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 description adds value by listing filter enums and query usage, but it omits two parameters (project and project_directory) entirely. Since schema description coverage is 100%, the baseline is 3, but missing param details reduce the added value.

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 tool retrieves team conventions, architectural decisions, and known gotchas, with automatic routing to the active project. It distinguishes itself from siblings like get_style_guide or get_team_patterns by being a general memory retrieval tool.

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

Usage Guidelines4/5

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

The description explicitly advises 'CALL BEFORE suggesting patterns, libraries, or architecture,' providing clear context for when to use. It lacks explicit when-not-to-use or alternative tool mentions, but the usage instruction is strong.

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/PatrickSys/codebase-context'

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