utf8-file-ops
This server provides MCP tools for Cursor to write and edit files as UTF-8 on Windows, avoiding Cursor's built-in UTF-16 corruption bug.
utf8_write: Create or overwrite a file as UTF-8 (no BOM), with optional line ending control (auto,lf,crlf,cr).utf8_replace: Search for exact text in an existing file and replace it, saving as UTF-8; supports replacing all occurrences.utf8_verify: Check whether a file is valid UTF-8 and optionally fix UTF-16 corruption by re-saving as UTF-8.Designed as a drop-in replacement for Cursor's
WriteandStrReplacetools on Windows.
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-opswrite 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.
Related MCP server: Encoding MCP Server
Tools
Tool | Replaces | Description |
| Cursor | Create or overwrite a file as UTF-8 |
| Cursor | Search/replace in an existing file |
| — | Check encoding; optionally fix UTF-16 corruption |
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
Add a Cursor rule or tell your agent:
On Windows, use the
cursor-write-edit-toolMCP (utf8_write,utf8_replace) instead of built-in Write/StrReplace for source files.
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
}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.
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the file | |
| new_string | Yes | Replacement text | |
| old_string | Yes | Exact text to find | |
| replace_all | No | Replace all occurrences (default: false) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It discloses that the tool modifies an existing file and writes UTF-8, which conveys mutation and encoding behavior. However, it does not explain what happens when old_string is not found, whether the file is rewritten atomically, or if replace_all affects error handling—leaving some behavioral ambiguity.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, two-part sentence with no filler. The primary action is front-loaded, and the usage guidance is appended without redundancy. Every word earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple file-replacement tool with a fully documented schema, the description covers purpose, encoding, and the Windows-specific rationale. It does not mention return values or failure behaviors, but no output schema exists and these are less critical for such a straightforward operation.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the parameters path, old_string, new_string, and replace_all are already individually documented. The description adds no additional parameter-level meaning beyond what the schema provides, so the baseline score of 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb and resource: 'Replace text in an existing file and save as UTF-8.' It clearly distinguishes the operation from the sibling tools utf8_write and utf8_verify by focusing on modification of existing content rather than creation or verification.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The phrase 'Use instead of Cursor StrReplace on Windows' provides an explicit context for when this tool should be chosen over a known alternative. It doesn't explicitly contrast with sibling tools, but the domain of Windows-specific UTF-8 replacement is a clear usage signal.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
utf8_verifyB
Check whether a file is valid UTF-8 and optionally fix UTF-16 corruption.
| Name | Required | Description | Default |
|---|---|---|---|
| fix | No | Re-save as UTF-8 if corrupted (default: false) | |
| path | Yes | Absolute path to the file |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description carries the burden of behavioral disclosure. It mentions optional fixing of UTF-16 corruption, implying a file modification, but does not explicitly state that the file will be overwritten or that the operation is destructive. It also fails to disclose the return value or error behavior, leaving the agent uncertain about side effects.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single sentence with no filler. Every word contributes to stating the core action and the optional fix. It is highly concise and front-loaded, though it may be too sparse for full completeness.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a tool that both checks and can modify files, the description is incomplete. It does not state what the tool returns (e.g., boolean, report), whether it requires write permissions when fix=true, or how it handles invalid UTF-8. With no output schema and no annotations, these gaps leave the agent uncertain about invocation and handling results.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100% – both 'path' and 'fix' have descriptive properties. The description adds no additional meaning beyond the schema, such as path format expectations or the exact effect of 'fix'. Baseline of 3 applies because the schema already documents the parameters adequately.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states a specific verb ('check') and resource ('file is valid UTF-8'), and also mentions an optional fix action. It clearly distinguishes from siblings utf8_write and utf8_replace, which focus on writing/replacing content, while this tool verifies validity.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus its siblings. It does not mention scenarios like pre-write validation or troubleshooting, nor does it say when not to use it. The agent is left to infer usage context from the name and siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
utf8_writeA
Create or overwrite a file as UTF-8 (no BOM). Use instead of Cursor Write on Windows.
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path to the file | |
| newline | No | Line ending style (default: auto) | |
| contents | Yes | Full file contents |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are present, so the description must carry the burden of behavioral disclosure. It does disclose the key encoding trait (UTF-8 without BOM) and the overwrite semantics, but does not mention error behavior, whether parent directories are created, or line-ending handling beyond the schema's newline parameter. This covers the core behavior but leaves some operational details unstated.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, with the primary action frontloaded in the first sentence and the alternative guidance in the second. There is zero filler or redundant restatement of the schema, making it efficient and well-scoped.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a simple write operation with only three parameters, the description plus schema provide the essential information: what it does, the encoding, overwrite behavior, and a platform condition. It could benefit from mentioning the sibling usage boundary (replace/verify) and return behavior, but no output schema exists and the tool's simplicity lowers the bar.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, with each parameter (path, newline, contents) having a concise description. The tool description does not repeat parameter details, but the baseline of 3 applies because the schema carries the explanatory load. No additional meaning beyond the schema is needed, though the description's 'UTF-8 (no BOM)' context hints at why newline handling matters.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Description states a specific action ('Create or overwrite a file') with precise encoding behavior ('as UTF-8 (no BOM)'), which clearly distinguishes it from siblings like utf8_replace (targeted replacement) and utf8_verify (checking). It also notes the platform-specific context (Windows), reinforcing what this tool is for.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly directs agents to use this tool instead of Cursor Write on Windows, providing a clear platform condition. However, it does not contrast against the sibling tools utf8_replace and utf8_verify, leaving some ambiguity about when a different write-family tool is appropriate. This is better than no guidance but not fully specified.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v1.0.0- First observed
utf8_replace - First observed
utf8_verify - First observed
utf8_write
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
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…
Exact text tools for AI agents: unified diff, patch apply, regex testing, grapheme counting.
Path-scoped team memories, rules and skills for Claude Code, Cursor, Codex and other MCP clients.
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.88 npm1MIT
- 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
- AlicenseAqualityBmaintenanceEncoding-aware, indentation-smart file tools for AI coding agents. 20+ tools including read/edit with automatic encoding detection, smart indentation conversion, SSH, SFTP, process management, and system utilities.1124MIT
- FlicenseNot gradedqualityFmaintenanceEnables 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-