read_file
View and access file contents from your local development projects directory to examine code, configuration files, and documentation.
Instructions
Read the contents of a file from the local file system. Use this to view existing code files.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the file (relative to projects directory or absolute) |
Implementation Reference
- index.js:215-226 (handler)The handler function that implements the core logic of the 'read_file' tool. It resolves the input path and reads the file contents using fs.promises.readFile, returning the content in the MCP format.async readFile(filePath) { const resolvedPath = this.resolvePath(filePath); const content = await fs.readFile(resolvedPath, 'utf-8'); return { content: [ { type: 'text', text: content, }, ], }; }
- index.js:50-59 (schema)JSON schema defining the input parameters for the 'read_file' tool, specifying a required 'path' string.inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to the file (relative to projects directory or absolute)', }, }, required: ['path'], },
- index.js:47-60 (registration)Registration of the 'read_file' tool in the ListToolsRequestSchema handler, including name, description, and schema.{ name: 'read_file', description: 'Read the contents of a file from the local file system. Use this to view existing code files.', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to the file (relative to projects directory or absolute)', }, }, required: ['path'], }, },
- index.js:205-213 (helper)Helper method used by read_file (and other tools) to resolve relative paths to absolute paths based on the PROJECTS_DIR.resolvePath(inputPath) { if (!inputPath || inputPath === '.') { return PROJECTS_DIR; } if (path.isAbsolute(inputPath)) { return inputPath; } return path.join(PROJECTS_DIR, inputPath); }
- index.js:163-164 (handler)Dispatch handler in the CallToolRequestSchema switch statement that routes 'read_file' calls to the readFile method.case 'read_file': return await this.readFile(args.path);