Documentation
¶
Overview ¶
Package mcpclient provides a Go client that speaks Model Context Protocol (MCP) over stdio to downstream MCP servers running as subprocesses.
Communication uses newline-delimited JSON-RPC 2.0 over the subprocess's stdin (requests) and stdout (responses).
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 a connection to a single downstream MCP server subprocess.
func NewClient ¶
NewClient spawns a downstream MCP server as a subprocess and performs the MCP initialize handshake. The command slice must contain at least the program name; additional elements are passed as arguments. The env slice is merged with os.Environ() so the subprocess inherits the current environment plus any overrides.
func (*Client) CallTool ¶
func (c *Client) CallTool(_ context.Context, name string, arguments map[string]any) (*mcp.ToolResult, error)
CallTool invokes a tool on the downstream MCP server by name.
func (*Client) Close ¶
Close terminates the subprocess. It sends SIGTERM first, then SIGKILL after a 5-second timeout if the process hasn't exited.
func (*Client) DiscoverTools ¶
DiscoverTools sends a tools/list request and caches the result.