fedit MCP server
Commit Nov 6, 2026Performs surgical file edits including inserting, replacing, moving, and copying content with built-in verification and streaming support.
Also known as amalexico/fedit
- Stars
- 12
- Tools
- —
- Downloads, 30 days
- —
- Latest version
- 1.12.0
- Last commit
- Nov 6, 2026
- License
- MIT
What is fedit MCP?
fedit performs surgical file edits including inserting, replacing, moving, and copying content with built-in verification and streaming support.
Summary generated from the project's README
About fedit MCP server
Sysadmins and DevOps engineers can perform precise file modifications using fedit, a zero-dependency CLI tool designed for surgical edits. Instead of relying on complex regex or interactive editors, users can execute specific operations like inserting, replacing, moving, or copying content within configuration files and scripts. The tool supports both single files and multiple files via comma-separated lists or globs, making it ideal for managing large-scale environment changes.
Users interact with the tool through specific operations such as show, find, insertafter, and replaceall. For massive datasets, the stream engine allows processing multi-GB files line-by-line without exhausting system memory. To ensure reliability, the server includes built-in verification that re-reads files after a mutation to confirm the change was successful. It also provides specialized features like field extraction for CSV or TSV files and hex-encoded input to bypass shell quoting issues.
What you can do with it
- 1Update configuration valuesReplace a specific line in a configuration file with a new setting while verifying the change.
- 2Extract data from delimited filesPull a specific column from a TSV or CSV file for data processing.
- 3Batch update multiple filesApply a text replacement across all files matching a specific pattern.
Written from the project's README. Every use case is checked against a quote from it.
Automated checks
Ran Nov 14, 2026Full report →Not verified yet. A server needs a score of 80, no serious finding, and enough data for us to check. How checks work · What to fix for more points
- Source repository linked and reachableamalexico/fedit is public and reachablegithub.com/amalexico/fedit ↗Pass
- Package names this repository as its sourceNot checked
- Build provenance (Sigstore attestation)Not checked
- Open source license (OSI)MITspdx.org/licenses/MIT.html ↗Pass
- Commit or release in the last yearLast commit or release 2026-11-06github.com/amalexico/fedit ↗Pass
- OpenSSF ScorecardNot checked
- Package name not close to a popular packageNot checked
- No critical advisory in the package or its dependenciesNot checked
- No hidden instructions to the model0 tool descriptions and the README read; no override phrases, credential paths or hidden charactersPass
- Destructive tools are labelledNot checked
- Remote endpoint answers the MCP handshakeNot checked
README
View on GitHubfedit — Fast File Editor for the Terminal
A zero-dependency CLI tool for surgical file edits from the command line. No interactive editors. No sed/awk gymnastics. Just simple, predictable operations with built-in verification.
Built for sysadmins, DevOps engineers, and anyone who scripts config changes.

