read_context
Retrieve project documentation content from local markdown files by specifying project name and file path to access organized context information.
Instructions
Read the content of a specific context file within a project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_name | Yes | Name of the project | |
| file_path | Yes | Relative path to the file within the project (e.g., 'backend/gin.md') |
Implementation Reference
- src/index.ts:268-285 (handler)MCP tool handler for 'read_context': validates project_name and file_path arguments, calls readContext helper, and returns the file content as text.case "read_context": { const projectName = args.project_name as string; const filePath = args.file_path as string; if (!projectName || !filePath) { throw new Error("project_name and file_path are required"); } const content = await readContext(projectName, filePath); return { content: [ { type: "text", text: content, }, ], }; }
- src/index.ts:187-201 (schema)Input schema definition for the 'read_context' tool, specifying required project_name and file_path parameters.inputSchema: { type: "object", properties: { project_name: { type: "string", description: "Name of the project", }, file_path: { type: "string", description: "Relative path to the file within the project (e.g., 'backend/gin.md')", }, }, required: ["project_name", "file_path"], },
- src/index.ts:73-87 (helper)Helper function that reads the content of a specific context file, including path security validation to prevent directory traversal.async function readContext( projectName: string, filePath: string ): Promise<string> { const fullPath = path.join(CONTEXT_DIR, projectName, filePath); // Security check: ensure path is within context directory const resolvedPath = path.resolve(fullPath); const resolvedContextDir = path.resolve(CONTEXT_DIR); if (!resolvedPath.startsWith(resolvedContextDir)) { throw new Error("Invalid path: outside context directory"); } return await fs.readFile(fullPath, "utf-8"); }
- src/index.ts:183-202 (registration)Tool registration in the list_tools response, including name, description, and schema.{ name: "read_context", description: "Read the content of a specific context file within a project", inputSchema: { type: "object", properties: { project_name: { type: "string", description: "Name of the project", }, file_path: { type: "string", description: "Relative path to the file within the project (e.g., 'backend/gin.md')", }, }, required: ["project_name", "file_path"], }, },