Aider MCP Server - Experimental
Model context protocol server for offloading AI coding work to Aider, enhancing development efficiency and flexibility.
Overview
This server allows Claude Code to offload AI coding tasks to Aider, the best open source AI coding assistant. By delegating certain coding tasks to Aider, we can reduce costs, gain control over our coding model and operate Claude Code in a more orchestrative way to review and revise code.
Setup
- Clone the repository:
- Install dependencies:
- Create your environment file:
- Configure your API keys in the
.env
file (or use the mcpServers "env" section) to have the api key needed for the model you want to use in aider:
- Copy and fill out the the
.mcp.json
into the root of your project and update the--directory
to point to this project's root directory and the--current-working-dir
to point to the root of your project.
Testing
Tests run with gemini-2.5-pro-exp-03-25
To run all tests:
To run specific tests:
Note: The AI coding tests require a valid API key for the Gemini model. Make sure to set it in your .env
file before running the tests.
Add this MCP server to Claude Code
Add with gemini-2.5-pro-exp-03-25
Add with gemini-2.5-pro-preview-03-25
Add with quasar-alpha
Add with llama4-maverick-instruct-basic
Usage
This MCP server provides the following functionalities:
- Offload AI coding tasks to Aider:
- Takes a prompt and file paths
- Uses Aider to implement the requested changes
- Returns success or failure
- List available models:
- Provides a list of models matching a substring
- Useful for discovering supported models
Available Tools
This MCP server exposes the following tools:
1. aider_ai_code
This tool allows you to run Aider to perform AI coding tasks based on a provided prompt and specified files.
Parameters:
ai_coding_prompt
(string, required): The natural language instruction for the AI coding task.relative_editable_files
(list of strings, required): A list of file paths (relative to thecurrent_working_dir
) that Aider is allowed to modify. If a file doesn't exist, it will be created.relative_readonly_files
(list of strings, optional): A list of file paths (relative to thecurrent_working_dir
) that Aider can read for context but cannot modify. Defaults to an empty list[]
.model
(string, optional): The primary AI model Aider should use for generating code. Defaults to"gemini/gemini-2.5-pro-exp-03-25"
. You can use thelist_models
tool to find other available models.editor_model
(string, optional): The AI model Aider should use for editing/refining code, particularly when using architect mode. If not provided, the primarymodel
might be used depending on Aider's internal logic. Defaults toNone
.
Example Usage (within an MCP request):
Claude Code Prompt:
Result:
Returns:
- A simple dict: {success, diff}
success
: boolean - Whether the operation was successful.diff
: string - The diff of the changes made to the file.
2. list_models
This tool lists available AI models supported by Aider that match a given substring.
Parameters:
substring
(string, required): The substring to search for within the names of available models.
Example Usage (within an MCP request):
Claude Code Prompt:
Result:
Returns:
- A list of model name strings that match the provided substring. Example:
["gemini/gemini-1.5-flash", "gemini/gemini-1.5-pro", "gemini/gemini-pro"]
Architecture
The server is structured as follows:
- Server layer: Handles MCP protocol communication
- Atoms layer: Individual, pure functional components
- Tools: Specific capabilities (AI coding, listing models)
- Utils: Constants and helper functions
- Data Types: Type definitions using Pydantic
All components are thoroughly tested for reliability.
Codebase Structure
The project is organized into the following main directories and files:
src/aider_mcp_server
: Contains the main application code.atoms
: Holds the fundamental building blocks. These are designed to be pure functions or simple classes with minimal dependencies.tools
: Each file here implements the core logic for a specific MCP tool (aider_ai_code
,list_models
).utils.py
: Contains shared constants like default model names.data_types.py
: Defines Pydantic models for request/response structures, ensuring data validation.logging.py
: Sets up a consistent logging format for console and file output.
server.py
: Orchestrates the MCP server. It initializes the server, registers the tools defined in theatoms/tools
directory, handles incoming requests, routes them to the appropriate tool logic, and sends back responses according to the MCP protocol.__main__.py
: Provides the command-line interface entry point (aider-mcp-server
), parsing arguments like--editor-model
and starting the server defined inserver.py
.tests
: Contains tests mirroring the structure of thesrc
directory, ensuring that each component (especially atoms) works as expected.
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
Allows Claude Code to offload AI coding tasks to Aider, reducing costs and enabling more control over which models handle specific coding tasks.
Related MCP Servers
- -securityAlicense-qualityProvides code manipulation, execution, and version control capabilities. It allows AI assistants to read, write, and execute code while maintaining a history of changes.Last updated -8PythonMIT License
- -securityAlicense-qualityAI-powered assistant that connects Claude to video encoding workflows, translating cryptic errors into plain English and providing actionable solutions for troubleshooting encoding jobs.Last updated -1PythonMIT License
Code MCP Serverofficial
-securityAlicense-qualityEnables AI agents and assistants like Goose or Claude to interact with VS Code through the Model Context Protocol.Last updated -14TypeScriptApache 2.0- -securityFlicense-qualityConnects Claude AI to QGIS through the Model Context Protocol, allowing Claude to directly interact with and control QGIS for tasks like project creation, layer manipulation, and code execution.Last updated -286Python