Skip to main content
Glama

mcp-wcgw

Apache 2.0
510
  • Apple
  • Linux

FileWriteOrEdit

Write or edit files on the MCP server by specifying the percentage of changes needed. Use search/replace blocks for minor edits or provide full content for major updates, ensuring precise file modifications.

Instructions

  • Writes or edits a file based on the percentage of changes.
  • Use absolute path only (~ allowed).
  • First write down percentage of lines that need to be replaced in the file (between 0-100) in percentage_to_change
  • percentage_to_change should be low if mostly new code is to be added. It should be high if a lot of things are to be replaced.
  • If percentage_to_change > 50, provide full file content in text_or_search_replace_blocks
  • If percentage_to_change <= 50, text_or_search_replace_blocks should be search/replace blocks.

Instructions for editing files.

Example

Input file

import numpy as np from impls import impl1, impl2 def hello(): "print a greeting" print("hello") def call_hello(): "call hello" hello() print("Called") impl1() hello() impl2()

Edit format on the input file

<<<<<<< SEARCH from impls import impl1, impl2 ======= from impls import impl1, impl2 from hello import hello as hello_renamed >>>>>>> REPLACE <<<<<<< SEARCH def hello(): "print a greeting" print("hello") ======= >>>>>>> REPLACE <<<<<<< SEARCH def call_hello(): "call hello" hello() ======= def call_hello_renamed(): "call hello renamed" hello_renamed() >>>>>>> REPLACE <<<<<<< SEARCH impl1() hello() impl2() ======= impl1() hello_renamed() impl2() >>>>>>> REPLACE

SEARCH/REPLACE block Rules:

  • Every "SEARCH" section must EXACTLY MATCH the existing file content, character for character, including all comments, docstrings, whitespaces, etc.
  • In a single call the edit blocks should be constructed from top to bottom of the file in a sequence.
  • An edit block can't edit over a previous edit in the same tool call.
  • Including multiple unique SEARCH/REPLACE blocks if needed.
  • Include enough and only enough lines in each SEARCH section to uniquely match each set of lines that need to change.
  • Keep SEARCH/REPLACE blocks concise.
  • Break large SEARCH/REPLACE blocks into a series of smaller blocks that each change a small portion of the file.
  • Include just the changing lines, and a few surrounding lines (0-3 lines) if needed for uniqueness.
  • Other than for uniqueness, avoid including those lines which do not change in search (and replace) blocks. Target 0-3 non trivial extra lines per block.
  • Preserve leading spaces and indentations in both SEARCH and REPLACE blocks.

Input Schema

NameRequiredDescriptionDefault
file_pathYes#1: absolute file path
percentage_to_changeYes#2: predict this percentage, calculated as number of existing lines that will have some diff divided by total existing lines.
text_or_search_replace_blocksYes#3: content/edit blocks. Must be after #2 in the tool xml
thread_idYes#4: thread_id

Input Schema (JSON Schema)

{ "additionalProperties": false, "properties": { "file_path": { "description": "#1: absolute file path", "title": "File Path", "type": "string" }, "percentage_to_change": { "description": "#2: predict this percentage, calculated as number of existing lines that will have some diff divided by total existing lines.", "title": "Percentage To Change", "type": "integer" }, "text_or_search_replace_blocks": { "description": "#3: content/edit blocks. Must be after #2 in the tool xml", "title": "Text Or Search Replace Blocks", "type": "string" }, "thread_id": { "description": "#4: thread_id", "title": "Thread Id", "type": "string" } }, "required": [ "file_path", "percentage_to_change", "text_or_search_replace_blocks", "thread_id" ], "title": "FileWriteOrEdit", "type": "object" }
Install Server

Other Tools from mcp-wcgw

Related Tools

    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/rusiaaman/wcgw'

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