command 参数初始化 MCPTools 类即可。
您要传递的命令是用于运行代理可以访问的 MCP 服务器的命令。
例如 uvx mcp-server-git,它运行一个 git MCP 服务器:
MultiMCPTools 类。例如:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
command 参数初始化 MCPTools 类即可。
您要传递的命令是用于运行代理可以访问的 MCP 服务器的命令。
例如 uvx mcp-server-git,它运行一个 git MCP 服务器:
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.mcp import MCPTools
async with MCPTools(command=f"uvx mcp-server-git") as mcp_tools:
agent = Agent(model=OpenAIChat(id="gpt-4o"), tools=[mcp_tools])
await agent.aprint_response("What is the license for this project?", stream=True)
MultiMCPTools 类。例如:
import asyncio
import os
from agno.agent import Agent
from agno.tools.mcp import MultiMCPTools
async def run_agent(message: str) -> None:
"""使用给定的消息运行 Airbnb 和 Google Maps 代理。"""
env = {
**os.environ,
"GOOGLE_MAPS_API_KEY": os.getenv("GOOGLE_MAPS_API_KEY"),
}
async with MultiMCPTools(
[
"npx -y @openbnb/mcp-server-airbnb --ignore-robots-txt",
"npx -y @modelcontextprotocol/server-google-maps",
],
env=env,
) as mcp_tools:
agent = Agent(
tools=[mcp_tools],
markdown=True,
show_tool_calls=True,
)
await agent.aprint_response(message, stream=True)
# 示例用法
if __name__ == "__main__":
# Pull request 示例
asyncio.run(
run_agent(
"What listings are available in Cape Town for 2 people for 3 nights from 1 to 4 August 2025?"
)
)