Skip to main content
Glama
Pranav-stac

utf8-file-ops

by Pranav-stac

Cursor Write Edit Tool

Add to Cursor

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

utf8_write

Cursor Write

Create or overwrite a file as UTF-8

utf8_replace

Cursor StrReplace

Search/replace in an existing file

utf8_verify

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

  1. Click Add to Cursor above

  2. Approve the install prompt

  3. 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-tool MCP (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/file

Development

git clone https://github.com/Pranav-stac/cursor-write-edit-tool.git
cd cursor-write-edit-tool
npm install
npm test
npm start

License

MIT

Available Tools

3 tools
utf8_replaceA

Replace text in an existing file and save as UTF-8. Use instead of Cursor StrReplace on Windows.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path to the file
new_stringYesReplacement text
old_stringYesExact text to find
replace_allNoReplace all occurrences (default: false)

TDQS

A4/5.0
Behavior3/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
fixNoRe-save as UTF-8 if corrupted (default: false)
pathYesAbsolute path to the file

TDQS

B3/5.0
Behavior2/5

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.

Conciseness5/5

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.

Completeness2/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines1/5

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path to the file
newlineNoLine ending style (default: auto)
contentsYesFull file contents

TDQS

A4/5.0
Behavior3/5

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.

Conciseness5/5

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.

Completeness4/5

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.

Parameters3/5

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.

Purpose5/5

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.

Usage Guidelines4/5

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.

  1. 3 tool updatesv1.0.0
    • First observedutf8_replace
    • First observedutf8_verify
    • First observedutf8_write

TDQS

A3.8/5.0

Scored across 3 tools

Disambiguation5/5

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.

Naming Consistency5/5

All tool names follow the uniform utf8_<verb> pattern with snake_case throughout, making the set predictable and easy to navigate.

Tool Count5/5

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.

Completeness4/5

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

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Enables 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.
    8
    8 npm
    1
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Enables 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.
    4
    1
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Encoding-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.
    11
    24
    MIT
  • F
    license
    Not graded
    quality
    F
    maintenance
    Enables 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
    -