Skip to main content
Glama
theburgerllc

AI Development Pipeline MCP

by theburgerllc

check_file_exists

Verify whether a specific file exists within your workspace directory to prevent errors in development workflows.

Instructions

Check if a local file exists (restricted to workspace directory)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • The main handler function for the 'check_file_exists' tool. It validates the input path using validatePath, then uses fs.existsSync to check if the file exists, returning a text response indicating existence or not.
    async ({ path }) => { try { const safePath = validatePath(path); const exists = fs.existsSync(safePath); return { content: [{ type: 'text', text: exists ? 'File exists' : 'File does not exist' }] }; } catch (err: any) { return { content: [{ type: 'text', text: `File check error: ${err.message}` }] }; } }
  • Registration of the 'check_file_exists' tool on the MCP server, including name, description, schema, and handler.
    server.tool( 'check_file_exists', 'Check if a local file exists (restricted to workspace directory)', { path: z.string() }, async ({ path }) => { try { const safePath = validatePath(path); const exists = fs.existsSync(safePath); return { content: [{ type: 'text', text: exists ? 'File exists' : 'File does not exist' }] }; } catch (err: any) { return { content: [{ type: 'text', text: `File check error: ${err.message}` }] }; } } );
  • Input schema for the tool: requires a 'path' parameter as a string, validated with Zod.
    { path: z.string() },
  • Helper function used by the tool to validate and resolve the file path, preventing path traversal attacks by ensuring it stays 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; }

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