Hashfile MCP — Claude Code MCP server: hash-anchored edits
An MCP server that edits files by line content instead of line numbers, and keeps agents away from secrets and lock files.
Open on GitHubWhat Hashfile MCP does
Line-number editing breaks the moment someone inserts a few lines above. Hashfile tags every line with a short hash on read, so an edit points at content rather than a position. The server locates the line even after it moves, and a file hash blocks the operation if the content changed since you read it. Several changes can go into one atomic batch: replace, insert_after, insert_before, delete.
Nine tools ship with it. Three handle hash-anchored work (read_text_file, edit_text_file, write_text_file), six cover plain filesystem tasks (list_directory, directory_tree, create_directory, move_file, write_file, read_multiple_files). Access rules live in AGENTS.md frontmatter: forbidden blocks a path, read_only permits reads but not writes, ignore keeps a directory out of the agent's context. Put the file anywhere in the tree and the nearest one applies. .gitignore patterns are honored too, with AGENTS.md taking precedence.
Build it with cargo build --release; the binary lands at target/release/hashfile-mcp. Rust has to be installed first, and you point your MCP client config at that binary path yourself. The server pulls in no dependencies.
What it helps with
- edit a file that shifted since the last read without hitting the wrong line
- keep an agent out of
.envfiles and private keys - let an agent read lock files and schemas but never write them
- hide
node_modulesand build output from agent context - apply several edits in one atomic operation
Example prompts for the agent
- Read
src/main.rsand replace the line with themainfunction - Add a
forbiddenrule forsecrets/**and**/*.envtoAGENTS.md - Show the project tree without
node_modulesandtarget
How to install Hashfile MCP
Install
The MCP registry has no launch command for it: see the repository README
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about Hashfile MCP
How do I install Hashfile MCP in Claude Code?
Run cargo build --release to produce the binary at target/release/hashfile-mcp. Then add a hashfile entry to your MCP client config and set command to that path.
What does Hashfile MCP do?
It gives an agent nine file tools: hash-anchored editing plus standard filesystem operations. Access is constrained by AGENTS.md frontmatter and .gitignore patterns.
How is hash-anchored editing different from line-number editing?
An operation targets the content of a line, not its number. If lines above were added or removed, the server finds the right spot anyway, and the file hash flags content that changed after the read.