| """智能体通信协议模块 |
| |
| 本模块提供三种主要的智能体通信协议: |
| - MCP (Model Context Protocol): 模型上下文协议 |
| - A2A (Agent-to-Agent Protocol): 智能体间通信协议 |
| - ANP (Agent Network Protocol): 智能体网络协议 |
| |
| 简洁导入示例: |
| >>> from hello_agents.protocols import MCPClient, MCPServer |
| >>> from hello_agents.protocols import A2AServer, A2AClient, AgentNetwork |
| >>> from hello_agents.protocols import ANPDiscovery, ANPNetwork |
| |
| 完整导入示例(向后兼容): |
| >>> from hello_agents.protocols.mcp import MCPClient, MCPServer |
| >>> from hello_agents.protocols.a2a import A2AServer, A2AClient |
| >>> from hello_agents.protocols.anp import ANPDiscovery, ANPNetwork |
| """ |
|
|
| from .base import Protocol |
|
|
| |
| try: |
| from .mcp import ( |
| MCPClient, |
| MCPServer, |
| create_context, |
| parse_context, |
| ) |
| MCP_AVAILABLE = True |
| except ImportError: |
| MCP_AVAILABLE = False |
| |
| class MCPClient: |
| def __init__(self, *args, **kwargs): |
| raise ImportError("MCP requires fastmcp: pip install fastmcp") |
| class MCPServer: |
| def __init__(self, *args, **kwargs): |
| raise ImportError("MCP requires fastmcp: pip install fastmcp") |
| def create_context(*args, **kwargs): |
| raise ImportError("MCP requires fastmcp: pip install fastmcp") |
| def parse_context(*args, **kwargs): |
| raise ImportError("MCP requires fastmcp: pip install fastmcp") |
|
|
| |
| from .a2a import ( |
| A2AAgent, |
| A2AServer, |
| A2AClient, |
| AgentNetwork, |
| AgentRegistry, |
| A2AMessage, |
| MessageType, |
| create_message, |
| parse_message, |
| ) |
|
|
| |
| from .anp import ( |
| ANPDiscovery, |
| ANPNetwork, |
| ServiceInfo, |
| register_service, |
| discover_service, |
| ) |
|
|
| __all__ = [ |
| |
| "Protocol", |
|
|
| |
| "MCPClient", |
| "MCPServer", |
| "create_context", |
| "parse_context", |
|
|
| |
| "A2AAgent", |
| "A2AServer", |
| "A2AClient", |
| "AgentNetwork", |
| "AgentRegistry", |
| "A2AMessage", |
| "MessageType", |
| "create_message", |
| "parse_message", |
|
|
| |
| "ANPDiscovery", |
| "ANPNetwork", |
| "ServiceInfo", |
| "register_service", |
| "discover_service", |
| ] |
|
|
|
|