Repository avatar
Other Tools
v1.0.3
active

edit-mcp

io.github.FgsiDev/edit-mcp

MCP server for editing and managing code.

Documentation

edit-mcp

Local MCP server and CLI for editing files. One C++17 binary, zero dependencies, no build step beyond make.

Credit: FgsiDev — https://github.com/FgsiDev

Build

make            # ./edit-mcp
make install    # /usr/local/bin/edit-mcp (PREFIX=... to change)
# or: cmake -B build && cmake --build build

Termux (from source): pkg install clang make git && make CXX=clang++.

Install a release binary

Tagging vX.Y.Z builds binaries via GitHub Actions and attaches them to the release with SHA256SUMS: linux-x64 and linux-arm64 (static glibc), macos-arm64, and android-arm64 (Android NDK, bionic). Termux needs the android build: static glibc binaries are killed by Android's seccomp filter (Bad system call).

curl -fsSL https://raw.githubusercontent.com/FgsiDev/edit-mcp/main/install.sh | sh

install.sh picks the right asset, installs to $PREFIX/bin (Termux), /usr/local/bin or ~/.local/bin, and prints the MCP config. Override with EDIT_MCP_REPO and EDIT_MCP_VERSION.

Use as MCP

edit-mcp with no arguments speaks MCP over stdio. edit-mcp config prints the config for this binary (absolute path filled in):

edit-mcp config                    # opencode format
edit-mcp config --agent claude     # mcpServers JSON: Claude Code (.mcp.json), Cursor, Gemini CLI, ...
edit-mcp config --agent codex      # TOML for ~/.codex/config.toml
edit-mcp config --root ~/project --name edit

opencode (opencode.json):

{
  "mcp": {
    "servers": {
      "edit": {
        "type": "local",
        "command": ["/path/to/edit-mcp"]
      }
    }
  }
}

Claude Code: claude mcp add edit -- /path/to/edit-mcp. Codex: add to ~/.codex/config.toml:

[mcp_servers.edit]
command = "/path/to/edit-mcp"

Agents without MCP support (pi, as far as I know) use the CLI through their shell; the skill below teaches both.

Add "--root", "/dir" to command to confine every path to that directory (symlinks resolved). Without --root, paths are relative to the working directory, absolute, or ~/....

Agent skill

The skill (SKILL.md, the shared Agent Skills format) teaches an agent which tool to pick, the coordinate rules, the indentation behaviour, recipes (insert, append, delete, regex, batch) and the CLI fallback. It is embedded in the binary:

edit-mcp install-skill                  # ~/.claude/skills/edit-mcp + ~/.agents/skills/edit-mcp
edit-mcp install-skill --project        # same, inside the current project
edit-mcp install-skill --target claude  # or: agents
edit-mcp install-skill --dir ~/my/skills
edit-mcp skill > SKILL.md               # print it
agentreads the skill from
Claude Code~/.claude/skills/, .claude/skills/
opencode~/.agents/skills/, .agents/skills/ (also ~/.claude/skills/, .claude/skills/)
Codex~/.agents/skills/, .agents/skills/
pi~/.agents/skills/, .agents/skills/ (also ~/.pi/agent/skills/, .pi/skills/)

--target all (default) writes both .claude and .agents, which covers all four. For agents without skill support (Cursor rules, Gemini CLI, Aider, ...), paste the body of skills/edit-mcp/SKILL.md into AGENTS.md / GEMINI.md / the rules file.

skills/edit-mcp/SKILL.md in this repo is generated from the binary (make skill); the source of truth is src/skill.hpp.

Tools

All line/column numbers are 1-based. Columns count characters, not bytes.

toolwhat
replace_contentsearch/replace. Literal by default, regex for ECMAScript with $1/$&. All matches unless all:false or occurrence:N.
replace_linesreplace startLine..endLine (default one line) with content. The indentation of the replaced line is applied automatically; relative indentation inside multi-line content is kept. keepIndent:false replaces the whitespace too.
delete_linesdelete startLine..endLine including the newline (no blank line left).
replace_rangereplace by position: line + from, ending at to (inclusive column), length, or endLine + to. Without endLine, to counts from the line start and runs through newlines into following lines. length:0 inserts.
multi_replacemany edits (content / lines / range mixed, several files). Every coordinate refers to the file before the call, so edits never shift each other. Per file all-or-nothing. Overlaps are rejected.
get_contentfind with line:col, captures, context lines.
get_linesread lines with numbers (raw for plain).
get_rangeread a character range with coordinates.
multi_getmany reads in one call.

Every write tool accepts dryRun and returns a before/after diff. CRLF line endings and BOM are preserved. Writes are atomic (temp file + rename). Binary and non-UTF-8 files are refused.

Regex: patterns match per line by default; flags:"s" runs the pattern over the whole file so it can span lines.

CLI

edit-mcp replace-content app.js 'const ee = require("path")' 'const path = require("path")'
edit-mcp replace-content app.js 'ee' 'path' --first -n          # dry run
edit-mcp replace-content app.js 'foo(\d+)' 'bar_$1' -r
edit-mcp replace-lines   app.js 2 'console.log("fgsi")'          # indent follows line 2
edit-mcp replace-lines   app.js 2-4 -e 'a()\nb()'                # -e: \n \t escapes
edit-mcp delete-lines    app.js 10-12
edit-mcp replace-range   app.js 1:5-8 renamed                    # line 1, cols 5..8
edit-mcp replace-range   app.js 1:5-3:2 x                        # line 1 col 5 .. line 3 col 2
edit-mcp replace-range   app.js 1:1 --length 0 'HEAD '           # insert
edit-mcp get-lines       app.js 10-20
edit-mcp get-content     app.js 'TODO' --context 2
edit-mcp get-range       app.js 1:5-8
edit-mcp multi-replace   edits.json                              # or: ... | edit-mcp multi-replace -
cat new.txt | edit-mcp replace-lines app.js 5-9 --stdin

edits.json:

[
  {"path": "app.js", "type": "content", "search": "ee", "replace": "path"},
  {"path": "app.js", "type": "lines", "startLine": 3, "endLine": 4, "content": "run()"},
  {"path": "app.js", "type": "range", "line": 5, "from": 5, "to": 8, "content": "x"}
]

Exit codes: 0 ok, 1 edit failed, 2 usage error. Run edit-mcp --help for all options.

No installation packages available.