utf8-mcp
v1.0.1
Published
UTF8-MCP local server that enforces UTF-8 text workflows
Maintainers
Readme
UTF8-MCP
UTF8-MCP 是一个本地 MCP 服务器(stdio),用于强制 UTF-8 文本工作流,避免中文文本在 GBK/GB2312/GB18030 场景下出现乱码。
功能特性
- 检测文本是 UTF-8 还是 GB18030。
- 将非 UTF-8 文本自动转换为 UTF-8(无 BOM)。
- 转换前自动创建带时间戳的备份文件。
- 拒绝疑似二进制文件。
- 扫描目录中的非 UTF-8 文本文件。
run_cmd始终通过cmd执行(不会走 PowerShell)。
MCP 工具
read_text_utf8(path)write_text_utf8(path, content)convert_to_utf8(path)scan_non_utf8(targets?)run_cmd(command, cwd?, timeoutMs?)
本地开发
cmd /c npm install
node ./mcp-utf8/server.js发布到 npmjs
npm config set registry https://registry.npmjs.org/
npm login
npm run pack:check
npm run publish:dry-run
npm publish --access public检查已发布版本:
npm view utf8-mcp version --registry https://registry.npmjs.org/全局安装:
npm install -g [email protected] --registry https://registry.npmjs.org/MCP 配置(JSON,Windows 推荐)
Windows PowerShell 可能因执行策略拦截 npx.ps1,建议使用 cmd /c npx 启动:
{
"mcpServers": {
"UTF8-MCP": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"utf8-mcp"
]
}
}
}MCP 配置(TOML,Windows 推荐)
[mcp_servers."UTF8-MCP"]
command = "cmd"
args = ["/c", "npx", "-y", "utf8-mcp"]
enabled = true如果你已经全局安装成功,也可以改为:
command = "utf8-mcp"args = []
run_cmd 调用示例
{
"name": "run_cmd",
"arguments": {
"command": "echo %CMDEXTVERSION%",
"timeoutMs": 120000
}
}测试
npm test
npm run test:unit
npm run test:integration
npm run test:e2e