Skip to main content
Glama
theburgerllc

AI Development Pipeline MCP

by theburgerllc

read_project_file

Access and read local files directly from the VS Code workspace, ensuring secure and directory-restricted file retrieval for streamlined development workflows.

Instructions

Read a local file from the VS Code workspace (restricted to workspace directory)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • Executes the tool logic: validates the input path using validatePath helper, reads the file synchronously with fs.readFileSync, and returns the content as MCP-formatted response or error message.
    async ({ path }) => { try { const safePath = validatePath(path); const content = fs.readFileSync(safePath, 'utf8'); return { content: [{ type: 'text', text: content }] }; } catch (err: any) { return { content: [{ type: 'text', text: `File read error: ${err.message}` }] }; } }
  • Zod schema for tool input parameters: requires a 'path' string.
    { path: z.string() },
  • Registers the 'read_project_file' tool on the McpServer instance with name, description, input schema, and inline handler function.
    server.tool( 'read_project_file', 'Read a local file from the VS Code workspace (restricted to workspace directory)', { path: z.string() }, async ({ path }) => { try { const safePath = validatePath(path); const content = fs.readFileSync(safePath, 'utf8'); return { content: [{ type: 'text', text: content }] }; } catch (err: any) { return { content: [{ type: 'text', text: `File read error: ${err.message}` }] }; } } );
  • Helper function to validate and resolve file paths, preventing directory traversal attacks by ensuring the path is within the WORKSPACE_ROOT.
    function validatePath(filePath: string): string { const resolvedPath = path.resolve(WORKSPACE_ROOT, filePath); if (!resolvedPath.startsWith(WORKSPACE_ROOT)) { throw new Error('Path traversal detected - access denied'); } return resolvedPath; }

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/theburgerllc/ai-development-pipeline-mcp'

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