Skip to main content
Glama
arathald

mcp-editor

by arathald

create

Create a new file with specified content at a designated path to enable file manipulation through client-approved operations.

Instructions

Create a new file with specified content

Input Schema

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

Implementation Reference

  • The primary handler function for the 'create' tool. It validates the path, writes the file content using writeFile, 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)
    Registers the 'create' tool in the MCP server's ListTools response, providing name, description, and JSON 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"]
        }
    },
  • 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 used to validate input arguments for the 'create' tool before execution.
    export function isCreateArgs(args: Record<string, unknown>): args is CreateArgs {
        return typeof args.path === "string" && typeof args.file_text === "string";
    }
  • Utility function called by the 'create' handler to validate the file path, ensuring it's absolute, not a directory, doesn't exist yet for create, etc.
    export async function validatePath(command: string, filePath: string): Promise<void> {
        const absolutePath = path.isAbsolute(filePath) ?
            filePath :
            path.join(process.cwd(), filePath);
    
        if (!path.isAbsolute(filePath)) {
            throw new ToolError(
                `The path ${filePath} is not an absolute path, it should start with '/'. Maybe you meant ${absolutePath}?`
            );
        }
    
        try {
            const stats = await fs.stat(filePath);
            if (stats.isDirectory() && command !== 'view') {
                throw new ToolError(
                    `The path ${filePath} is a directory and only the \`view\` command can be used on directories`
                );
            }
            if (command === 'create' && stats.isFile()) {
                throw new ToolError(
                    `File already exists at: ${filePath}. Cannot overwrite files using command \`create\``
                );
            }
        } catch (e: unknown) {
            const error = e instanceof Error ? e : new Error('Unknown error');
            if ('code' in error && error.code === 'ENOENT' && command !== 'create') {
                throw new ToolError(`The path ${filePath} does not exist. Please provide a valid path.`);
            }
            if (command !== 'create') {
                throw error;
            }
        }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool creates a file but doesn't mention critical behaviors like whether it overwrites existing files, requires specific permissions, handles errors, or what happens on success/failure. This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It's front-loaded with the core action, making it easy to parse quickly, and every part of the sentence contributes essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a file creation tool with no annotations and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., overwrite behavior, error handling), usage context compared to siblings, and expected outcomes, making it insufficient for safe and effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with clear descriptions for both parameters ('path' and 'file_text'). The description adds no additional semantic context beyond what the schema provides, such as file format expectations or path validation rules, so it meets the baseline score when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create a new file') and the resource ('with specified content'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'insert' or 'string_replace', which might also involve file content manipulation, so it doesn't reach the highest score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'insert' or 'string_replace'. It doesn't mention prerequisites, such as whether the path must exist or if it overwrites existing files, leaving the agent without contextual usage information.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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