Skip to main content
Glama

m9k_file_history

Read-onlyIdempotent

Search past conversations and metadata to find when specific files were discussed or modified, using indexed conversation history and file path references.

Instructions

Find past conversations that touched a specific file. Searches metadata (tool_use file_path) and text content.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesFile path to search for (e.g. "src/server.ts")
limitNoMax results
sourceNoFilter by source type. Default: all sources.

Implementation Reference

  • Handler implementation for 'm9k_file_history' tool.
    async ({ filePath, limit }) => {
      const basename = path.basename(filePath);
    
      // Strategy 1: LIKE on metadata_json for the file path
      const metadataRows = ctx.db
        .prepare(
          `SELECT c.id, c.session_id, c.idx, c.user_content, c.assistant_content,
                  c.timestamp, c.metadata_json, s.project
           FROM conv_chunks c
           JOIN conv_sessions s ON c.session_id = s.id
           WHERE c.metadata_json LIKE ?
             AND c.deleted_at IS NULL
           ORDER BY c.timestamp DESC
           LIMIT ?`,
        )
        .all(`%${filePath}%`, limit * 2) as Array<{
        id: string;
        session_id: string;
        idx: number;
        user_content: string;
        assistant_content: string;
        timestamp: string;
        metadata_json: string;
        project: string;
      }>;
    
      // Strategy 2: FTS5 on the basename
      let ftsRows: typeof metadataRows = [];
      try {
        ftsRows = ctx.db
          .prepare(
            `SELECT c.id, c.session_id, c.idx, c.user_content, c.assistant_content,
                    c.timestamp, c.metadata_json, s.project
             FROM conv_chunks_fts
             JOIN conv_chunks c ON conv_chunks_fts.rowid = c.rowid
             JOIN conv_sessions s ON c.session_id = s.id
             WHERE conv_chunks_fts MATCH ?
               AND c.deleted_at IS NULL
             ORDER BY c.timestamp DESC
             LIMIT ?`,
          )
          .all(basename, limit * 2) as typeof metadataRows;
      } catch {
        // FTS5 syntax error — skip
      }
    
      // Dedup by chunkId, metadata results first (more precise)
      const seen = new Set<string>();
      const combined: Array<{
        chunkId: string;
        sessionId: string;
        project: string;
        timestamp: string;
        snippet: string;
        filePaths: string[];
      }> = [];
    
      for (const row of [...metadataRows, ...ftsRows]) {
        if (seen.has(row.id)) continue;
        seen.add(row.id);
    
        let filePaths: string[] = [];
        try {
          const meta = JSON.parse(row.metadata_json) as { filePaths?: string[] };
          filePaths = meta.filePaths ?? [];
        } catch {
          // ignore parse error
        }
    
        combined.push({
          chunkId: row.id,
          sessionId: row.session_id,
          project: row.project,
          timestamp: row.timestamp,
          snippet: (row.user_content + ' ' + row.assistant_content).slice(0, 150),
          filePaths,
        });
      }
    
      // Sort by timestamp DESC, take top limit
      combined.sort((a, b) => b.timestamp.localeCompare(a.timestamp));
    
      return {
        content: [{ type: 'text' as const, text: JSON.stringify(combined.slice(0, limit)) }],
      };
    },
  • Input schema definition for the 'm9k_file_history' tool.
    inputSchema: {
      filePath: z.string().describe('File path to search for (e.g. "src/server.ts")'),
      limit: z.number().int().min(1).max(50).default(10).describe('Max results'),
      source: z
        .enum(['conversations', 'git', 'files'])
        .optional()
        .describe('Filter by source type. Default: all sources.'),
    },
  • Registration of the 'm9k_file_history' tool.
    export function registerSpecializedTools(server: McpServer, ctx: ToolContext): void {
      server.registerTool(
        'm9k_file_history',
        {
          description:
            'Find past conversations that touched a specific file. Searches metadata (tool_use file_path) and text content.',
          inputSchema: {
            filePath: z.string().describe('File path to search for (e.g. "src/server.ts")'),
            limit: z.number().int().min(1).max(50).default(10).describe('Max results'),
            source: z
              .enum(['conversations', 'git', 'files'])
              .optional()
              .describe('Filter by source type. Default: all sources.'),
          },
          annotations: {
            readOnlyHint: true,
            destructiveHint: false,
            idempotentHint: true,
            openWorldHint: false,
          },
        },
Behavior4/5

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

Annotations establish read-only safety (readOnlyHint=true, destructiveHint=false). The description adds valuable behavioral context that annotations don't provide: specifically that the search covers both metadata (tool_use file_path) and text content, clarifying the matching algorithm.

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, zero waste. First sentence establishes the core purpose (find conversations by file), second sentence adds implementation detail (search scope). Front-loaded with the essential action and resource.

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?

Reasonably complete for a read-only query tool, but gaps exist: it doesn't clarify the relationship between the source enum values (git/files) and the 'conversations' framing, nor does it describe the return shape given the absence of an output schema.

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?

With 100% schema description coverage, the baseline is 3. The description adds semantic context by mentioning 'specific file' (mapping to filePath) and noting that file_path appears in metadata, which helps explain how the required parameter is interpreted, meeting but not exceeding the baseline.

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 verb (Find), resource (past conversations), and scope (that touched a specific file). However, it frames the output exclusively as 'conversations' when the source parameter allows searching git and files as well, creating slight ambiguity about whether output type varies by source.

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

Usage Guidelines3/5

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

The description provides implied usage through specificity—'touched a specific file' suggests when to use this versus general search tools like m9k_search. However, it lacks explicit when-not-to-use guidance or named alternatives.

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/louis49/melchizedek'

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