MCPAdapt

MCPAdapt

site icon
2025.04.16 296
Python工具适配器代理框架扩展开发效率
MCPAdapt 是一个开源项目,旨在将 650+ 个 MCP 服务器的工具无缝集成到任何代理框架中。它通过 Model Context Protocol (MCP) 协议,使开发者能够轻松地在代理工作流中调用这些工具。MCPAdapt 支持多种代理框架,包括 smolagents、langchain、crewAI 和 google-genai 等。
View on GitHub

Overview

基本能力

产品定位

MCPAdapt 是一个工具适配器,旨在将 MCP 服务器的工具集成到各种代理框架中,以扩展代理的功能。

核心功能

  • 支持 650+ 个 MCP 服务器的工具调用。
  • 提供多种代理框架的适配器(如 smolagents、langchain、crewAI、google-genai 等)。
  • 支持本地和远程 MCP 服务器(通过 SSE)。
  • 提供简单的 API 来集成 MCP 工具到代理工作流中。

适用场景

  • 在代理工作流中快速集成外部工具。
  • 扩展代理的功能,使其能够访问大量 MCP 服务器提供的工具。
  • 开发自定义代理框架时,快速集成 MCP 工具。

工具列表

  • Smolagents 适配器:直接集成到 smolagents 的工具集合中。
  • Langchain 适配器:将 MCP 工具适配到 Langchain 框架中。
  • CrewAI 适配器:将 MCP 工具适配到 CrewAI 框架中。
  • Google-GenAI 适配器:将 MCP 工具适配到 Google GenAI 框架中。

常见问题解答

  • 安全性警告:使用 MCP 服务器时,尤其是通过 SSE,务必仅连接可信和已验证的服务器。
  • 框架支持:目前支持 smolagents、langchain、crewAI 和 google-genai,其他框架(如 pydantic-ai、llamaindex)正在开发中。

使用教程

使用依赖

安装 MCPAdapt 前,需要安装 Python 和 pip 或 uv。

安装教程

Smolagents

uv add smolagents[mcp]

其他框架

# 使用 uv
uv add mcpadapt[langchain]

# 或使用 pip
pip install mcpadapt[langchain]

调试方式

Smolagents

from mcp import StdioServerParameters
from smolagents.tools import ToolCollection

serverparams = StdioServerParameters(command="uv", args=["run", "src/echo.py"])

with ToolCollection.from_mcp(serverparams) as tool_collection:
    ... # 使用工具

其他框架

from mcp import StdioServerParameters
from mcpadapt.core import MCPAdapt
from mcpadapt.smolagents_adapter import SmolAgentsAdapter

with MCPAdapt(
    StdioServerParameters(command="uv", args=["run", "src/echo.py"]),
    SmolAgentsAdapter(),
) as tools:
    ... # 使用工具

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。