返回市场
crewai_mcp_适配器

crewai_mcp_适配器

作者:dshivendra15 星标更新:2025-07-28

项目介绍

MseeP.ai Security Assessment Badge

CrewAI MCP 适配器

一个 Python 库,扩展了 CrewAI 的适配器生态系统,支持 模型上下文协议 (MCP) 集成,并提供了用于自定义代理和工具开发的全面工具。

特性

  • 🔌 原生 CrewAI 集成和适配器模式
  • 🛠️ 支持 MCP 协议的工具集成
  • 🧩 易于使用的接口,用于扩展和创建新的适配器
  • 📝 使用 Pydantic 实现类型安全
  • 🔍 工具参数的 JSON Schema 验证
  • 🚀 异步/等待支持
  • 📊 详细的执行元数据

安装

您可以直接从 PyPI 安装该包:

pip install crewai-adapters

或者从源代码安装:

pip install git+https://github.com/dshivendra/crewai_mcp_adapter.git

快速开始

from crewai import Agent, Task
from crewai_adapters import CrewAIAdapterClient
from crewai_adapters.types import AdapterConfig

async def main():
    async with CrewAIAdapterClient() as client:
        # 连接到 MCP 服务器
        await client.connect_to_mcp_server(
            "math",
            command="python",
            args=["math_server.py"]
        )

        # 创建带有工具的代理
        agent = Agent(
            name="Calculator",
            goal="执行计算",
            tools=client.get_tools()
        )

        # 执行任务
        task = Task(
            description="计算 (3 + 5) × 12",
            agent=agent
        )
        result = await task.execute()
        print(f"结果: {result}")

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

文档

详细文档请参阅:

开发

先决条件

  • Python 3.11 或更高版本
  • crewai
  • pydantic
  • mcp

安装开发依赖

pip install -e ".[test,docs]"

运行测试

pytest tests/ -v

发布

要发布新版本到 PyPI:

  1. 更新 pyproject.toml 中的版本
  2. 构建包:
    python -m build
    
  3. 上传到 PyPI:
    python -m twine upload dist/*
    

许可证

本项目采用 MIT 许可证 - 详情请参阅 LICENSE 文件。

贡献

欢迎贡献!请随时提交 Pull Request。