Documentation
¶
Overview ¶
Package mcp 把外部 MCP(Model Context Protocol)服务提供的工具接入 gobrave 的 工具框架(从 opencode internal/llm/agent/mcp-tools.go 迁移)。
与 opencode 的差异:
- 工具不再实现 opencode 的 tools.BaseTool,而是直接实现 gobrave 的 tool.Tool, 因此能被 tool.Registry / ToolRunner 统一调度(权限门禁、事件流都复用);
- 配置不再读取 opencode 的全局 config,而是由调用方显式传入 Server 列表;
- 不再把工具缓存在包级变量里,改为 Manager 实例持有缓存,便于测试与多实例。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MCPServer ¶
type MCPServer struct {
// Name 是配置中的服务名,工具名会被拼成 <server>_<tool>。
Name string
// Config 是该服务的连接配置。
Config Server
// Tool 是发现的工具定义。
Tool mcp.Tool
}
MCPServer 是一个 MCP 工具对应的服务端连接。
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 持有 MCP 工具发现结果(懒加载 + 进程内缓存)。
配置在构造时固定;如需热更新配置,请重新创建 Manager。
type Server ¶
type Server struct {
// Type 是传输类型:stdio / sse。
Type Type
// Command / Args / Env 仅 stdio 使用。
Command string
Args []string
Env []string
// URL / Headers 仅 sse 使用。
URL string
Headers map[string]string
}
Server 是一个 MCP 服务的连接配置。
Click to show internal directories.
Click to hide internal directories.