Code Refactor

v1.0.4
io.github.zhouhengchang/code-refactor Checked 4 days ago Published 1 month ago

Refactor legacy code into modern, idiomatic code without changing its behavior.

Values you need

VariableWhat it is
REFACTOR_BACKENDoptional Inference backend: 'ollama' (local, code stays on your machine, default) or 'openai' (any OpenAI-compatible cloud endpoint, e.g. DeepSeek). Default: ollama
OPENAI_BASE_URLoptional Base URL of the OpenAI-compatible endpoint, e.g. https://api.deepseek.com/v1. Required when REFACTOR_BACKEND=openai.
OPENAI_API_KEYoptional secret API key for the cloud endpoint, e.g. a DeepSeek key. Only needed when REFACTOR_BACKEND=openai.
OPENAI_MODELoptional Cloud model name, e.g. deepseek-chat. Default: deepseek-chat
OLLAMA_HOSToptional Ollama server address used when REFACTOR_BACKEND=ollama. Default: http://127.0.0.1:11434
OLLAMA_MODELoptional Ollama model name used when REFACTOR_BACKEND=ollama. Default: qwen2.5-coder
REFACTOR_TIMEOUT_MSoptional Per-call timeout in milliseconds. Raise it for slow local CPU inference. Default: 180000

npm (npx) discovery passed

Requires Node.js 18+

Run in a terminal
claude mcp add code-refactor -- npx -y workbuddy-code-refactor-connector@1.0.4
Add to claude_desktop_config.json
{
  "mcpServers": {
    "code-refactor": {
      "args": [
        "-y",
        "workbuddy-code-refactor-connector@1.0.4"
      ],
      "command": "npx"
    }
  }
}
Add to ~/.cursor/mcp.json
{
  "mcpServers": {
    "code-refactor": {
      "args": [
        "-y",
        "workbuddy-code-refactor-connector@1.0.4"
      ],
      "command": "npx"
    }
  }
}
Add to .vscode/mcp.json
{
  "servers": {
    "code-refactor": {
      "args": [
        "-y",
        "workbuddy-code-refactor-connector@1.0.4"
      ],
      "command": "npx",
      "type": "stdio"
    }
  }
}
Add to ~/.codex/config.toml
[mcp_servers.code-refactor]
command = "npx"
args = ["-y", "workbuddy-code-refactor-connector@1.0.4"]

Remote (hosted)

Run in a terminal
claude mcp add --transport http code-refactor https://code-refactor-api.app.workbuddy.host/mcp
Add to Settings → Connectors → Add custom connector (or claude_desktop_config.json via mcp-remote)
{
  "mcpServers": {
    "code-refactor": {
      "args": [
        "-y",
        "mcp-remote",
        "https://code-refactor-api.app.workbuddy.host/mcp"
      ],
      "command": "npx"
    }
  }
}
Add to ~/.cursor/mcp.json
{
  "mcpServers": {
    "code-refactor": {
      "url": "https://code-refactor-api.app.workbuddy.host/mcp"
    }
  }
}
Add to .vscode/mcp.json
{
  "servers": {
    "code-refactor": {
      "type": "http",
      "url": "https://code-refactor-api.app.workbuddy.host/mcp"
    }
  }
}
Add to ~/.codex/config.toml
[mcp_servers.code-refactor]
command = "npx"
args = ["-y", "mcp-remote", "https://code-refactor-api.app.workbuddy.host/mcp"]

For AI agents

  1. Pick the user's MCP client and apply the matching config from the first install method (it is the one verified by the smoke test when available).
  2. Restart or reload the client so it starts the server.
  3. Verify: the server should expose these tools: refactor_code, check_status.
  4. If it fails, check that the required runtime is installed (Node.js 18+) and that the values above are set.

Machine-readable: install.md · manifest.json