utf8-file-ops
This server provides UTF-8-safe file operations for Cursor on Windows: writing, replacing text, and verifying/fixing encoding.
utf8_write: Create or overwrite a file as UTF-8 without BOM; supports line-ending styles (
auto,lf,crlf,cr).utf8_replace: Replace an exact old string with new text, optionally replacing all occurrences; returns diff/error details on failure.
utf8_verify: Check whether a file is valid UTF-8 and optionally fix UTF-16 corruption by re-saving as UTF-8.
Designed to avoid Cursor's built-in Write/StrReplace UTF-16 bug on Windows; edits go directly to disk, so use git/revert carefully.
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., "@utf8-file-ops write src/app.ts as UTF-8 with export const app = 'ok';"
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.
Cursor Write Edit Tool
An MCP server for Cursor that writes and edits files as UTF-8 on Windows.
Why I built this
I was hitting a frustrating issue on Windows with Cursor's built-in Agent Write and StrReplace tools — files were sometimes saved as UTF-16 instead of UTF-8. That broke builds (SyntaxError, illegal character '\0', etc.) and wasted time fixing corrupted source files.
So I made this tool. It uses MCP to write and edit files directly as UTF-8. In my experience it works well and fixes the encoding problem.
One drawback: you usually can't see the edits inline in Cursor the same way you do with the built-in Write/StrReplace diff view. The file changes on disk, but Cursor may not show a nice side-by-side preview of what changed.
Line endings: Windows files often use CRLF while the agent sends LF. utf8_replace now normalizes line endings before matching, so multi-line JSX/TSX edits should work. If a replace still fails, use utf8_write to rewrite the full file.
Related MCP server: Encoding MCP Server
Tools
Tool | Use when | Description |
| Multi-line JSX/TSX | Replace lines by number (no unique |
| Small text swaps | EOL-aware replace; returns diff; rich errors on failure |
| Many edits | Several write/replace/edit ops in one call |
| Unified diff | Apply a single |
| New files / full rewrite | UTF-8 write; returns diff when overwriting |
| Encoding check | Detect/fix UTF-16 corruption |
MCP server id in Cursor: user-cursor-write-edit-tool
Requirements
Node.js 18+
Cursor with MCP support
Windows (this is mainly for the Cursor UTF-16 write bug on Windows)
Install in Cursor
One-click install
Click Add to Cursor above
Approve the install prompt
Restart Cursor if the tools do not appear immediately
No clone or manual mcp.json editing required — it runs via npx from GitHub.
Manual install
Add to ~/.cursor/mcp.json (global) or .cursor/mcp.json (project):
{
"mcpServers": {
"cursor-write-edit-tool": {
"command": "npx",
"args": ["-y", "github:Pranav-stac/cursor-write-edit-tool"]
}
}
}Restart Cursor after saving.
Agent usage
Prefer this MCP for source files on Windows. If utf8_replace fails twice, use utf8_edit_lines with line numbers. Built-in Write/StrReplace are fine as a fallback.
Tool results include a diff field (removed / added / unified) — show that to the user since inline diffs may not appear.
Write a file
{
"path": "C:\\project\\src\\app.ts",
"contents": "export const app = 'ok';\n"
}Replace text
{
"path": "C:\\project\\src\\app.ts",
"old_string": "'ok'",
"new_string": "'ready'",
"replace_all": false
}On failure you get reason, candidates (line + snippet), and hints — not just old_string not found.
Edit by line range (best for multi-line JSX)
{
"path": "C:\\project\\src\\page.tsx",
"start_line": 42,
"end_line": 48,
"new_string": "<section>\n <h1>Title</h1>\n</section>"
}Verify / fix encoding
{
"path": "C:\\project\\src\\app.ts",
"fix": true
}Revert limitations
This tool writes files directly to disk through MCP. That means:
Action | Works? |
Cursor Agent Revert button in chat | Usually no — MCP edits are not tracked like built-in Write/StrReplace |
Editor Undo (Ctrl+Z) | Sometimes — only if the file is open and you undo right away |
Git revert / restore | Yes — recommended |
Cursor Local History / Timeline | Often yes |
Use git carefully. Commit or stash before long agent sessions. Do not rely on Cursor's revert for MCP-made changes.
git add -A && git commit -m "checkpoint before agent session"If something goes wrong:
git restore .
# or
git checkout -- path/to/fileDevelopment
git clone https://github.com/Pranav-stac/cursor-write-edit-tool.git
cd cursor-write-edit-tool
npm install
npm test
npm startLicense
MIT
Available Tools
3 toolsutf8_replaceA
Replace text in an existing file and save as UTF-8. Use instead of Cursor StrReplace on Windows.
Inputs: path (required), new_string (required), old_string (required), replace_all.
utf8_verifyB
Check whether a file is valid UTF-8 and optionally fix UTF-16 corruption.
Inputs: path (required), fix.
utf8_writeA
Create or overwrite a file as UTF-8 (no BOM). Use instead of Cursor Write on Windows.
Inputs: path (required), contents (required), newline.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool has a clearly distinct role: write creates/overwrites, replace edits existing content, and verify checks/fixes encoding. There is no meaningful overlap between them.
All tool names follow the uniform utf8_<verb> pattern with snake_case throughout, making the set predictable and easy to navigate.
Three tools is a well-scoped size for a narrow, purpose-built server focused on UTF-8 file operations. Each tool earns its place without redundancy.
The set covers the core operations implied by the domain: write, replace, and verify. A read or conversion tool could round it out, but the stated UTF-8-focused purpose is reasonably complete.
Maintenance
Related MCP Connectors
Connect ChatGPT, Claude, Cursor or VS Code to your Windows PC: files, terminal, browser, apps.
Read and write your Fresh Jots notes from Claude, Cursor, and any MCP client.
Manage files and folders directly from your workspace. Read and write files, list directories, cre…
Use your Mac, Windows or Linux computer from ChatGPT, Claude or Codex: files, commands, documents.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables comprehensive file operations including reading, writing, searching, and editing files with advanced features like regex-based replacements, line-specific modifications, and directory-wide search capabilities. Provides 8 robust tools for safe file manipulation with content verification and detailed error handling.89 npm2MIT
- AlicenseAqualityDmaintenanceEnables creation and management of UTF-8 with BOM encoded files optimized for Windows build environments. Provides file encoding conversion, detection, and template support for C++ and PowerShell files to prevent Korean character encoding issues.41MIT
- FlicenseNot gradedqualityCmaintenanceEnables AI assistants to read and write non-UTF-8 files (e.g., GBK, GB18030) on Windows by automatically detecting and converting encodings, preventing garbled text.7-
- FlicenseBqualityDmaintenanceWindows-first MCP server for deterministic file writes with atomic create, replace, and structured edit operations, preserving encoding and newline styles.101-