file-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@file-mcp Replace 'copyright 2023' with 'copyright 2024' in C:\legal.txt"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
file-mcp
file-mcp is a Windows-first MCP server focused on deterministic text writes.
It intentionally exposes write-only tools for create, replace, and structured edit workflows.
Public read and search capabilities have been removed from the tool surface.
Goals
Keep the MCP surface focused on writing files
Preserve encoding, BOM, newline style, and trailing newline by default when editing existing files
Support atomic writes guarded by
base_hashHandle chunked large-file generation without giant single-call payloads
Keep existing mixed-newline files writable without forcing full normalization first
Related MCP server: local-code-mcp
Tool Surface
write_full_text(path, content, encoding="preserve", bom="preserve", newline="preserve", final_newline="preserve", create_dirs=True, if_exists="overwrite", base_hash=None)Whole-file atomic write.apply_text_edits(path, edits, encoding="preserve", bom="preserve", newline="preserve", final_newline="preserve", base_hash=None)Atomic line-range edits. Eachedits[]item must providestart_lineandnew_text;end_lineandexpected_old_textare optional.apply_text_spans(path, spans, encoding="preserve", bom="preserve", newline="preserve", final_newline="preserve", base_hash=None)Atomic offset-based edits using normalized-text offsets. Eachspans[]item must providestart_offset,end_offset, andnew_text;expected_old_textis optional.replace_literal(path, old_text, new_text, encoding="preserve", expected_occurrences=1, bom="preserve", newline="preserve", final_newline="preserve", base_hash=None)Exact-count literal replacement. When no exact match is found, the server also tries conservative mojibake recovery for non-ASCIIold_text/new_textpairs before failing and reporting whitespace or codec hints.replace_regex(path, pattern, replacement, encoding="preserve", expected_occurrences=1, case_sensitive=True, dotall=False, bom="preserve", newline="preserve", final_newline="preserve", base_hash=None)Exact-count regex replacement.replace_block(path, start_marker, end_marker, replacement, encoding="preserve", occurrence=1, mode="between", bom="preserve", newline="preserve", final_newline="preserve", base_hash=None)Marker-delimited block replacement.begin_write_session(path, encoding="preserve", bom="preserve", newline="preserve", final_newline="preserve", create_dirs=True, if_exists="overwrite", base_hash=None)append_write_chunk(session_id, content)commit_write_session(session_id)abort_write_session(session_id)
What Changed
inspect_textwas removed from the public MCP interfaceread_textwas removed from the public MCP interfacesearch_textwas removed from the public MCP interfaceapply_search_replacementswas removed from the public MCP interface
The server still reads existing file contents internally when a write operation needs style preservation, conflict checks, or targeted replacement. That internal read path is now an implementation detail rather than a client-facing capability.
Editing Model
Recommended usage now is:
Use a caller-side source of truth for the target file content or edit coordinates.
Choose one write primitive:
write_full_text,apply_text_edits,apply_text_spans,replace_literal,replace_regex, orreplace_block.Pass
base_hashwhen you already have a trusted hash and want fail-closed concurrency protection.Use chunked sessions for large generated outputs.
Return Format
Successful write tools return compact natural-language summaries for LLM attention hygiene. The default result includes only the operation outcome, target path, and essential counts or session id.
Examples:
Created C:\work\repo\README.md.
Updated C:\work\repo\src\app.ts: replaced 1 occurrence.
Unchanged C:\work\repo\README.md: new content matched existing file.
Write session started for C:\work\repo\large.txt. Session: 8f6c2c4e0f134f49a6b48bbf55f7156a
Committed write session 8f6c2c4e0f134f49a6b48bbf55f7156a to C:\work\repo\large.txt: updated file.The tool output intentionally omits audit fields such as hashes, byte counts, encoding, newline style, and total line counts.
Nested Edit Objects
apply_text_edits item fields:
start_line: 1-based inclusive line number.end_line: optional 1-based inclusive end line. Omit to replace onlystart_line; set tostart_line - 1to insert beforestart_line.new_text: replacement text for the line range.expected_old_text: optional guard text for the existing line range.
apply_text_spans item fields:
start_offset: 0-based inclusive offset in normalized file text.end_offset: 0-based exclusive offset in normalized file text.new_text: replacement text for the offset range.expected_old_text: optional guard text for the existing normalized offset range.
Style Preservation
When editing an existing file with the default "preserve" modes:
encodingkeeps the detected file encodingbomkeeps the existing BOM statenewlinekeepsLF,CRLF, orCRfinal_newlinekeeps whether the file ended with a newline
If the existing file uses mixed newline styles and you keep newline="preserve", unchanged or positionally corresponding lines retain their original endings and inserted lines use the dominant existing newline style.
Allowed Roots
By default the server only allows access under F:\.
Override with an environment variable:
$env:FILE_MCP_ALLOWED_ROOTS = 'F:\;F:\GGPK3\;F:\repo\'Multiple roots are separated with ;.
Set FILE_MCP_ALLOWED_ROOTS to * to disable root restrictions entirely.
Install
cd D:\file-mcp
py -m pip install -e .Run
cd D:\file-mcp
py -m file_mcpExample MCP Client Config
{
"mcpServers": {
"file-mcp": {
"command": "py",
"args": ["-m", "file_mcp.server"],
"cwd": "D:\\file-mcp",
"env": {
"FILE_MCP_ALLOWED_ROOTS": "*"
}
}
}
}Notes
Auto-detection supports UTF-8, UTF-8 BOM, UTF-16 LE/BE, UTF-32 LE/BE, and
gb18030, and it now prefersgb18030over UTF-8 only when both decoders succeed and the UTF-8 result looks materially more like mojibakeSuccessful write tools return compact natural-language summaries instead of JSON metadata
write_full_textis the simplest primitive when whole-file replacement is acceptable
Available Tools
10 toolsabort_write_sessionB
Abort a chunked write session without writing anything.
Inputs: session_id (required). Returns: result
append_write_chunkC
Append a text chunk to an open write session.
Inputs: content (required), session_id (required). Returns: result
apply_text_editsB
Apply multiple non-overlapping line-range edits in a single atomic write.
Inputs: path (required), edits (required), bom, newline, +3 more. Returns: result
apply_text_spansC
Apply multiple non-overlapping normalized-text span edits using 0-based offsets.
Inputs: path (required), spans (required), bom, newline, +3 more. Returns: result
begin_write_sessionC
Start a chunked write session for large generated files.
Inputs: path (required), bom, newline, encoding, +4 more. Returns: result
commit_write_sessionB
Commit a chunked write session via a single atomic file replacement.
Inputs: session_id (required). Returns: result
replace_blockA
Replace a marker-delimited block with base-hash protection and style preservation.
Inputs: path (required), end_marker (required), replacement (required), start_marker (required), +7 more. Returns: result
replace_literalC
Replace literal text only when the exact expected occurrence count matches.
Inputs: path (required), new_text (required), old_text (required), bom, +5 more. Returns: result
replace_regexC
Replace regex matches only when the exact expected occurrence count matches.
Inputs: path (required), pattern (required), replacement (required), bom, +7 more. Returns: result
write_full_textB
Write an entire text file with explicit style controls and optional base-hash protection.
Inputs: path (required), content (required), bom, newline, +5 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool has a clearly distinct purpose: session management, various replace methods, and full file writing. No two tools appear to do the same thing, and descriptions clarify the differences.
All tool names follow a consistent verb_noun snake_case pattern (e.g., abort_write_session, replace_literal), making them predictable and easy to interpret.
10 tools is well within the ideal range. Each tool addresses a specific file editing operation without being excessive or insufficient.
The tool set lacks basic file operations like reading, deleting, or listing files. While editing and writing are covered, the absence of read functionality creates a significant gap for typical file management workflows.
Related MCP Connectors
MCP Server for Slima - AI Writing IDE for Novel Authors with AI Beta Reader.
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Ovanek MCP: Model Context Protocol server for Ovanek platform tools; writes are dry-run by default.
Related MCP Servers
- AlicenseBqualityBmaintenanceComprehensive MCP server for filesystem operations, process management, interactive sessions, and async file search. Includes utilities for JSON repair, encoding fixes, duplicate detection, OCR, ZIP archives, and Markdown export.50208 npm6MIT
- AlicenseNot gradedqualityBmaintenanceSafe local MCP server for Windows to list, read, search, patch, backup, and verify code files in allowed folders, with Git integration and dry-run diffs.1MIT
- AlicenseNot gradedqualityDmaintenanceA tuned filesystem MCP server for Codex-style development, offering fast file operations, bounded output, and safe edits.MIT
- AlicenseNot gradedqualityCmaintenanceA sandboxed file-access MCP server for Claude Desktop, enabling safe read/write access to selected directories with atomic verified writes, undo, and read-only git operations.1MIT