Skip to main content
Glama

m9k_similar_work

Read-onlyIdempotent

Find similar past work to inform your current complex task. Use this tool at project start to discover previous approaches with rich metadata like multiple tools and files.

Instructions

Find past work similar to what you're about to do. Use at the start of a complex task to see previous approaches. Unlike m9k_search, this prioritizes chunks with rich metadata (multiple tools used, multiple files touched).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYesDescription of the current task
limitNo
sourceNoFilter by source type. Default: all sources.

Implementation Reference

  • The handler logic for 'm9k_similar_work' tool, which performs a search and applies a bonus score based on metadata (tool calls and touched files).
      async ({ description, limit }) => {
        // Use the same search pipeline as m9k_search
        const results = await search(
          ctx.db,
          { query: description, limit: limit * 3 },
          ctx.searchContext,
        );
    
        // Apply metadata bonus scoring
        const enriched = results.map((r) => {
          const chunk = ctx.db
            .prepare('SELECT metadata_json FROM conv_chunks WHERE id = ?')
            .get(r.chunkId) as { metadata_json: string } | undefined;
    
          let metadataBonus = 0;
          if (chunk?.metadata_json) {
            try {
              const meta = JSON.parse(chunk.metadata_json) as {
                toolCalls?: string[];
                filePaths?: string[];
              };
              if (meta.toolCalls && meta.toolCalls.length >= 3) metadataBonus += 0.2;
              if (meta.filePaths && meta.filePaths.length >= 2) metadataBonus += 0.1;
            } catch {
              // ignore parse error
            }
          }
    
          return {
            chunkId: r.chunkId,
            snippet: r.snippet,
            score: r.score + metadataBonus,
            metadataBonus,
            project: r.project,
            timestamp: r.timestamp,
            matchType: r.matchType,
            sessionId: r.sessionId,
          };
        });
    
        // Re-sort by adjusted score, take top limit
        enriched.sort((a, b) => b.score - a.score);
        return {
          content: [{ type: 'text' as const, text: JSON.stringify(enriched.slice(0, limit)) }],
        };
      },
    );
  • Schema definition for the inputs to the 'm9k_similar_work' tool.
    inputSchema: {
      description: z.string().describe('Description of the current task'),
      limit: z.number().int().min(1).max(20).default(5),
      source: z
        .enum(['conversations', 'git', 'files'])
        .optional()
        .describe('Filter by source type. Default: all sources.'),
    },
  • Registration block for the 'm9k_similar_work' tool within the server.
    server.registerTool(
      'm9k_similar_work',
      {
        description:
          "Find past work similar to what you're about to do. Use at the start of a complex task to see previous approaches. Unlike m9k_search, this prioritizes chunks with rich metadata (multiple tools used, multiple files touched).",
        inputSchema: {
          description: z.string().describe('Description of the current task'),
          limit: z.number().int().min(1).max(20).default(5),
          source: z
            .enum(['conversations', 'git', 'files'])
            .optional()
            .describe('Filter by source type. Default: all sources.'),
        },
        annotations: {
          readOnlyHint: true,
          destructiveHint: false,
          idempotentHint: true,
          openWorldHint: false,
        },
      },
      async ({ description, limit }) => {
        // Use the same search pipeline as m9k_search
        const results = await search(
          ctx.db,
          { query: description, limit: limit * 3 },
          ctx.searchContext,
        );
    
        // Apply metadata bonus scoring
        const enriched = results.map((r) => {
          const chunk = ctx.db
            .prepare('SELECT metadata_json FROM conv_chunks WHERE id = ?')
            .get(r.chunkId) as { metadata_json: string } | undefined;
    
          let metadataBonus = 0;
          if (chunk?.metadata_json) {
            try {
              const meta = JSON.parse(chunk.metadata_json) as {
                toolCalls?: string[];
                filePaths?: string[];
              };
              if (meta.toolCalls && meta.toolCalls.length >= 3) metadataBonus += 0.2;
              if (meta.filePaths && meta.filePaths.length >= 2) metadataBonus += 0.1;
            } catch {
              // ignore parse error
            }
          }
    
          return {
            chunkId: r.chunkId,
            snippet: r.snippet,
            score: r.score + metadataBonus,
            metadataBonus,
            project: r.project,
            timestamp: r.timestamp,
            matchType: r.matchType,
            sessionId: r.sessionId,
          };
        });
    
        // Re-sort by adjusted score, take top limit
        enriched.sort((a, b) => b.score - a.score);
        return {
          content: [{ type: 'text' as const, text: JSON.stringify(enriched.slice(0, limit)) }],
        };
      },
    );
Behavior4/5

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

Annotations cover read-only/idempotent safety properties. The description adds valuable behavioral context not in annotations: it discloses the prioritization algorithm (favors chunks with 'multiple tools used, multiple files touched') and reveals the unit of retrieval ('chunks'). This explains what makes results 'similar' beyond simple semantic matching.

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?

Three sentences efficiently structured: sentence 1 defines purpose, sentence 2 specifies timing/usage, sentence 3 differentiates from sibling. Zero wasted words. Information density is high with every sentence serving a distinct function.

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 (semantic similarity search) and lack of output schema, the description adequately covers the retrieval behavior and result prioritization logic. Annotations handle safety profile. Could improve by mentioning return format (chunk references? full content?), but sufficient for agent selection.

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?

Schema coverage is 67% (2 of 3 parameters described). The description focuses on tool purpose rather than parameter specifics. It implicitly references the 'description' parameter via 'what you're about to do' but does not add syntax guidance, validation rules, or semantic details for 'limit' or 'source' beyond the schema definitions. Appropriate baseline for >50% coverage.

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 'Find past work similar to what you're about to do' - specific verb (find) and resource (past work). It effectively distinguishes from sibling m9k_search by contrasting its prioritization logic ('Unlike m9k_search, this prioritizes chunks with rich metadata').

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 states when to use: 'Use at the start of a complex task to see previous approaches.' Also identifies the alternative tool (m9k_search) and explains the differentiation criteria (rich metadata vs. presumably standard search), providing clear guidance on selection.

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