Aider MCP 服务器 - 实验性
模型上下文协议服务器,用于将AI编码工作卸载到Aider,提高开发效率和灵活性。
概述
该服务器允许 Claude Code 将 AI 编码任务分流给最佳开源 AI 编码助手 Aider。通过将某些编码任务委托给 Aider,我们可以降低成本,更好地控制编码模型,并以更协调的方式运行 Claude Code 来审查和修改代码。
设置
- 克隆存储库:
- 安装依赖项:
- 创建您的环境文件:
- 在
.env
文件中配置您的 API 密钥(或使用 mcpServers 的“env”部分)以获取您想要在 aider 中使用的模型所需的 api 密钥:
- 将
.mcp.json
复制并填写到项目的根目录中,并更新--directory
以指向该项目的根目录,以及--current-working-dir
以指向项目的根目录。
测试
使用 gemini-2.5-pro-exp-03-25 进行测试
运行所有测试:
运行特定测试:
注意:AI 编码测试需要 Gemini 模型的有效 API 密钥。请确保在运行测试之前将其设置在.env
文件中。
将此 MCP 服务器添加到 Claude Code
添加gemini-2.5-pro-exp-03-25
添加gemini-2.5-pro-preview-03-25
添加quasar-alpha
使用llama4-maverick-instruct-basic
添加
用法
该 MCP 服务器提供以下功能:
- 将 AI 编码任务卸载到 Aider :
- 接受提示和文件路径
- 使用 Aider 来实现所请求的更改
- 返回成功或失败
- 列出可用的模型:
- 提供与子字符串匹配的模型列表
- 对于发现支持的模型很有用
可用工具
该 MCP 服务器公开以下工具:
1. aider_ai_code
该工具允许您运行 Aider 根据提供的提示和指定的文件执行 AI 编码任务。
参数:
ai_coding_prompt
(字符串,必需):AI 编码任务的自然语言指令。relative_editable_files
(字符串列表,必需):Aider 允许修改的文件路径列表(相对于current_working_dir
)。如果文件不存在,则会创建该文件。relative_readonly_files
(字符串列表,可选):Aider 可以读取但无法修改的文件路径列表(相对于current_working_dir
)。默认为空列表[]
。model
(字符串,可选):Aider 用于生成代码的主要 AI 模型。默认为"gemini/gemini-2.5-pro-exp-03-25"
。您可以使用list_models
工具查找其他可用模型。editor_model
(字符串,可选):Aider 用于编辑/优化代码的 AI 模型,尤其是在使用架构师模式时。如果未提供,则可能会根据 Aider 的内部逻辑使用主model
。默认为None
。
使用示例(在 MCP 请求中):
克劳德代码提示:
结果:
返回:
- 一个简单的字典:{success, diff}
success
:boolean - 操作是否成功。diff
:字符串-对文件所做更改的差异。
2. list_models
该工具列出了与给定子字符串匹配的 Aider 支持的可用 AI 模型。
参数:
substring
(字符串,必需):在可用模型名称中搜索的子字符串。
使用示例(在 MCP 请求中):
克劳德代码提示:
结果:
返回:
- 与提供的子字符串匹配的型号名称字符串列表。示例:
["gemini/gemini-1.5-flash", "gemini/gemini-1.5-pro", "gemini/gemini-pro"]
建筑学
服务器结构如下:
- 服务器层:处理 MCP 协议通信
- 原子层:独立的、纯功能组件
- 工具:特定功能(AI编码、列表模型)
- Utils :常量和辅助函数
- 数据类型:使用 Pydantic 的类型定义
所有组件都经过了彻底的可靠性测试。
代码库结构
该项目分为以下主要目录和文件:
src/aider_mcp_server
:包含主应用程序代码。atoms
:包含基本构建块。它们被设计为纯函数或具有最小依赖关系的简单类。tools
:这里的每个文件都实现了特定 MCP 工具(aider_ai_code
、list_models
)的核心逻辑。utils.py
:包含共享常量,如默认模型名称。data_types.py
:定义请求/响应结构的 Pydantic 模型,确保数据验证。logging.py
:为控制台和文件输出设置一致的日志格式。
server.py
:负责编排 MCP 服务器。它负责初始化服务器、注册在atoms/tools
目录中定义的工具、处理传入的请求、将其路由到相应的工具逻辑,并根据 MCP 协议返回响应。__main__.py
:提供命令行界面入口点(aider-mcp-server
),解析--editor-model
等参数并启动server.py
中定义的服务器。tests
:包含镜像src
目录结构的测试,确保每个组件(尤其是原子)按预期工作。
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.
允许 Claude Code 将 AI 编码任务卸载到 Aider,从而降低成本并更好地控制哪些模型处理特定的编码任务。
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
- -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