# dabito/hledit-mcp [Health: Active]

**Category:** 📂 File Systems  
**Repository:** https://github.com/dabito/hledit-mcp  
**GitHub Stars:** 1  
**npm Downloads (last month):** 326  
**Views:** 4  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/dabito-hledit-mcp

## Description
Hash-anchored file edits for MCP clients. Reads files with line anchors, validates anchors against current content, and rejects stale writes before changing files.

## Tools
Capabilities this server exposes over MCP:

- **hledit** — Read, edit, or batch-edit files using hash-anchored line references (LN#HASH, currently LN#HHH). Use op:'read' to get anchors, op:'edit' for single changes, op:'batch' for multiple edits in one call. Anchors come from the most recent read and detect stale context before any write.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "hledit-mcp": {
    "command": "npx",
    "args": ["-y","hledit-mcp"],
    "env": {
      "HLEDIT_BIN": "",
      "HLEDIT_CWD": "",
      "HLEDIT_MCP_DIFF": "",
      "HLEDIT_MCP_DIFF_MAX_LINES": "",
      "HLEDIT_MCP_DIFF_CONTEXT": "",
      "HLEDIT_MCP_DIFF_MAX_CELLS": ""
    }
  }
}
```

**Requires environment variables:** `HLEDIT_BIN`, `HLEDIT_CWD`, `HLEDIT_MCP_DIFF`, `HLEDIT_MCP_DIFF_MAX_LINES`, `HLEDIT_MCP_DIFF_CONTEXT`, `HLEDIT_MCP_DIFF_MAX_CELLS` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What dabito/hledit-mcp does

dabito/hledit-mcp provides MCP clients with a file-editing interface backed by the `hledit` command-line tool. Its single `hledit` tool supports three operations: `read`, `edit`, and `batch`. Reading a file returns line references containing a line number and short hash, such as `6#M9A`. Later write operations use those references rather than relying only on copied text.

The server is intended for local workspace edits. It can read bounded sections of a file, filter reads with substring matching, and apply replacement, insertion, deletion, or range-replacement changes. Batch operations group multiple anchor-based edits into one request.

## How it works

A typical workflow with the dabito/hledit-mcp MCP server starts with `read`. The response includes anchors tied to the file content at the time of reading. An agent then submits an `edit` or `batch` request using one or more of those anchors.

Before modifying the file, `hledit` recalculates the referenced hash. If the relevant line has moved or changed since the read, the operation fails with a `stale` result and no write occurs. The agent should read the file again to obtain current anchors before retrying. This behavior makes stale context an explicit failure rather than an implicit text-replacement risk.

The server communicates over MCP stdio. It invokes the installed `hledit` binary, resolving relative paths from the configured working directory. Successful edits return concise summaries; with a recent enough CLI, they can also include line-count deltas. Optional textual diffs can be enabled for successful edits and batches.

## Setup and configuration

To run the dabito/hledit-mcp MCP server, install Go 1.21 or later and install the CLI with `go install github.com/dabito/hledit@latest`. Node.js 18 or later is also required. The MCP client must support stdio servers.

A client can launch the published package with `npx -y hledit-mcp`. Set `HLEDIT_CWD` to the workspace that the server should edit. `HLEDIT_BIN` can point to the CLI when `hledit` is not available on `PATH`.

Optional diff settings include `HLEDIT_MCP_DIFF`, `HLEDIT_MCP_DIFF_MAX_LINES`, `HLEDIT_MCP_DIFF_CONTEXT`, and `HLEDIT_MCP_DIFF_MAX_CELLS`. Diff output is disabled by default. The server uses a default read limit of 2,000 lines when no offset or limit is supplied.

## Tools and capabilities

The `hledit` tool accepts a required `op` and `path`. For `read`, `offset`, `limit`, `grep`, and `context` control the returned content. Grep reads use two context lines by default, or only matching lines when `context` is set to zero.

For `edit`, `action` selects `replace`, `insert`, `delete`, or `replace-range`. Range operations use an `end_anchor`; inserted or replacement text is supplied through `content`. For `batch`, the preferred `edits` value is a structured array containing operations such as replace, delete, and insert. Legacy JSON-string batch input remains accepted.

## Limitations and notes

The server does not provide a separate tool for each edit type; all operations are handled through `hledit`. Anchors are only valid for the file state from which they were read, so edits made by another process can require a fresh read. The working directory should be scoped to the workspace the MCP client is expected to modify.

Older `hledit` CLI versions remain usable, but versions before 1.2.4 may omit line-delta information from successful edit summaries. The optional diff output is capped by configurable limits and may omit the diff body when a comparison exceeds the configured cell budget.

_Full upstream README: https://allmcps.com/mcp/dabito-hledit-mcp/readme_

