MCP 集成MCP integration
通过 stdio / SSE / streamable HTTP 连接 Model Context Protocol 服务,把远端工具纳入 Toolkit,并管理连接生命周期和鉴权头。Connect Model Context Protocol servers over stdio, SSE or streamable HTTP and expose their tools through the toolkit.
心智模型Mental model
MCP 客户端把远端 MCP 服务的工具、资源和提示词映射为本地 Toolkit 能力,连接方式包括 stdio、SSE 与 streamable HTTP。The MCP client maps remote tools, resources and prompts into the local toolkit over stdio, SSE or streamable HTTP.
先学什么What to learn first
- 连接是长生命周期资源:启动时注册,关闭时释放,并处理断线重连。Connections are long-lived resources: register on startup, release on shutdown, handle reconnects.
- stdio 适合本地进程,HTTP 适合多租户远程服务,注意鉴权头透传。Use stdio for local processes and HTTP for multi-tenant remote services; forward auth headers carefully.
- 远端工具名可能冲突,注册时统一加前缀并做白名单。Remote tool names can collide; prefix them and enforce an allowlist.
生产常见坑Production pitfalls
- 每次请求都新建 MCP 连接,造成握手风暴。Creating an MCP connection per request causes handshake storms.
- MCP 服务超时被当成模型错误处理。Treating MCP timeouts as model errors.
域内图谱Domain map
点击节点打开 API 页面;拖拽平移,滚轮缩放。Click a node to open its API page. Drag to pan, scroll to zoom.
Python API 集Python API set 3
归入本功能域的全部 Python 公开类型,按所属包分组。Every public Python type classified into this domain, grouped by owning package.
agentscope.mcp3
HttpMCPConfig | class | HTTP MCP 服务端配置。 |
MCPClient | class | MCP 客户端 |
StdioMCPConfig | class | stdio MCP 配置,保存相关配置项。 |
Java API 集Java API set 4
归入本功能域的全部 Java 公开类型,按包分组并标注构件。Every public Java type classified into this domain, grouped by package with its artifact.
io.agentscope.extensions.nacos.mcp.client3
NacosMcpClientBuilder | class | agentscope-extensions-mcp-nacos | Nacos MCP 客户端构建器,用于构建并配置目标实例。 |
NacosMcpClientWrapper | class | agentscope-extensions-mcp-nacos | Nacos MCP 客户端包装器,把 MCP 服务提供的工具接入智能体。 |
RefreshHook | interface | agentscope-extensions-mcp-nacos | 定义刷新钩子契约的接口。 |
io.agentscope.extensions.nacos.mcp1
NacosMcpServerManager | class | agentscope-extensions-mcp-nacos | Nacos MCP 服务端管理器,把 MCP 服务提供的工具接入智能体。 |
Python ↔ Java 对照Python ↔ Java
Python
Java
McpClientBuilderMcpClientWrapperMcpTool两套实现共享同一概念模型,但在并发(async/await 与 Reactor)、打包(wheel 模块与 Maven 构件)和生命周期 API 上存在差异。需要精确签名时请使用 API 全景。The two implementations follow the same conceptual model but differ in concurrency (async/await vs Reactor), packaging (wheel modules vs Maven artifacts) and lifecycle APIs. Use the full API map to locate exact signatures.