go install github.com/amalexico/fedit@latest
Why fedit?
- One binary, zero dependencies — pure Go, runs everywhere
- 21 language mappers — see the structure of any file before editing
- -v flag — verify every mutation before moving on
- Line-aware — no regex surprises, no "which match did it hit?"
- Stream engine — process multi-GB files line-by-line with atomic integrity
- Field extraction — pull CSV/TSV column N without awk
- Many files at once — a comma list or glob in -file, plus cross-file copy, move and replace with -dest (since v1.9.0)
- Safe — no in-place unless you say so, never touches files you did not name
Install
Go install (recommended):
go install github.com/amalexico/fedit@latest
Or download the binary from GitHub Releases and put it in your PATH.
Verify:
fedit -file /etc/hostname -op show
Quick Start
# See what is in a file
fedit -file config.yaml -op show
# See just lines 10-25
fedit -file config.yaml -op show -line 10 -end 25
# Find every line containing "timeout"
fedit -file config.yaml -op find -match "timeout"
# See the structure of a Go file
fedit -file main.go -op map -lang go
# Replace line 42 with new content
fedit -file config.yaml -op replace -line 42 -end 42 -text "timeout: 60s" -v
# Insert a line after every occurrence of "server {"
fedit -file nginx.conf -op insertafter -match "server {" -text " include security.conf;" -v
# Move a function block before another (content-matched, atomic)
fedit -file main.go -op move -match "func OldHelper(" -end 45 -beforematch "func NewHelper(" -v
# Copy a config block and paste it 3 times at a new location
fedit -file values.yaml -op copy -line 50 -end 65 -after 200 -times 3 -v
# Extract column 2 from a TSV file (v1.4+)
fedit -file data.tsv -op fields -col 2
# Write content with literal backslashes — no \n escape expansion (v1.6.0)
fedit -file config.txt -op writeraw -text "path=C:\\Users\\admin"
# Hex-encode tricky text to sidestep shell quoting (v1.6.0)
# fwencode produces the hex; fedit decodes it before writing
fedit -file config.txt -op write -texthex 706174683d2f746d70
# Overwrite a file cleanly then insert new content (v1.6.0)
fedit -file config.txt -op insert -line 0 -cleanfirst -text "# regenerated"
# Get bare line numbers for scripting (v1.6.0)
fedit -file main.go -op find -match "TODO" -x 2>$null
# Regex replace on a multi-GB log without loading it into memory (v1.4+)
fedit -file huge.log -op replaceall -match 'ERROR' -text 'WARN' -stream
All Operations
show — Display file contents
# Entire file
fedit -file app.conf -op show
# Lines 50-75 only
fedit -file app.conf -op show -line 50 -end 75
# Last 10 lines
fedit -file app.conf -op show -line -10:
# Lines 50 to 5th from end
fedit -file app.conf -op show -line 50 -end -5
# Lines 100-103 (relative range)
fedit -file app.conf -op show -line 100:+3
# Show from one anchor to another (no line numbers needed)
fedit -file config.go -op show -match "func Start" -endmatch "func End"
find — Search for lines matching a substring
# Find all lines containing "ERROR"
fedit -file /var/log/app.log -op find -match "ERROR"
# Output includes context lines and occurrence numbers
# Use -nth to target a specific match in other operations
Pro tip: Run find first to get line numbers, then use replace or delete with exact lines.
insert — Insert content after a line number
# Insert a comment after line 1
fedit -file script.sh -op insert -line 1 -text "# Added by deploy script" -v
# Insert multiple lines from a file
fedit -file config.yaml -op insert -line 10 -textfile extra-config.yaml -v
insertafter — Insert after a matching line (RECOMMENDED)
# Add a firewall rule after the matching comment
fedit -file iptables.rules -op insertafter -match "# Custom rules" -text "-A INPUT -p tcp --dport 8080 -j ACCEPT" -v
# Target the 2nd occurrence
fedit -file nginx.conf -op insertafter -match "server {" -nth 2 -text " listen 8443 ssl;" -v
# Target the last occurrence
fedit -file docker-compose.yml -op insertafter -match "volumes:" -nth -1 -text " - /data:/data" -v
insertbefore — Insert before a matching line (RECOMMENDED)
# Add a header before the first route definition
fedit -file routes.rb -op insertbefore -match "get '/'" -text " # === Public Routes ===" -v
# Insert a dependency before the closing bracket
fedit -file package.json -op insertbefore -match "}" -nth -1 -textfile new-deps.txt -v
replace — Replace a line range with new content
# Replace a single line
fedit -file config.ini -op replace -line 15 -end 15 -text "max_connections = 200" -v
# Replace the one line that contains a text (no end bound needed; after v1.12.0)
fedit -file config.ini -op replace -match "max_connections" -text "max_connections = 200" -v
# Replace from a matched line through line 35 (-match with -end; after v1.12.0)
fedit -file server.conf -op replace -match "[cache]" -end 35 -textfile patched-block.txt -v
# Replace lines 30-35 with content from a patch file
fedit -file server.conf -op replace -line 30 -end 35 -textfile patched-block.txt -v
# Replace a section by content anchors (no line numbers needed)
fedit -file CHANGELOG.md -op replace -match "## v1.6" -endmatch "## v1.5" -textfile new-section.txt -v
replaceall — Global find-and-replace
# Change all occurrences of old domain to new
fedit -file nginx.conf -op replaceall -match "old.example.com" -text "new.example.com" -v
# Update a version string everywhere
fedit -file Makefile -op replaceall -match "1.1.0" -text "1.2.0" -v
- Every replaceall is verified by default: after the write, fedit re-reads the file from disk and prints
VERIFY: PASSorVERIFY: FAILfollowed by the changed lines. This covers a single file,-match-regex,-stream,-filesand a file list in-file, andfedit_replaceallover MCP.-vadds a context window for every match (not printed with-stream). - Exit codes for replaceall: 0 ok, 1 the edit did not happen, 3 the file was written but verification failed or could not be done. With several files, one FAIL file makes the exit code 3 even when the others succeeded, and the MCP result is an error.
-files GLOBprints the same per-file report as a file list in-file: one OK, SKIP or FAIL line per file, thenmulti -file replaceall: N/M file(s) succeeded. An OK line readsOK PATH replaced on N line(s); VERIFY: PASS, a file without the text is a SKIP (No lines contain: TEXT) and is never modified. Exit code 0 if at least one file succeeded and none failed (SKIP files do not change that), 1 if none succeeded, 3 if any file is FAIL.
fields -- Extract a column from delimited files (v1.4.0)
# Extract column 2 from a tab-separated file (default delimiter: tab)
fedit -file data.tsv -op fields -col 2
# Extract the third field from a CSV
fedit -file report.csv -op fields -col 3 -delim ","
# Extract usernames from /etc/passwd (colon-delimited)
fedit -file /etc/passwd -op fields -col 1 -delim ":"
Output goes to stdout for piping. Lines shorter than -col are skipped silently.
Always streaming -- no memory limit regardless of file size.
-stream -- Large-file streaming mode (v1.4.0)
Add -stream to replaceall or find to process files line-by-line without
loading them into memory. 10 MB per-line buffer handles JSON blobs and minified files.
Atomic integrity: writes to a temp file then renames -- original is untouched on interruption.
# Replace a pattern in a multi-GB log file
fedit -file server.log -op replaceall -match "10.0.0.1" -text "10.0.0.2" -stream
# Regex replace in a huge file with capture groups
fedit -file big.csv -op replaceall -match-regex 'id_(\d+)' -text 'ID_$1' -stream
# Streaming find -- grep-style output to stdout
fedit -file huge.log -op find -match "FATAL" -stream
Supported with -stream: replaceall (literal and regex), find.
Not supported: move, copy, map (these require full file structure in memory).
writeraw — Write without escape expansion
# Write a Windows path without double-escaping backslashes
fedit -file config.ini -op writeraw -text "basedir=C:\\Program Files\\App"
# Write content from a file as-is
fedit -file output.txt -op writeraw -textfile template.txt
Unlike write, writeraw treats \n as two characters (backslash + n), not a newline.
writelines — Write lines interactively from stdin
fedit -file notes.txt -op writelines
# Type lines at the > prompt, Ctrl+Z (Windows) or Ctrl+D (Unix) to finish
-texthex — Hex-encoded input (v1.6.0)
Encode text to hex first (e.g. with fwencode), then pass the hex string as -text.
Eliminates all shell-quoting issues with special characters.
# Decode hex string and write — no quoting gymnastics needed
fedit -file deploy.sh -op write -texthex 23212f62696e2f62617368
-matchhex / -endmatchhex — Hex-encoded anchors (v1.8.1)
Same idea as -texthex, but for the search anchors. PowerShell mangles a double quote
inside -match before fedit sees it, so case "replace": silently becomes case replace:
and matches nothing. Pass the anchor as hex instead; fedit decodes it into -match
(or -endmatch) once, so every op that takes an anchor works unchanged.
# Find a line containing double quotes (hex of: case "replace":)
fedit -file main.go -op find -matchhex 6361736520227265706c616365223a
Invalid hex exits 1 with matchhex: invalid hex string: ... (or endmatchhex: ...).
Multiple files -- comma list or glob (show/find/map since v1.8.1, mutation and MCP since v1.9.0, -sourcefile and -sourceblock with a list since v1.11.0)
-file accepts a comma-separated list, a glob, or both. A real file with that exact name wins over glob expansion.
Read-only ops (show, find, map) print a ==> path <== header per file:
# Find TODO in every Go file in the current folder
fedit -file '*.go' -op find -match 'TODO'
# Map two files at once
fedit -file main.go,mcp.go -op map -lang go
- find skips files with no hits (grep-style) and exits 1 only if nothing matched in any file.
- map skips unrecognized extensions with a SKIP line.
- A summary line reports how many files had results.
Mutating ops (replaceall, insertafter, insertbefore, delete, replace, write) run on each file on its own:
# Replace in every matching file
fedit -file '*.conf' -op replaceall -match 'old.example.com' -text 'new.example.com'
# Insert after the first match in each file
fedit -file a.yaml,b.yaml -op insertafter -match 'servers:' -text ' - new'
# Delete from a start line through an end line in each file (-endmatch is inclusive)
fedit -file '*.md' -op delete -match '<!-- start -->' -endmatch '<!-- end -->'
- A problem in one file (no match, unreadable, read-only, write failed) is reported as SKIP and never stops the batch. A skipped file is never modified.
- The report lists OK, SKIP or FAIL per file, then
N/M file(s) succeeded. A FAIL is a replaceall file that was written but did not pass the on-disk verification. Exit code 0 if at least one file succeeded and none failed, 1 if none succeeded, 3 if any file is FAIL (FAIL wins). - Only -match (plus -endmatch for delete and replace), -nth and -text/-textfile/-texthex are accepted, plus -sourcefile/-sourceblock/-lang on insertafter and insertbefore (since v1.11.0). -match-regex works with replaceall, and write needs no -match and writes the same content to every file. -block, -line, -end, -cleanfirst, -stream and -files are rejected (use -endmatch for a range), and so are move and copy, all before any file is read.
- MCP: fedit_replaceall, fedit_insertafter, fedit_insertbefore, fedit_delete and fedit_replace take a comma list or glob in file, with the same rules and a per-file report; block, line, end, stream and files are rejected. fedit_write always treats file as one path. fedit_show, fedit_find and fedit_map also take a list.
Cross-file copy, move and replace -- -dest (v1.9.0, MCP since v1.10.0)
-dest copies or moves a block from -file into one or more other files. It takes a comma-separated list of existing files (no globs). The source is chosen the usual way: -line/-end, -match/-endmatch, or -block with -lang. The destination anchor is resolved separately inside each destination file, using one of -after, -before, -aftermatch, -beforematch, -afterblock or -beforeblock (the block anchors need -lang).
# Copy a function into two other files, right after a named block in each
fedit -file a.go -op copy -block Helper -lang go -dest b.go,c.go -afterblock Init
# Move a config section into two files, before a marker line in each
fedit -file base.conf -op move -match '[cache]' -endmatch '[/cache]' -dest x.conf,y.conf -beforematch '[logging]'
# Paste 2 copies in each destination
fedit -file src.txt -op copy -line 5:+3 -dest a.txt,b.txt -aftermatch ANCHOR -times 2
- Each destination is handled on its own. A problem in one (missing file, anchor not found, read-only, write failed) is reported as SKIP and that file is never modified. The batch never aborts.
- move writes all the destinations first. The source text is removed only if at least one destination write succeeded. If every destination fails, the source is left intact, so text is never lost.
- The report lists OK or SKIP per destination, then
N/M file(s) succeeded. Exit code 0 if at least one destination succeeded, 1 if none did. - A destination that is the source file itself is a SKIP, and a file listed twice is used once.
- copy and move take -dest with an anchor flag, and replace takes -dest with -destblock (below). It is rejected with any other op, and with -match-regex, -cleanfirst, -stream or -files, before any file is read. It does not combine with a multi -file list: -file must be the single source file.
- Cross-file transfer moves text, not dependencies. A Go function that calls fmt.Println lands textually perfect in a file with no fmt import, and that file will not compile until you add the import. Since v1.11.0, copy, move and replace with -dest add an advisory note when a Go destination lacks a standard library import that the transferred lines use (advisory only: results and exit codes are unchanged).
- MCP: fedit_copy, fedit_move and fedit_replace take a dest parameter (a comma list of files) with the same anchors, and destblock for replace; same rules and a per-destination report; file must be a single path. fedit_insertafter and fedit_insertbefore take sourcefile and sourceblock (with lang); there file may also be a comma list or glob.
Replace a block in other files -- replace -dest with -destblock
replace -dest overwrites a named block in each destination with the source block or range from -file. -destblock names the block to overwrite and is required. The source is chosen as for copy and move, and -lang lets block names resolve.
# Overwrite Helper in two files with the Helper from a.go
fedit -file a.go -op replace -block Helper -lang go -dest b.go,c.go -destblock Helper -v
- A destination that does not have that block is a SKIP, never an insert. Each destination is handled on its own, like copy and move.
- -destblock is only accepted with replace -dest.
Insert a block from another file -- -sourcefile and -sourceblock
insertafter and insertbefore can take their content from a named block in another file. -file stays the file being edited and the anchor is chosen as usual.
# Insert Helper from a.go into b.go, after the line matching '// helpers'
fedit -file b.go -op insertafter -match '// helpers' -sourcefile a.go -sourceblock Helper -lang go -v
- -sourcefile and -sourceblock must be used together and need -lang. They cannot be combined with -text, -textfile or -texthex.
- -file may be a comma list or glob (since v1.11.0). The block is read once from -sourcefile and inserted into every file at that file's own -match, with a per-file report. A file without the match is a SKIP and is never modified. This is not a -dest fan-out: each target is edited at its own -match.
- Since v1.11.0, when the source and the destination are both Go files and the inserted block uses a standard library package the destination does not import, a hint is printed (stderr on the CLI, the OK message on MCP; advisory only: the insert is still done and the exit code is unchanged). With a file list the hint is added to that file's report line.
- The MCP tools take sourcefile and sourceblock as parameters on fedit_insertafter and fedit_insertbefore (with lang).
guided -- Natural-order entry point (CLI, since v1.11.0)
fedit guided takes the source, the verb and the destination in plain order and turns them into the explicit -op command, which it prints to stderr before running it. It is a CLI shortcut only, with no MCP tool, by design: it exists to guide a person typing at a terminal (it can ask which block you mean when a name is ambiguous), and an MCP client already passes the same information as explicit parameters. The engine and the explicit flags are unchanged.
fedit guided SRCFILE SRCBLOCK copy|move DESTFILE [before TARGET | after TARGET | at-end] [silent|report-only] [dry]
fedit guided SRCFILE SRCBLOCK replace DESTFILE [TARGET]
fedit guided SRCFILE SRCBLOCK insertbefore|insertafter DESTFILE TARGET
fedit guided "new text" insertbefore|insertafter FILE TARGET
fedit guided
fedit guided a.go Helper copy b.go before Init
fedit guided a.go Helper move "b.go,c.go" after Init
fedit guided a.go "line 12-18" copy b.go at-end
fedit guided a.go Helper replace b.go
- The source is a named block (the language comes from the file extension) or
"line N-M". - Several destinations: quote them as one comma list (
"b.go,c.go"), because PowerShell would otherwise split them. - Each destination is handled on its own. A missing file is created, and a missing anchor (or no position at all) appends at the end, with a note. A move runs its copies first and the move last, so the source is erased only after a write succeeded.
- Block names are matched by substring, as everywhere else. If a name matches several blocks, a single exact match wins (a note says so); otherwise you get a numbered choice in a terminal, or the list of candidates and exit code 2 when there is no terminal. The chosen block is then addressed by line numbers.
replaceoverwrites TARGET (default: the same name as the source) in each destination and skips a destination that does not have it.silentruns the plan with-quiet: no echo, no notes, and no engine report when every file succeeded (skips and errors still print).report-onlyruns the plan without the verify output and without the echo line, but keeps the notes and the engine's own summary. Both modifiers go last and work with every verb.drygoes last, aftersilentorreport-onlywhen you use one. It adds-dryto every step, so each step prints its diff and writes nothing, and the parent log record carriesdry=true. A destination file that does not exist is not created: the plan saysguided: dry-run: would create FILE and put the block into itinstead (for a move it adds that the block would then be removed from the source), and no diff is shown for that file. The bare prompt acceptsdry,silent dryandreport-only dry. A target block literally named dry cannot be the last word.- Bare
fedit guided(no other arguments) asks the questions one at a time: the operation, the source file and block, the destination, the position, then the modifier. Operation and position can be answered by name or by number, and a wrong choice is asked again (three tries). The prompts go to stderr and the answers are read from stdin, one per line, so piped input works. If the input ends before the last answer, nothing is changed.
-dry -- Preview a change without writing it (since v1.12.0)
-dry turns an operation that changes files into a preview. Nothing is written, truncated or created. fedit prints a unified diff (three lines of context, and /dev/null for a file that does not exist yet) to stdout, and the report on stderr ends with dry-run: applied=false (no file was changed). Exit codes are the same as for a real run, so a script can try a change before it makes it.
# Preview, then apply
fedit -file app.conf -op replaceall -match old.example.com -text new.example.com -dry
fedit -file app.conf -op replaceall -match old.example.com -text new.example.com
# Preview a multi-file run: one diff per file, and the total reads would succeed
fedit -file "*.conf" -op replaceall -match old.example.com -text new.example.com -dry
# Preview a cross-file copy
fedit -file a.go -op copy -block Helper -lang go -dest b.go,c.go -afterblock Init -dry
- The verify step is skipped, because nothing was written: replaceall and
-vprintVERIFY: SKIP (dry-run)and the exit code is 0. There is no VERIFY window and no STATS block;moveandcopykeep their own STATS block, which is computed from the plan. - Multi-file and
-destruns print one diff per file. The batch total readsN/M file(s) would succeed, each file line is worded as a preview (would replace on 1 line(s),would insert 1 line(s) at match on line 3,block "X" would be replaced with N line(s)) and a replaceall line ends withVERIFY: SKIP (dry-run), and a-destmove reportsmove: would remove lines N-M from SRCinstead of removing them. -streamwith-dryreads the file, runs the replacement and prints counts only: no diff, no temporary file, nothing written.- On the command line the summary line of a single-file run is worded as a preview too, with the wording the MCP tools use:
Would insert 1 line(s) after line 1 (4 total after),Would delete lines 2-2 (2 total after),Would write 1 line(s) to FILE,Would regex-replace on 1 line(s) (3 total). -cleanfirstwith-drytruncates nothing; the diff shows the old content removed and the new content added.- A run that would fail still fails: no match or a missing block gives the usual error and exit code, with no diff.
-dryworks with-outputresult. It cannot be combined withfedit -configorfedit -log merge(usage error, exit 1), and-dry=falseis refused too.- A dry run is logged like any run: its end record carries
dry=true(see "Audit log" below). Infedit guidedadd the worddryat the end; over MCP passdry_run(see "MCP Server Mode" below). - Limits: a guided dry run shows no diff for a destination file that does not exist yet, and a guided target block literally named dry cannot be the last word.
-cleanfirst — Truncate before writing (v1.6.0)
# Clear the file then insert fresh content at line 0
fedit -file output.txt -op insert -line 0 -cleanfirst -text "# regenerated"
-x — Machine-readable output (v1.6.0)
# Get bare line numbers from find (stdout only, no context noise)
fedit -file main.go -op find -match "TODO" -x 2>$null
fedit MCP questions
Can fedit handle very large files?
Yes, it features a stream engine that processes files line-by-line to handle multi-GB files without loading them entirely into memory.
Does fedit support regular expressions?
Yes, it supports regex replacement in streaming mode for both literal and regex patterns.
How can I avoid shell quoting issues when editing files?
You can use hex-encoded input via the -texthex flag to eliminate all shell-quoting issues with special characters.