Skip to main content
Glama
ai-yliu

Filesystem MCP Server

by ai-yliu

write_file

Create or overwrite a file by specifying the file path and content using the Filesystem MCP Server, enabling secure file management and modification.

Instructions

Create new file or overwrite existing

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesContent to write to the file
pathYesPath to the file to write

Implementation Reference

  • Handler for the 'write_file' tool. Extracts path and content, validates path, ensures parent directory exists, writes file using fs.writeFile, returns success message.
    case 'write_file': { const { path: filePath, content } = request.params.arguments as { path: string; content: string }; validatePath(filePath); // Ensure parent directory exists await fs.ensureDir(path.dirname(filePath)); await fs.writeFile(filePath, content, 'utf8'); return { content: [ { type: 'text', text: `File written successfully: ${filePath}`, }, ], }; }
  • src/index.ts:126-143 (registration)
    Tool registration in listTools handler, defining name, description, and input schema for 'write_file'.
    { name: 'write_file', description: 'Create new file or overwrite existing', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to the file to write', }, content: { type: 'string', description: 'Content to write to the file', }, }, required: ['path', 'content'], }, },

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/ai-yliu/filesystem-mcp-server'

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