Documentation
¶
Overview ¶
Package mcp is the harness's client of its one tool source: an MCP server reached over streamable HTTP with a bearer token. It lists the server's tools and calls them, and does nothing else the protocol offers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// URL is the server's streamable HTTP endpoint.
URL string
// Token returns the bearer token. It is called for every request.
Token func() string
// HTTP sends the requests.
HTTP *http.Client
// Name and Version identify the client to the server.
Name, Version string
// contains filtered or unexported fields
}
Client is a connection to one MCP server.
func (*Client) CallTool ¶
func (c *Client) CallTool(ctx context.Context, name string, arguments json.RawMessage) (*Result, error)
CallTool runs one tool. arguments is the JSON object of its arguments. A tool that reports an error is a Result with IsError set; an *Error means the call did not reach the tool or the server refused it.
func (*Client) Initialize ¶
Initialize opens the session. It must be called once before the others.
type Content ¶
type Content struct {
// Type is text, image, resource, or a type the client passes over.
Type string `json:"type"`
Text string `json:"text"`
// Data and MimeType hold an image, base64-encoded.
Data string `json:"data"`
MimeType string `json:"mimeType"`
// Resource is an embedded resource. Its text is content the server
// marked as its own to pass on whole.
Resource *struct {
URI string `json:"uri"`
MimeType string `json:"mimeType"`
Text string `json:"text"`
} `json:"resource"`
}
Content is one item of a tool's result.
type Error ¶
type Error struct {
// Status is the HTTP status, zero when there was none. Code is the
// JSON-RPC error code, zero when the failure was not one.
Status int
Code int
Message string
}
Error is a failure to reach the server, or the server's refusal.