Documentation
¶
Overview ¶
@sk-task ecosystem#T2.2: MCP client (connect, tools/list, tools/call)
@sk-task ecosystem#T2.1: MCP package (stdio + SSE transports, JSON-RPC 2.0)
Index ¶
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 manages an MCP server connection.
func (*Client) CallTool ¶
CallTool calls the MCP tools/call method with the given name and arguments.
type JSONRPCError ¶
JSONRPCError represents a JSON-RPC error.
type JSONRPCRequest ¶
type JSONRPCRequest struct {
JSONRPC string `json:"jsonrpc"`
ID int `json:"id"`
Method string `json:"method"`
Params any `json:"params,omitempty"`
}
JSONRPCRequest is a JSON-RPC 2.0 request.
type JSONRPCResponse ¶
type JSONRPCResponse struct {
JSONRPC string `json:"jsonrpc"`
ID int `json:"id"`
Result json.RawMessage `json:"result,omitempty"`
Error *JSONRPCError `json:"error,omitempty"`
}
JSONRPCResponse is a JSON-RPC 2.0 response.
type ListToolsResult ¶
type ListToolsResult struct {
Tools []ToolDescriptor `json:"tools"`
}
ListToolsResult is the result of a tools/list call.
type SSETransport ¶
type SSETransport struct {
// contains filtered or unexported fields
}
SSETransport connects to an MCP server via HTTP SSE.
func NewSSETransport ¶
func NewSSETransport(url string) *SSETransport
NewSSETransport creates a new SSE transport for the given URL.
func (*SSETransport) Close ¶
func (t *SSETransport) Close() error
Close shuts down the SSE transport and releases resources.
func (*SSETransport) Connect ¶
func (t *SSETransport) Connect(ctx context.Context) error
Connect establishes the HTTP SSE connection to the MCP server.
func (*SSETransport) Receive ¶
func (t *SSETransport) Receive() ([]byte, error)
Receive reads the next event from the SSE stream.
func (*SSETransport) Send ¶
func (t *SSETransport) Send(msg []byte) error
Send posts a message to the MCP server via HTTP POST.
type StdioTransport ¶
type StdioTransport struct {
// contains filtered or unexported fields
}
StdioTransport connects to an MCP server via subprocess stdin/stdout.
func NewStdioTransport ¶
func NewStdioTransport(command string, args ...string) *StdioTransport
NewStdioTransport creates a new stdio transport for the given command.
func (*StdioTransport) Close ¶
func (t *StdioTransport) Close() error
Close stops the subprocess and cleans up resources.
func (*StdioTransport) Connect ¶
func (t *StdioTransport) Connect(ctx context.Context) error
Connect starts the subprocess and prepares stdin/stdout for communication.
func (*StdioTransport) Receive ¶
func (t *StdioTransport) Receive() ([]byte, error)
Receive reads the next message from the subprocess stdout.
func (*StdioTransport) Send ¶
func (t *StdioTransport) Send(msg []byte) error
Send writes a message to the subprocess stdin.
type ToolAdapter ¶
type ToolAdapter struct {
// contains filtered or unexported fields
}
ToolAdapter adapts an MCP ToolDescriptor to the tools.Tool interface.
func NewToolAdapter ¶
func NewToolAdapter(desc ToolDescriptor, client *Client) *ToolAdapter
NewToolAdapter creates a new ToolAdapter.
func (*ToolAdapter) Description ¶
func (a *ToolAdapter) Description() string
Description implements the Tool interface.
func (*ToolAdapter) Parameters ¶
func (a *ToolAdapter) Parameters() map[string]any
Parameters implements the Tool interface.
type ToolCallResult ¶
type ToolCallResult struct {
Content []ToolContent `json:"content"`
IsError bool `json:"isError"`
}
ToolCallResult is the result of a tools/call.
type ToolContent ¶
ToolContent represents content returned by an MCP tool.
type ToolDescriptor ¶
type ToolDescriptor struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema any `json:"inputSchema"`
}
ToolDescriptor represents metadata about an MCP tool from tools/list.