Expand description
MCP (Model Context Protocol) 组件
定义 MCP 客户端接口,用于连接外部 MCP 服务器并使用其工具。
§概述
MCP 是 Anthropic 提出的标准化协议,允许 AI Agent 与外部工具服务器通信。 本模块定义了 MoFA 框架中的 MCP 客户端抽象。
§架构
┌─────────────────────────────────────────────┐
│ MoFA Agent │
│ ┌─────────────────────────────────────────┐│
│ │ ToolRegistry ││
│ │ ┌───────────┐ ┌───────────────────┐ ││
│ │ │ Built-in │ │ McpToolAdapter │ ││
│ │ │ Tools │ │ (per MCP tool) │ ││
│ │ └───────────┘ └────────┬──────────┘ ││
│ └──────────────────────────┼──────────────┘│
└─────────────────────────────┼───────────────┘
│
┌──────────▼──────────┐
│ McpClient │
│ (manages MCP │
│ connections) │
└──────────┬──────────┘
│
┌────────────────┼────────────────┐
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ MCP Server A │ │ MCP Server B │ │ MCP Server C │
│ (stdio) │ │ (HTTP) │ │ (stdio) │
└──────────────┘ └──────────────┘ └──────────────┘Structs§
- McpServer
Config - MCP 服务器配置
- McpServer
Info - MCP 服务器信息
- McpTool
Info - MCP 工具信息
Enums§
- McpTransport
Config - MCP 服务器传输配置
Traits§
- McpClient
- MCP 客户端 Trait