Documentation
¶
Index ¶
- type Client
- func (c *Client) CallTool(ctx context.Context, serverName, toolName string, args json.RawMessage) (string, error)
- func (c *Client) Close()
- func (c *Client) Connect(ctx context.Context, cfg ServerConfig) error
- func (c *Client) ConnectAll(ctx context.Context) error
- func (c *Client) LoadConfigs(configs []ServerConfig)
- func (c *Client) RegisterToRegistry(registry *tool.Registry)
- func (c *Client) ToolCount() int
- type MCPTool
- type ServerConfig
- type StdioTransport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client MCP 客户端管理器
func (*Client) CallTool ¶
func (c *Client) CallTool(ctx context.Context, serverName, toolName string, args json.RawMessage) (string, error)
CallTool 调用 MCP 工具
func (*Client) Connect ¶
func (c *Client) Connect(ctx context.Context, cfg ServerConfig) error
Connect 连接单个 MCP 服务器
func (*Client) ConnectAll ¶
ConnectAll 连接所有配置的服务器
func (*Client) LoadConfigs ¶
func (c *Client) LoadConfigs(configs []ServerConfig)
LoadConfigs 从配置加载 MCP 服务器列表
func (*Client) RegisterToRegistry ¶
RegisterToRegistry 将 MCP 工具注册到 Xin Code 工具注册表
type MCPTool ¶
type MCPTool struct {
ServerName string `json:"server_name"`
Name string `json:"name"`
Description string `json:"description"`
InputSchema map[string]any `json:"input_schema"`
}
MCPTool MCP 发现的工具
type ServerConfig ¶
type ServerConfig struct {
Name string `json:"name"`
Command string `json:"command"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
}
ServerConfig MCP 服务器配置
type StdioTransport ¶
type StdioTransport struct {
// contains filtered or unexported fields
}
StdioTransport 通过子进程 stdin/stdout 的 MCP 传输
func NewStdioTransport ¶
func NewStdioTransport(command string, args []string, env map[string]string) *StdioTransport
NewStdioTransport 创建 stdio 传输
func (*StdioTransport) SendNotification ¶
func (t *StdioTransport) SendNotification(method string, params any) error
SendNotification 发送 JSON-RPC 通知(不需要响应)
func (*StdioTransport) SendRequest ¶
SendRequest 发送 JSON-RPC 请求并等待响应
Click to show internal directories.
Click to hide internal directories.