Skip to main content
Glama
theburgerllc

AI Development Pipeline MCP

by theburgerllc

write_project_file

Write content to a local file within the VS Code workspace directory, ensuring restricted file operations for secure project development.

Instructions

Write to a local file in the VS Code workspace (restricted to workspace directory)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes
pathYes

Implementation Reference

  • The handler function for the 'write_project_file' tool. It validates the file path for security, writes the provided content to the file using fs.writeFileSync, and returns a success or error message.
    async ({ path, content }) => { try { const safePath = validatePath(path); fs.writeFileSync(safePath, content, 'utf8'); return { content: [{ type: 'text', text: `File written: ${path}` }] }; } catch (err: any) { return { content: [{ type: 'text', text: `File write error: ${err.message}` }] }; } }
  • Registers the 'write_project_file' tool with the MCP server, including name, description, input schema, and handler function.
    server.tool( 'write_project_file', 'Write to a local file in the VS Code workspace (restricted to workspace directory)', { path: z.string(), content: z.string() }, async ({ path, content }) => { try { const safePath = validatePath(path); fs.writeFileSync(safePath, content, 'utf8'); return { content: [{ type: 'text', text: `File written: ${path}` }] }; } catch (err: any) { return { content: [{ type: 'text', text: `File write error: ${err.message}` }] }; } } );
  • Zod schema defining the input parameters: path (string) and content (string).
    { path: z.string(), content: z.string() },
  • Helper function used by the tool to validate and resolve the file path, preventing path traversal attacks.
    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