fastagent简化版的agent与mcp client

https://fast-agent.ai/#getting-started

fast-agent lets you create and interact with sophisticated Agents and Workflows in minutes. It's multi-modal - supporting Images and PDFs in Prompts, Resources and MCP Tool Call results.
fast-agent 允许您在几分钟内创建复杂的代理和工作流并与之交互。它是多模态的 - 在提示、资源和 MCP 工具调用结果中支持图像和 PDF。

Prebuilt agents and examples implementing the patterns in Anthropic's building effective agents paper get you building valuable applications quickly. Seamlessly use MCP Servers with your agents, or host your agents as MCP Servers.
在 Anthropic 的 Building effective agents 论文中实施模式的预构建代理和示例可帮助您快速构建有价值的应用程序。将 MCP 服务器与您的代理无缝使用,或将您的代理托管为 MCP 服务器。

uv pip install fast-agent-mcp - Install fast-agent.
uv pip install fast-agent-mcp - 安装 fast-agent。
fast-agent setup - Create Agent and Configuration files.
fast-agent setup - 创建代理和配置文件。
uv run agent.py - Run your first Agent
uv run agent.py - 运行您的第一个代理
fast-agent quickstart workflow - Create Agent workflow examples
fast-agent quickstart workflow - 创建代理工作流示例

简化版本的agent框架和mcp client:
fastagent.config.yaml

# Example of a STDIO sever named "fetch"
mcp:
  servers:
    fetch:
      command: "uvx"
      args: ["mcp-server-fetch"]

agent.py

@fast.agent(
    "url_fetcher",
    "Given a URL, provide a complete and comprehensive summary",
    servers=["fetch"], # Name of an MCP Server defined in fastagent.config.yaml
)
@fast.agent(
    "social_media",
    """
    Write a 280 character social media post for any given text.
    Respond only with the post, never use hashtags.
    """,
)
@fast.chain(
    name="post_writer",
    sequence=["url_fetcher", "social_media"],
)
async def main():
    async with fast.run() as agent:
        # using chain workflow
        await agent.post_writer("http://fast-agent.ai")

 

posted @ 2025-06-02 23:45  iTech  阅读(376)  评论(0)    收藏  举报