Skip to main content
Glama

create

Generate and write files with specific content to designated paths using structured input, ensuring controlled and secure file creation on the MCP server.

Instructions

Create a new file with specified content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_textYesContent to write to the file
pathYesAbsolute path where file should be created

Implementation Reference

  • The core handler function for the 'create' tool in the FileEditor class. It validates the path, writes the provided file_text to the path using writeFile utility, initializes and updates the file history, and returns a success message.
    async create(args: CreateArgs): Promise<string> { await validatePath('create', args.path); await writeFile(args.path, args.file_text); if (!this.fileHistory[args.path]) { this.fileHistory[args.path] = []; } this.fileHistory[args.path].push(args.file_text); return `File created successfully at: ${args.path}`; }
  • src/server.ts:63-80 (registration)
    Registration of the 'create' tool in the ListToolsRequestSchema handler, defining name, description, and input schema.
    { name: "create", description: "Create a new file with specified content", inputSchema: { type: "object", properties: { path: { type: "string", description: "Absolute path where file should be created" }, file_text: { type: "string", description: "Content to write to the file" } }, required: ["path", "file_text"] } },
  • src/server.ts:156-161 (registration)
    Dispatch logic in the CallToolRequestSchema handler for the 'create' tool: validates arguments using isCreateArgs and invokes the editor.create method.
    case "create": if (!request.params.arguments || !isCreateArgs(request.params.arguments)) { throw new ToolError("Invalid arguments for create command"); // Fixed } result = await this.editor.create(request.params.arguments); break;
  • TypeScript interface defining the input arguments for the 'create' tool.
    export interface CreateArgs extends Record<string, unknown> { path: string; file_text: string; }
  • Type guard function for validating 'create' tool arguments at runtime.
    export function isCreateArgs(args: Record<string, unknown>): args is CreateArgs { return typeof args.path === "string" && typeof args.file_text === "string"; }

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/arathald/mcp-editor'

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