Skip to main content
Glama

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
NameRequiredDescriptionDefault
project_nameYesName of the project
file_pathYesRelative path to the file within the project (e.g., 'backend/gin.md')

Implementation Reference

  • 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, }, ], }; }
  • 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"], },
  • 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"], }, },

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/doko89/mcp-mycontext'

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