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

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

Input Schema (JSON Schema)

{ "properties": { "docFile": { "description": "Name of the documentation file", "type": "string" }, "projectPath": { "description": "Path to the project root directory", "type": "string" } }, "required": [ "projectPath", "docFile" ], "type": "object" }

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); };

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