Codepage Bridge MCP
Click on "Install 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., "@Codepage Bridge MCPSearch for 'deprecated' in all .cpp files"
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.
Codepage Bridge MCP
Encoding-transparent file tools for Claude Code and other MCP clients.
Codepage Bridge exposes Read, Grep, Edit, and Write over MCP while transparently converting project files between their on-disk legacy codepage and Unicode text for the LLM. The model sees normal Unicode; files are written back in the encoding selected by the nearest .encoding-rules.
It is designed for legacy codebases that still use GBK/GB2312, Big5, Shift-JIS, EUC-KR, Windows-1251, or other non-UTF-8 encodings.
Why
Claude Code's built-in file tools assume UTF-8 for normal text reads. In legacy projects this can lead to:
unreadable C/C++ comments and string literals;
searches that silently miss text;
edits that corrupt the original codepage;
accidental UTF-8 rewrites of GBK or other legacy files.
Codepage Bridge keeps encoding conversion below the model boundary:
legacy bytes on disk -> decode by .encoding-rules -> Unicode for the LLM
Unicode from the LLM -> strict encode by .encoding-rules -> legacy bytes on diskIf new text cannot be represented in the target encoding, the write fails instead of silently replacing characters with ?.
Related MCP server: Universal MCP Server
Features
Encoding-aware
Read,Grep,Edit, andWritetools.Project-level
.encoding-ruleswith gitignore-like glob behavior.The nearest
.encoding-rulesdefines both the project root and active rules.Last matching rule wins;
!patternresets matching files to strict UTF-8.Basename patterns such as
*.cppmatch at every directory depth.Strict UTF-8 fallback for files not matched by a rule.
GBK/GB2312, Big5, Shift-JIS, EUC-KR, Windows codepages, UTF-8, and UTF-16 support.
BOM and dominant line-ending preservation for edits.
Read-before-write protection and stale-write detection using byte hashes.
Atomic temporary-file writes and per-path write locks.
Symlink and project-root boundary checks.
Image, PDF, and Jupyter Notebook reading.
Grep output modes, context lines, glob/type filters, regex flags, and pagination.
Requirements
Node.js 20 or newer.
Claude Code or another MCP client with stdio server support.
Optional: Poppler commands
pdfinfoandpdftoppmfor PDF page rendering.
Installation
Clone and build:
git clone git@github.com:skyispainted/codepage-bridge-mcp.git
cd codepage-bridge-mcp
npm install
npm run buildThe server entry point is:
dist/src/server.jsMCP Configuration
Claude Code user-level installation
Available in all projects:
claude mcp add --scope user codepage-bridge -- node /absolute/path/to/codepage-bridge-mcp/dist/src/server.jsVerify:
claude mcp get codepage-bridge
claude mcp listClaude Code project-level installation
Create .mcp.json in the project root:
{
"mcpServers": {
"codepage-bridge": {
"type": "stdio",
"command": "node",
"args": [
"/absolute/path/to/codepage-bridge-mcp/dist/src/server.js"
]
}
}
}Shared project MCP configurations may require approval the first time Claude Code opens the project.
Important: Disable the Built-in File Tools
Installing the MCP is not sufficient by itself. Claude Code may continue choosing its built-in Read, Grep, Edit, Write, or NotebookEdit tools, which bypass .encoding-rules.
Add the bridge tools to permissions.allow and the built-in tools to permissions.deny in ~/.claude/settings.json:
{
"permissions": {
"allow": [
"mcp__codepage-bridge__Read",
"mcp__codepage-bridge__Grep",
"mcp__codepage-bridge__Edit",
"mcp__codepage-bridge__Write"
],
"deny": [
"Read",
"Grep",
"Edit",
"Write",
"NotebookEdit"
]
}
}Merge these entries into your existing settings instead of replacing the entire file.
Recommended Claude instructions
Add this to the project CLAUDE.md, or to ~/.claude/CLAUDE.md for a global policy:
## File encoding policy
Use Codepage Bridge for all project file content operations:
- Read with `mcp__codepage-bridge__Read`.
- Search with `mcp__codepage-bridge__Grep`.
- Edit with `mcp__codepage-bridge__Edit`.
- Create or completely rewrite with `mcp__codepage-bridge__Write`.
Do not use built-in Read, Grep, Edit, Write, NotebookEdit, shell commands,
PowerShell commands, or scripts as substitutes for project file content access.
Glob may only be used to discover paths.
Do not manually transcode files or normalize line endings. `.encoding-rules`
is the source of truth.Why both settings and instructions?
denyremoves the unsafe built-in tools from the model's available tool list.CLAUDE.mdprevents the model from bypassing the bridge with shell commands or scripts.
.encoding-rules
Every project using Codepage Bridge must contain .encoding-rules at its root.
Example:
# Last matching rule wins
*.c gbk
*.cpp gbk
*.h gbk
legacy/**/*.txt windows-1251
assets/**/*.csv shift_jis
**/*.json utf8
# Cancel earlier matches and return to strict UTF-8
!SourceCode/generated/**Syntax:
<glob-pattern> <encoding>Rules:
Empty lines and lines beginning with
#are ignored.*,**, and?use glob semantics.Patterns without
/, such as*.cpp, match basenames at every directory depth.Patterns containing
/are relative to the.encoding-rulesdirectory.The last matching rule wins.
!patterncancels previous matches and selects strict UTF-8.Files with no matching rule use strict UTF-8.
The nearest
.encoding-rulesis used; its directory is the allowed project root.
Use encoding labels accepted by WHATWG TextDecoder and iconv-lite, for example:
utf8
utf-16le
gbk
gb2312
gb18030
big5
shift_jis
euc-kr
windows-1251
windows-1252Tools
Read
{
"file_path": "C:\\project\\SourceCode\\Main.cpp",
"offset": 1,
"limit": 200,
"pages": "1-5"
}Text is decoded according to
.encoding-rulesand returned as Unicode.Output uses numbered lines compatible with Claude Code workflows.
Files larger than 256 KiB require offset and limit.
Multiple ranged reads of the same unchanged file are merged by line coverage; once all lines have been returned, Edit and Write are authorized.
Ranges may be sequential, overlapping, out of order, or concurrently requested within the same MCP process. A file hash change invalidates accumulated coverage.
Supports PNG, JPEG, GIF, WebP, PDF pages, and Notebook cells.
Notebook reads do not accept text-line
offsetorlimit.
Grep
{
"pattern": "错误|失败",
"path": "C:\\project",
"glob": "**/*.log",
"output_mode": "content",
"-i": false,
"-n": true,
"-C": 2,
"head_limit": 250,
"offset": 0
}Supported options:
output_mode:content,files_with_matches, orcount.globand commontypefilters.-i,-n, and-o.-A,-B,-C, andcontext.multiline.head_limitandoffset.
Each candidate file is decoded using its own nearest .encoding-rules. Explicit single-file decode failures are reported as errors rather than being misreported as zero matches.
Edit
{
"file_path": "C:\\project\\SourceCode\\Main.cpp",
"old_string": "旧文本",
"new_string": "新文本",
"replace_all": false
}Existing files require a complete prior
Read.A partial read authorizes an edit when every line covered by the selected old_string match was actually returned to the model.
The rest of a large file does not need to be read when the target string is unique and fully contained in displayed lines.
With eplace_all: true, every matching range must have been read.
If a target was not read, the error reports the exact line range to request.
The file is re-read and hashed immediately before writing.
Multiple matches are rejected unless
replace_allis true.Straight/curly quote compatibility follows Claude Code edit behavior.
The original encoding, BOM, and dominant line ending are preserved.
Write
{
"file_path": "C:\\project\\SourceCode\\NewFile.cpp",
"content": "完整内容"
}New files use the encoding selected by
.encoding-rules.Existing files require a complete prior
Read.Existing files retain encoding and BOM metadata.
Complete rewrites use the line endings supplied by the caller.
Safety Notes
Commit
.encoding-ruleswith the project. Without it, Codepage Bridge refuses access instead of guessing a project root.Test rules before large edits. Start with
ReadorGrepon representative nested files.Use basename globs for language-wide rules.
*.cpp gbkapplies at any depth;SourceCode/**/*.cpp gbkapplies only below that path.Do not silently convert encodings. If text cannot be represented in the configured encoding, update the rule deliberately or choose representable text.
Do not bypass the bridge. Shell tools, scripts, IDE formatters, and other MCP servers can still rewrite files using the wrong encoding.
Keep the MCP process trusted. It has read/write access inside roots defined by
.encoding-rules.Review generated diffs. Encoding preservation prevents byte-level corruption, but semantic edits still require review.
PDF support is optional. Install Poppler or avoid PDF reads.
Notebook editing is intentionally unavailable. Notebook reading is supported, but the MCP does not expose
NotebookEdit.Windows network/device paths are rejected before I/O. This avoids unintended SMB access and credential leakage.
Development
npm install
npm run check
npm test
npm run build
npm startCurrent automated coverage includes encoding rule precedence, nested basename matching, strict codecs, lossy-write rejection, stale-write protection, atomic writes, symlink boundaries, images, PDFs, Notebook reads, GBK read/edit/write flows, Grep modes, and MCP protocol registration.
License
MIT. See LICENSE.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/skyispainted/codepage-bridge-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server