Code Refactor MCP server
online · 93% uptimeio.github.zhouhengchang/code-refactor·v1.0.4Refactor legacy code into modern, idiomatic code without changing its behavior.
0 stars73 downloads/wk
Reviews
Write oneNobody has reviewed Code Refactor yet.
If you have run it, two minutes of your experience saves the next person an afternoon.
Code Refactor tools (18, 1 write)
write = sends, deletes, buys or postscodeexplainFree按读者水平(零基础→资深)拆解代码逻辑、关键点与坑。按次计费:业务成功才确认扣款,内容违规、模型超时或生成失败会自动全额退款。
codegenFree根据需求描述生成可运行的示例代码。按次计费:业务成功才确认扣款,内容违规、模型超时或生成失败会自动全额退款。
codetransFreeA 语言 → B 语言等价实现 + 依赖替换与行为差异清单。按次计费:业务成功才确认扣款,内容违规、模型超时或生成失败会自动全额退款。
commitmsgFree粘贴 diff → Conventional Commits 中英双语提交信息 + 风险提示。按次计费:业务成功才确认扣款,内容违规、模型超时或生成失败会自动全额退款。
contractFree标出高/中风险条款与缺失条款,并给出可替换表述。按次计费:业务成功才确认扣款,内容违规、模型超时或生成失败会自动全额退款。
copywriterFree小红书/抖音/公众号等多平台文案,一次给 3 个版本。按次计费:业务成功才确认扣款,内容违规、模型超时或生成失败会自动全额退款。
docgenFreeREADME / API 文档 / 变更日志 / 技术方案一键生成。按次计费:业务成功才确认扣款,内容违规、模型超时或生成失败会自动全额退款。
errfixFree报错栈 + 代码 → 根因定位 + 最小修复补丁 + 验证步骤。按次计费:业务成功才确认扣款,内容违规、模型超时或生成失败会自动全额退款。
get_orderwrite actionFree按订单号查询一笔调用的状态、金额、耗时与失败原因。不收费。
list_ordersFree列出最近的调用订单,可按状态或平台过滤,用于对账。不收费。
regexgenFree自然语言 → 精确正则 + 逐段解释 + 匹配示例,防灾难性回溯。按次计费:业务成功才确认扣款,内容违规、模型超时或生成失败会自动全额退款。
resumeFree按 JD 诊断匹配度并用 STAR 结构重写(绝不虚构经历)。按次计费:业务成功才确认扣款,内容违规、模型超时或生成失败会自动全额退款。
reviewFree审查代码并给出分级的修改建议。按次计费:业务成功才确认扣款,内容违规、模型超时或生成失败会自动全额退款。
scriptFree开头钩子 3 版 + 分镜表 + 口播文案,可直接拍摄。按次计费:业务成功才确认扣款,内容违规、模型超时或生成失败会自动全额退款。
skill_infoFree返回当前技能是否上架、单次价格、支持的编程语言与免责声明。不收费。
sqlgenFree按表结构生成/优化 SQL,自动拦截破坏性语句。按次计费:业务成功才确认扣款,内容违规、模型超时或生成失败会自动全额退款。
testgenFree为核心代码生成可运行的单元测试(自动 mock 外部依赖)。按次计费:业务成功才确认扣款,内容违规、模型超时或生成失败会自动全额退款。
translateFree10 种语言,直译+润色+术语表三档输出。按次计费:业务成功才确认扣款,内容违规、模型超时或生成失败会自动全额退款。
Public scan report
scanner v0.1.10 · 2026-10-28 · same rubric, same numbers if you re-run it
- Code scan2 source files scanned25/25
- Live reliabilityremote reachable in 6128ms12/20
- Tool poisoning18 tool descriptions checked15/15
- Auth qualityopen endpoint exposes 1 write-action tools with no auth3/15
- Maintenancelast push 10 days ago15/15
- Maintainer identityregistry namespace matches repository owner6/10
Findings (1)
- highWrite-action tools reachable without authentication
auth.open-write
How Code Refactor compares
Against every graded MCP server, from our own scans and uptime checks. Updated after each scan run.
- Safety score
- 76/100
- higher than 48% of 48,255 servers
- Tools
- 18
- the typical server has 7
- Tools that change things
- 6%
- typical: 0%. Fewer write tools means less an agent can break
- Uptime
- 93%
- of our recent checks; the typical remote server answers 100%
- Response time
- 4,609 ms
- faster than 3% of 30,031 servers
- Downloads a week
- 73
- more than 55% of 12,191 servers with a package
What its tools let an agent do: 17 read · 1 change
Install Code Refactor in Claude Code, Cursor or VS Code
claude mcp add --transport http code-refactor https://code-refactor-api.app.workbuddy.host/mcp
What the publisher says
From the Code Refactor repository's README, as published. We do not edit it. Read it on GitHub
代码重构助手
把遗留代码重构为现代规范代码,保持原有接口与行为不变
一个基于本地大模型的代码重构服务。输入一段源代码和一句重构要求,输出重构后的完整代码。
代码不离开你的机器 —— 核心版通过本地 Ollama 推理,无任何数据上传。
快速开始 · 功能 · 使用方式 · 定价 · 贡献
这是什么
历史项目里总有些代码:能跑,但没人愿意碰。变量叫 a、tmp1、data2,三层嵌套的 if 里塞着业务逻辑,同一个校验规则在五个地方各写了一遍。
这个项目做的就是把这些代码改造好。它不修复 bug、不添加功能,只改结构——让代码好读、好改,同时保证外部行为完全不变。
核心能力由本地 Ollama 上的代码模型(默认 deepseek-coder)驱动,可以以 MCP Server、HTTP API、技能包 等多种形态接入你现有的工作流。
功能
支持语言:Python · JavaScript · TypeScript · Java · Go · Rust · C · C++
设计原则
重构这件事,改坏比不改更糟。所以本项目有两条硬约束:
- 不改公共接口 —— 函数名、类名、参数签名、返回值结构保持原样(除非你明确要求改)
- 保持行为等价 —— 重构后逻辑与原代码一致,不顺手修 bug
快速开始
前置条件
- Python 3.11+ 或 Node.js 18+
- Ollama 已安装并运行
- 已拉取代码模型:ollama pull deepseek-coder
方式一:本地 Python 直接调用
git clone https://github.com/zhouhengchang/code-refactor.git
cd code-refactor
python shared/refactor_core.py # 内置自测,会先检查服务再跑一个示例也可以在自己的代码里调用:
# -*- coding: utf-8 -*-
"""最小调用示例。"""
from shared.refactor_core import refactor_code, check_ollama_status
# 先确认环境就绪
print(check_ollama_status())
# 执行重构
result = refactor_code(
code="def f(a):\n r = []\n for i in a:\n if i % 2 == 0:\n r.append(i * i)\n return r\n",
task="重命名为有意义的函数名与变量名,补充类型标注与中文注释",
language="python",
)
if result["ok"]:
print(result["code"])
else:
print("失败:", result["error"])方式二:作为 MCP Server 接入(Claude Desktop / WorkBuddy / 任意 MCP 客户端)
已发布到 npm,不用克隆仓库,直接在 MCP 客户端配置里引用:
{
"mcpServers": {
"code-refactor": {
"command": "npx",
"args": ["-y", "workbuddy-code-refactor-connector"],
"env": {
"REFACTOR_BACKEND": "ollama",
"OLLAMA_HOST": "http://localhost:11434",
"OLLAMA_MODEL": "deepseek-coder"
}
}
}
}npm 包:workbuddy-code-refactor-connector
也可以从源码运行,便于自己改代码:
cd workbuddy-connector/server
npm install然后把上面的 command 改成 node,args 改成 ["/绝对路径/to/workbuddy-connector/server/index.js"] 即可。
重启客户端后即可使用 refactorcode 和 checkstatus 两个工具。
方式三:Docker 部署 HTTP 服务
docker build -t code-refactor-xpack:1.0.0 -f xpack-server/Dockerfile .
docker run -p 8000:8000 \
-e OLLAMA_HOST=http://host.docker.internal:11434 \
-e OLLAMA_MODEL=deepseek-coder \
code-refactor-xpack:1.0.0调用:
curl -X POST http://localhost:8000/refactor \
-H "Content-Type: application/json" \
-d '{
"code": "def f(a):\n return [i*i for i in a if i % 2 == 0]\n",
"task": "函数名与变量名改为有意义的命名,补充类型标注",
"language": "python"
}'使用方式
输入
输出
{
"ok": true,
"code": "重构后的完整代码",
"model": "deepseek-coder",
"language": "python",
"elapsed_ms": 3820
}Shortened. The full README is on GitHub.
Nothing above is checked by us. What we check is on the safety report.
Code Refactor: common questions
- Is Code Refactor MCP server safe?
- Mostly: it is graded B (76/100). Read the Code Refactor safety report
- How do I install Code Refactor?
- It runs remotely at code-refactor-api.app.workbuddy.host. Add it to Claude Code, Cursor, VS Code or Claude Desktop with the snippets above, or call it through the mcp.market gateway without installing anything.
- Does Code Refactor need an API key?
- Yes. The registry entry asks for
OPENAI_API_KEY. - Is Code Refactor maintained?
- The last commit was 17 days ago (2026-10-18). The latest release is v1.0.4.
- Is Code Refactor up?
- 93% of our last 28 checks got an answer. We check remote servers about four times a day.
- How does Code Refactor compare with other MCP servers?
- safety score 76/100 (higher than 48% of 48,255 servers); tools 18 (the typical server has 7); tools that change things 6% (typical: 0%. Fewer write tools means less an agent can break). Full comparison.