Skip to main content
Glama

get_related_docs

Identify related documentation files by analyzing metadata from a specified project path and document file to enhance knowledge retrieval and organization.

Instructions

Find related documentation files based on metadata

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
docFileYesName of the documentation file
projectPathYesPath to the project root directory

Implementation Reference

  • MCP tool handler case that parses input arguments, calls the findRelatedDocs helper, and returns related documentation files with metadata.
    case "get_related_docs": {
      const { projectPath, docFile } = request.params.arguments as {
        projectPath: string;
        docFile: string;
      };
    
      try {
        const related = await findRelatedDocs(docFile, projectPath);
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({
                file: docFile,
                relatedDocs: related,
                metadata: state.metadata[docFile]
              }, null, 2)
            }
          ]
        };
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        throw new McpError(
          ErrorCode.InternalError,
          `Error finding related docs: ${errorMessage}`
        );
      }
    }
  • Input schema defining projectPath and docFile parameters for the tool.
    inputSchema: {
      type: "object",
      properties: {
        projectPath: {
          type: "string",
          description: "Path to the project root directory"
        },
        docFile: {
          type: "string",
          description: "Name of the documentation file"
        }
      },
      required: ["projectPath", "docFile"]
    }
  • src/index.ts:557-574 (registration)
    Tool registration in the ListTools response, including name, description, and schema.
    {
      name: "get_related_docs",
      description: "Find related documentation files based on metadata",
      inputSchema: {
        type: "object",
        properties: {
          projectPath: {
            type: "string",
            description: "Path to the project root directory"
          },
          docFile: {
            type: "string",
            description: "Name of the documentation file"
          }
        },
        required: ["projectPath", "docFile"]
      }
    },
  • Core helper function that implements the logic to find related docs by matching tags, category, and wiki-style links in content.
    const findRelatedDocs = async (docFile: string, projectPath: string): Promise<string[]> => {
      const metadata = state.metadata[docFile];
      if (!metadata) return [];
    
      const related = new Set<string>();
    
      // Find docs with matching tags
      Object.entries(state.metadata).forEach(([file, meta]) => {
        if (file !== docFile && meta.tags.some(tag => metadata.tags.includes(tag))) {
          related.add(file);
        }
      });
    
      // Find docs in same category
      Object.entries(state.metadata).forEach(([file, meta]) => {
        if (file !== docFile && meta.category === metadata.category) {
          related.add(file);
        }
      });
    
      // Find docs referenced in content
      const content = await fs.readFile(`${projectPath}/.handoff_docs/${docFile}`, 'utf8');
      const matches = content.match(/\[\[([^\]]+)\]\]/g) || [];
      matches.forEach(match => {
        const linkedDoc = match.slice(2, -2).trim() + '.md';
        if (DEFAULT_DOCS.includes(linkedDoc)) {
          related.add(linkedDoc);
        }
      });
    
      return Array.from(related);
    };
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'Find related documentation files' but doesn't explain what 'related' entails, whether this is a read-only operation, how results are returned, or any constraints like rate limits or permissions. For a tool with no annotation coverage, this is a significant gap in transparency.

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 a single, efficient sentence that states the core function without unnecessary words. It's front-loaded with the main action ('Find related documentation files'), but it could be slightly more structured by clarifying the scope or output. Overall, it's concise and earns its place, though not perfectly optimized.

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

Completeness2/5

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

Given the tool's complexity (finding related files based on metadata), lack of annotations, no output schema, and multiple sibling tools, the description is incomplete. It doesn't explain what 'related' means, how metadata is used, or what the return format is, leaving critical gaps for an agent to use it correctly in context.

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 input schema has 100% description coverage, with clear documentation for both parameters ('docFile' and 'projectPath'). The description adds no additional meaning beyond what the schema provides, such as explaining how these parameters interact or what 'metadata' refers to. Baseline 3 is appropriate since the schema does the heavy lifting.

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

Purpose3/5

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

The description states the tool's purpose ('Find related documentation files') and mentions the mechanism ('based on metadata'), which is more specific than just restating the name. However, it doesn't clearly distinguish this from sibling tools like 'search_docs' or 'get_doc_content'—it's vague about what 'related' means or how metadata is used, leaving ambiguity about its unique role.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'search_docs' and 'analyze_existing_docs', there's no indication of context, prerequisites, or exclusions. This leaves the agent to guess based on the name alone, which is insufficient for effective tool 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

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/ryanjoachim/mcp-rtfm'

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