- Home
- MCP servers
- MCP Code Refiner
MCP Code Refiner
- python
0
GitHub Stars
python
Language
4 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"whtan410-mcp_code_review": {
"command": "python",
"args": [
"/absolute/path/to/mcp_code_review/mcp_server.py"
],
"env": {
"GOOGLE_API_KEY": "your-gemini-api-key"
}
}
}
}You deploy this second-layer MCP server to refine and review code with AI, working alongside your primary assistant to produce higher-quality, well-structured code through natural language feedback and precise diffs.
How to use
You connect your MCP client to the local code refinement server to gain AI-powered code improvements. After you set up the server, you can request refinements or reviews by asking your primary assistant to operate on a file. The server returns a diff, explanations, and suggested changes, which you can approve or reject before applying them.
Usage patterns include refining an existing file with a request like improving structure or adding error handling, and requesting a full code review for security, performance, and quality. You will see a diff of proposed changes, a rationale for each change, and an option to apply changes after your confirmation.
How to install
Follow these concrete steps to set up the server and connect it to your MCP client.
# Prerequisites
# - Python 3.10 or higher
# - An API key from at least one provider (Gemini recommended for free tier)
# 1. Clone the project
git clone https://github.com/yourusername/mcp_code_review.git
cd mcp_code_review
# 2. Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Prepare environment variables
cp .env.example .env
# Edit .env to add your API keys as shown in the example
# 5. Run the MCP server (example path; adjust as needed)
python mcp_server.py
Configuration and troubleshooting
Configure the local MCP server in your MCP client to point to the code refinement service you started. The configuration uses a standard stdio channel that launches the Python server and provides the necessary API key to the Gemini model by default.
{
"mcpServers": {
"code-refiner": {
"command": "python",
"args": ["/absolute/path/to/mcp_code_review/mcp_server.py"],
"env": {
"GOOGLE_API_KEY": "your-gemini-api-key"
}
}
}
}
Notes and usage details
Important: Replace the absolute path with the actual location of the mcp_server.py file on your system. Restart your MCP client after configuring the server so it loads the new settings.
Troubleshooting
If the server does not appear in your MCP client, verify that the path is absolute, the Python path is correct, and that the client logs show no errors. Check typical log locations for your system and restart after changes.
Project structure overview
The project includes a dedicated MCP server entry point, a test client, and modular tools that perform code refinement and code review. All prompts are designed to produce actionable diffs and explanations.
Available tools
refine_code_tool
Improves existing code based on natural language feedback using a second-layer LLM.
review_code_tool
Analyzes code for bugs, security vulnerabilities, performance issues, and quality.
apply_refinement_tool
Applies refined code to the file after user approval.