Skip to main content
Glama
talentedmrweb

Local Dev Bridge MCP

edit_file

Replace specific text in local development files by matching exact content, enabling precise file modifications for coding tasks.

Instructions

Edit a file by replacing specific text. The old_text must match exactly (including whitespace).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the file
old_textYesText to find and replace (must match exactly)
new_textYesText to replace it with

Implementation Reference

  • The handler function that implements the logic for the 'edit_file' tool: reads the file, checks if old_text exists, replaces it with new_text, and writes the file back.
    async editFile(filePath, oldText, newText) {
      const resolvedPath = this.resolvePath(filePath);
      let content = await fs.readFile(resolvedPath, 'utf-8');
      
      if (!content.includes(oldText)) {
        throw new Error(`Text not found in file: ${oldText.substring(0, 50)}...`);
      }
      
      content = content.replace(oldText, newText);
      await fs.writeFile(resolvedPath, content, 'utf-8');
      
      return {
        content: [
          {
            type: 'text',
            text: `File edited successfully: ${resolvedPath}`,
          },
        ],
      };
    }
  • index.js:79-100 (registration)
    Registration of the 'edit_file' tool in the ListTools response, including name, description, and input schema.
    {
      name: 'edit_file',
      description: 'Edit a file by replacing specific text. The old_text must match exactly (including whitespace).',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: 'Path to the file',
          },
          old_text: {
            type: 'string',
            description: 'Text to find and replace (must match exactly)',
          },
          new_text: {
            type: 'string',
            description: 'Text to replace it with',
          },
        },
        required: ['path', 'old_text', 'new_text'],
      },
    },
  • The switch case in the CallToolRequestHandler that dispatches 'edit_file' calls to the editFile method.
    case 'edit_file':
      return await this.editFile(args.path, args.old_text, args.new_text);
  • The input schema defining the parameters for the 'edit_file' tool.
    inputSchema: {
      type: 'object',
      properties: {
        path: {
          type: 'string',
          description: 'Path to the file',
        },
        old_text: {
          type: 'string',
          description: 'Text to find and replace (must match exactly)',
        },
        new_text: {
          type: 'string',
          description: 'Text to replace it with',
        },
      },
      required: ['path', 'old_text', 'new_text'],
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It adds some context: 'The old_text must match exactly (including whitespace),' which clarifies a constraint. However, it lacks details on permissions, error handling, or what happens if the text isn't found, which are critical for a mutation tool. This leaves significant gaps in understanding the tool's behavior.

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 extremely concise and front-loaded: the first sentence states the core purpose, and the second adds a critical constraint. There is no wasted language, and every sentence earns its place by providing essential information efficiently.

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?

Given the complexity of a file-editing mutation tool with no annotations and no output schema, the description is incomplete. It covers the basic operation and a constraint but omits details on permissions, side effects, error cases, and return values. This makes it inadequate for safe and effective use by an AI agent without additional context.

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%, so the schema already documents all three parameters. The description reinforces the exact match requirement for 'old_text' but doesn't add new semantic details beyond what's in the schema. With high schema coverage, the baseline is 3, as the description provides minimal additional value.

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 tool's purpose: 'Edit a file by replacing specific text.' It specifies the verb ('edit') and resource ('file') with the operation ('replacing specific text'). However, it doesn't explicitly distinguish this from sibling tools like 'write_file' or 'search_files', which might have overlapping functionality, 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. It doesn't mention sibling tools like 'write_file' (which might overwrite entire files) or 'search_files' (which might find text without editing), nor does it specify prerequisites or exclusions. The agent must infer usage from the purpose alone.

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/talentedmrweb/local-dev-bridge-mcp'

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