Skip to main content
Glama
encoding-bridge

encoding-bridge

by pindolabha

Encoding Bridge MCP

中文说明 / README_CN

Claude Code's built-in file tools assume UTF-8, so non-UTF-8 files show garbled text. Encoding Bridge auto-detects the file encoding and writes back in the original encoding.


What it's for

Projects that need to read and write non-UTF-8 files.

Related MCP server: Code Editor MCP Server

Install

npm install -g encoding-bridge-mcp

In a project that handles legacy encodings (GBK/GB2312, etc.), add a .mcp.json in the project root and set ENCODING_BRIDGE_ROOTS to the workspaces Encoding Bridge should handle:

{
  "mcpServers": {
    "encoding-bridge": {
      "type": "stdio",
      "command": "encoding-bridge-mcp",
      "args": [],
      "env": {
        "ENCODING_BRIDGE_ROOTS": "E:/path/to/project-a;E:/path/to/project-b"
      }
    }
  }
}

ENCODING_BRIDGE_ROOTS is the list of workspaces to handle; separate multiple entries with ; (Windows) or : (Unix).

The .mcp.json lives in the first workspace folder VS Code opens; putting it in a workspace folder added later has no effect.

Allow the tools in a project

Encoding Bridge uses project-scoped permissions. In each project you want it to handle, create or edit that project's .claude/settings.json to allow the MCP tools and deny the built-in file tools:

{
  "permissions": {
    "allow": [
      "mcp__encoding-bridge__Read",
      "mcp__encoding-bridge__Grep",
      "mcp__encoding-bridge__Edit",
      "mcp__encoding-bridge__Write"
    ],
    "deny": ["Read", "Grep", "Edit", "Write", "NotebookEdit"]
  }
}

Verify it works

Start (or reload) a Claude Code session and ask it to read or search a legacy file. The tool calls should be mcp__encoding-bridge__Read / Grep / Edit / Write, not the built-in tools. A configured ENCODING_BRIDGE_ROOTS directory will get a .encoding-bridge/encoding-index.json, confirming it is enabled.


License

MIT. See LICENSE.

Available Tools

4 tools
EditPerforms exact string replacements in files.A

Performs exact string replacements in files.

Usage:

  • You must use your Read tool at least once in the conversation before editing. This tool will error if you attempt an edit without reading the file.

  • When editing text from Read tool output, ensure you preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix. The line number prefix format is: line number + tab. Everything after that is the actual file content to match. Never include any part of the line number prefix in the old_string or new_string.

  • ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.

  • Only use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.

  • The edit will FAIL if old_string is not unique in the file. Either provide a larger string with more surrounding context to make it unique or use replace_all to change every instance of old_string.

  • Use replace_all for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.

Inputs: file_path (required), new_string (required), old_string (required), replace_all.

GrepA powerful search tool built on regular expressions.A

A powerful search tool for file contents.

Usage:

  • ALWAYS use Grep for search tasks. NEVER invoke grep or rg as a Bash command.

  • Supports full regular expressions, file glob filters, file type filters, context lines, match-only output, multiline matching, pagination, file lists, and per-file counts.

  • Use output_mode=files_with_matches when you only need file paths; this is the default.

  • Use output_mode=content to see matching lines. Line numbers are included by default.

  • Use output_mode=count to see match counts per file.

  • scan_mode=exact is the default: pagination never stops scanning, so counts are exact when scanComplete is true. scan_mode=fast is opt-in and only valid for files_with_matches; it stops each matching file at its first match and reports countsExact=false.

  • Results are limited to 250 entries by default; use head_limit and offset for pagination. Check structuredContent scanComplete, truncationReason, and outputTruncated whenever a search is resource-limited.

  • ASCII patterns are searched once with ripgrep and ignore file encoding.

  • Non-ASCII patterns (Chinese, etc.) are grouped by detected file encoding and searched with rg --encoding per group.

Inputs: pattern (required), -A, -B, -C, +12 more.

ReadRead a file from the local filesystem.A

Reads a file from the local filesystem. You can access any file directly by using this tool. Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.

Usage:

  • The file_path parameter must be an absolute path, not a relative path

  • By default, it reads up to 2000 lines starting from the beginning of the file. Files larger than 256KB will return an error; use offset and limit for larger files

  • When you already know which part of the file you need, only read that part. This can be important for larger files.

  • Results are returned using cat -n format, with line numbers starting at 1

  • This tool allows Claude Code to read images (eg PNG, JPG, etc). When reading an image file the contents are presented visually as Claude Code is a multimodal LLM.

  • This tool can read PDF files (.pdf). For large PDFs (more than 10 pages), you MUST provide the pages parameter to read specific page ranges (e.g., pages: "1-5"). Reading a large PDF without the pages parameter will fail. Maximum 20 pages per request.

  • This tool can read Jupyter notebooks (.ipynb files) and returns all cells with their outputs, combining code, text, and visualizations.

  • This tool can only read files, not directories. To read a directory, use an ls command via the Bash tool.

  • You will regularly be asked to read screenshots. If the user provides a path to a screenshot, ALWAYS use this tool to view the file at the path. This tool will work with all temporary file paths.

  • If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.

Inputs: file_path (required), limit, pages, offset.

WriteWrite a file to the local filesystem.A

Writes a file to the local filesystem.

Usage:

  • This tool will overwrite the existing file if there is one at the provided path.

  • If this is an existing file, you MUST use the Read tool first to read the file's contents. This tool will fail if you did not read the file first.

  • Prefer the Edit tool for modifying existing files — it only sends the diff. Only use this tool to create new files or for complete rewrites.

  • NEVER create documentation files (*.md) or README files unless explicitly requested by the User.

  • Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.

Inputs: content (required), file_path (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.7/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a clear, non-overlapping purpose: Read retrieves file contents, Edit performs targeted string replacements, Write creates or overwrites files, and Grep searches file contents. There is no ambiguity in choosing which tool to use for a given task.

    Naming Consistency5/5

    All tool names are single-word verbs (Read, Edit, Write, Grep) that directly describe their actions. The naming is consistent and predictable, though it does not follow a verb_noun pattern.

    Tool Count5/5

    With 4 tools covering file reading, editing, writing, and searching, the count is well-scoped for a file manipulation server. Each tool is essential and there is no redundancy.

    Completeness4/5

    The tool surface covers the primary file operations (read, write, edit, search) but lacks delete, move, copy, and directory listing. These gaps are minor and can be worked around, but a file delete tool would make the set more complete.

    Maintenance

    ActivityNo data
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • 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
      D
      maintenance
      Enables safe, concurrent file system operations with sandboxed directory access control, automatic encoding detection, optimistic locking, and precise code editing capabilities including search-replace and batch operations.
      10
      5
      MIT
    • F
      license
      Not graded
      quality
      C
      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
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables writing and editing files in ISO-8859-1 encoding, automatically converting UTF-8 content to ISO-8859-1 for legacy codebases.
      199 npm
      2
      MIT