一个 Python 库,扩展了 CrewAI 的适配器生态系统,支持 模型上下文协议 (MCP) 集成,并提供了用于自定义代理和工具开发的全面工具。
您可以直接从 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())
详细文档请参阅:
crewai 包pydantic 包mcp 包pip install -e ".[test,docs]"
pytest tests/ -v
要发布新版本到 PyPI:
python -m build
python -m twine upload dist/*
本项目采用 MIT 许可证 - 详情请参阅 LICENSE 文件。
欢迎贡献!请随时提交 Pull Request。