Documentation
¶
Overview ¶
Package mcpclient is the client half of MCP - what this proxy needs to forward a call ONWARD to an upstream MCP server, as opposed to internal/adapter/mcp which is the server half that agents connect to.
Having both is what makes "put the firewall in front of the MCP server you already run" possible at all: the agent talks MCP to us, we talk MCP to the real server, and the agent never holds that server's credential - we do, configured once, and it never enters the agent's context.
Written against the same Streamable HTTP transport spec the server side was validated against, so it handles the parts a real upstream may use even though this project's own server doesn't: an Mcp-Session-Id assigned at initialize (which the spec says clients MUST echo on every later request), the MCP-Protocol-Version header, and an SSE-framed response, since the spec lets a server answer a POST with either a single JSON object or an event stream and requires clients to handle both.
Index ¶
- type CallResult
- type Client
- func (c *Client) CallTool(ctx context.Context, name string, args map[string]any) (CallResult, error)
- func (c *Client) CallToolWithMeta(ctx context.Context, name string, args, meta map[string]any) (CallResult, error)
- func (c *Client) Initialize(ctx context.Context) error
- func (c *Client) ListTools(ctx context.Context) ([]Tool, error)
- type Option
- type Tool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallResult ¶
CallResult mirrors MCP's tools/call result: content blocks plus an isError flag that is NOT a transport error - a tool can fail on its own terms and still return a perfectly valid JSON-RPC response.
func (CallResult) Text ¶
func (r CallResult) Text() string
Text flattens the content blocks into a single string, which is what nearly every MCP tool actually returns.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CallToolWithMeta ¶
func (c *Client) CallToolWithMeta(ctx context.Context, name string, args, meta map[string]any) (CallResult, error)
CallToolWithMeta is CallTool plus the spec's own `params._meta` extension field - the same channel this project's MCP server side already accepts run ids and taint through. The proxy uses it to hand an upstream the capability token minted for this exact call, so an upstream that wants to verify independently can, without that being required of one that doesn't.
func (*Client) Initialize ¶
Initialize performs the MCP handshake. Safe to call more than once - a second call is a no-op, so callers don't have to coordinate who initializes first.
type Option ¶
type Option func(*Client)
func WithAuthorization ¶
WithAuthorization sets a header sent on every request to the upstream - this is the credential the AGENT never gets to see.