Skip to content
MCP server

Code Refactor

Refactor legacy code into modern, idiomatic code through a local or cloud model backend

Install
Pricing
Open source
Platforms
CLI, self-hosted, API
Runs
Locally or Remotely
Version
1.0.4
Listing updated
today

Similar MCP servers

About Code Refactor

Code Refactor is an open-source MCP server for developer tools. It can run locally on your machine or as a hosted remote server.

Two tools sit behind this connector. refactor_code takes source code, a description of the refactoring task and an optional language hint, and returns the refactored code with an explanation, while check_status reports whether the inference backend is reachable and which model it uses. The connector was written for WorkBuddy, with Chinese-language documentation.

The model work happens in a backend you pick through environment variables. The default is a local Ollama server, which keeps code on your machine, and the alternative is any OpenAI-compatible cloud endpoint such as DeepSeek, for higher refactoring quality. Calls have a timeout of 180 seconds by default, which is longer to allow slow CPU-only inference, and errors are returned as readable messages instead of stack traces.

It can run over stdio through npx or as a hosted streamable-HTTP endpoint, and no keys are hard-coded. The README states an MIT licence.

Install

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

https://code-refactor-api.app.workbuddy.host/mcp
Install in CursorOpens Cursor, which asks you to confirm. Or add it by hand:

Add to ~/.cursor/mcp.json

{
  "mcpServers": {
    "code-refactor": {
      "url": "https://code-refactor-api.app.workbuddy.host/mcp"
    }
  }
}
Install in VS CodeOpens VS Code, which asks you to confirm. Or add it by hand:

Add to .vscode/mcp.json

{
  "servers": {
    "code-refactor": {
      "type": "http",
      "url": "https://code-refactor-api.app.workbuddy.host/mcp"
    }
  }
}

Add to ~/.codeium/windsurf/mcp_config.json

{
  "mcpServers": {
    "code-refactor": {
      "serverUrl": "https://code-refactor-api.app.workbuddy.host/mcp"
    }
  }
}

Add to your client's MCP settings (most use this shape)

{
  "mcpServers": {
    "code-refactor": {
      "type": "http",
      "url": "https://code-refactor-api.app.workbuddy.host/mcp"
    }
  }
}

Using several servers? Build one config file with the MCP config generator.

Configuration

  • REFACTOR_BACKENDInference backend: 'ollama' (local, code stays on your machine, default) or 'openai' (any OpenAI-compatible cloud endpoint, e.g. DeepSeek).
  • OPENAI_BASE_URLBase URL of the OpenAI-compatible endpoint, e.g. https://api.deepseek.com/v1. Required when REFACTOR_BACKEND=openai.
  • OPENAI_API_KEYAPI key for the cloud endpoint, e.g. a DeepSeek key. Only needed when REFACTOR_BACKEND=openai.
  • OPENAI_MODELCloud model name, e.g. deepseek-chat.
  • OLLAMA_HOSTOllama server address used when REFACTOR_BACKEND=ollama.
  • OLLAMA_MODELOllama model name used when REFACTOR_BACKEND=ollama.
  • REFACTOR_TIMEOUT_MSPer-call timeout in milliseconds. Raise it for slow local CPU inference.

Tools this server provides (2)

Taken from the project documentation; the running server may differ.

refactor_code
Refactors source code given a task description and optional language hint, returning code and notes
check_status
Checks whether the inference backend is available and reports backend and model

What it does

Refactor tool
refactor_code takes code, a task description and an optional language.
Backend health check
check_status shows backend and model availability.
Local-first default
Ollama keeps code on the machine by default.
Cloud option
Any OpenAI-compatible endpoint can be used, such as DeepSeek.
Configurable timeout
Per-call timeout defaults to 180 seconds and can be raised.
No hard-coded keys
Addresses, models and keys come from environment variables.

Good for

  • Modernise an old function without rewriting it by hand
  • Run refactoring fully offline with a local model
  • Switch to a stronger cloud model for hard refactors
  • Check that the model backend is running before a batch

Pricing

Open source

MIT licence; cloud backend usage billed by your provider

Prices change. Check code-refactor-api.app.workbuddy.host before you buy.

Code Refactor FAQ

Does my code leave my machine?

Not with the default Ollama backend. Choosing the OpenAI-compatible backend sends code to that endpoint.

Which models work?

Any Ollama model such as qwen2.5-coder, or any OpenAI-compatible model such as deepseek-chat.

How is it installed?

Run it with npx workbuddy-code-refactor-connector or install the npm package globally.

What licence is it?

MIT, according to the README.

Is Code Refactor free?

Yes. Code Refactor is open source, so you can use and self-host it for free.

How do I add Code Refactor to Claude Code?

Run this command in your terminal: claude mcp add --transport http code-refactor https://code-refactor-api.app.workbuddy.host/mcp

What are the best alternatives to Code Refactor?

The closest alternatives to Code Refactor are REA, Context7, Chrome DevTools MCP, Codebase Memory and GitHub.

Where this comes from

  • Description: written from the project's README and the project's website.
  • Install steps: from the official MCP Registry entry.

How AIPoweredBot checks servers