The Aider MCP Server allows Claude Code to delegate AI coding tasks to Aider, an open source AI coding assistant. This integration enables cost reduction and enhanced control over your coding workflow while leveraging Claude Code's capabilities.
Before installing the Aider MCP Server, ensure you have:
git clone https://github.com/disler/aider-mcp-server.git
uv sync
cp .env.sample .env
.env
file with the necessary credentials for your preferred AI models:GEMINI_API_KEY=your_gemini_api_key_here
OPENAI_API_KEY=your_openai_api_key_here
ANTHROPIC_API_KEY=your_anthropic_api_key_here
.mcp.json
file in the root of your project with the following configuration:{
"mcpServers": {
"aider-mcp-server": {
"type": "stdio",
"command": "uv",
"args": [
"--directory",
"<path to this project>",
"run",
"aider-mcp-server",
"--editor-model",
"gpt-4o",
"--current-working-dir",
"<path to your project>"
],
"env": {
"GEMINI_API_KEY": "<your gemini api key>",
"OPENAI_API_KEY": "<your openai api key>",
"ANTHROPIC_API_KEY": "<your anthropic api key>"
}
}
}
}
Add the MCP server to Claude Code by selecting an AI model that matches your needs:
claude mcp add aider-mcp-server -s local \
-- \
uv --directory "<path to the aider mcp server project>" \
run aider-mcp-server \
--editor-model "gemini/gemini-2.5-pro-exp-03-25" \
--current-working-dir "<path to your project>"
claude mcp add aider-mcp-server -s local \
-- \
uv --directory "<path to the aider mcp server project>" \
run aider-mcp-server \
--editor-model "gemini/gemini-2.5-pro-preview-03-25" \
--current-working-dir "<path to your project>"
claude mcp add aider-mcp-server -s local \
-- \
uv --directory "<path to the aider mcp server project>" \
run aider-mcp-server \
--editor-model "openrouter/openrouter/quasar-alpha" \
--current-working-dir "<path to your project>"
claude mcp add aider-mcp-server -s local \
-- \
uv --directory "<path to the aider mcp server project>" \
run aider-mcp-server \
--editor-model "fireworks_ai/accounts/fireworks/models/llama4-maverick-instruct-basic" \
--current-working-dir "<path to your project>"
The Aider MCP Server provides two main tools that you can use through Claude Code:
The aider_ai_code
tool allows you to implement code changes based on natural language prompts.
ai_coding_prompt
(string, required): The instruction for the AI coding taskrelative_editable_files
(list of strings, required): Files that Aider can modifyrelative_readonly_files
(list of strings, optional): Files that provide context but won't be modifiedmodel
(string, optional): Primary AI model to useeditor_model
(string, optional): Model for refining codeWhen using Claude Code, you can prompt:
Use the Aider AI Code tool to: Refactor the calculate_sum function in calculator.py to handle potential TypeError exceptions.
This will generate a request like:
{
"name": "aider_ai_code",
"parameters": {
"ai_coding_prompt": "Refactor the calculate_sum function in calculator.py to handle potential TypeError exceptions.",
"relative_editable_files": ["src/calculator.py"],
"relative_readonly_files": ["docs/requirements.txt"],
"model": "openai/gpt-4o"
}
}
The tool returns a dictionary with success status and a diff of the changes.
The list_models
tool helps you discover available AI models compatible with Aider.
substring
(string, required): Search term for filtering available modelsPrompt Claude Code with:
Use the Aider List Models tool to: List models that contain the substring "gemini".
This generates:
{
"name": "list_models",
"parameters": {
"substring": "gemini"
}
}
The tool returns a list of model names matching your search, such as:
["gemini/gemini-1.5-flash", "gemini/gemini-1.5-pro", "gemini/gemini-pro"]
To verify the server is working correctly, you can run the included tests:
uv run pytest
For specific test cases:
# Test model listing
uv run pytest src/aider_mcp_server/tests/atoms/tools/test_aider_list_models.py
# Test AI coding capabilities
uv run pytest src/aider_mcp_server/tests/atoms/tools/test_aider_ai_code.py
Note that AI coding tests require valid API keys configured in your .env
file.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.