transport

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RedactURL

func RedactURL(raw string) string

func SupportedProtocolVersions

func SupportedProtocolVersions() []string

Types

type Client

type Client struct {
	HTTPClient       *http.Client
	MaxRetries       int
	RetryDelay       time.Duration
	RetryMaxDelay    time.Duration
	AuthToken        string
	ExtraHeaders     map[string]string
	SnapshotRecorder SnapshotRecorder
	TrustedDomains   []string

	// Stderr is the writer for warning messages. Defaults to os.Stderr.
	Stderr io.Writer
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client) *Client

func (*Client) CallTool

func (c *Client) CallTool(ctx context.Context, endpoint, tool string, arguments map[string]any) (ToolCallResult, error)

func (*Client) Initialize

func (c *Client) Initialize(ctx context.Context, endpoint string) (InitializeResult, error)

func (*Client) ListTools

func (c *Client) ListTools(ctx context.Context, endpoint string) (ToolsListResult, error)

func (*Client) NotifyInitialized

func (c *Client) NotifyInitialized(ctx context.Context, endpoint string) error

func (*Client) WithAuth

func (c *Client) WithAuth(token string, headers map[string]string) *Client

WithAuth returns a shallow copy of c with the given auth token and extra headers. The returned client shares the underlying HTTP client but is safe to use concurrently with the original.

type ContentBlock

type ContentBlock struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

type InitializeResult

type InitializeResult struct {
	RequestedProtocolVersion string         `json:"requested_protocol_version"`
	ProtocolVersion          string         `json:"protocol_version"`
	Capabilities             map[string]any `json:"capabilities"`
	ServerInfo               map[string]any `json:"server_info"`
}

type RPCError

type RPCError struct {
	Code    int             `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
}

type SnapshotRecorder

type SnapshotRecorder interface {
	RecordJSONRPC(method, endpoint string, requestBody, responseBody []byte) string
}

type ToolCallResult

type ToolCallResult struct {
	Content           map[string]any `json:"-"`
	StructuredContent map[string]any `json:"structuredContent,omitempty"`
	Blocks            []ContentBlock `json:"content,omitempty"`
	IsError           bool           `json:"isError,omitempty"`
}

func (*ToolCallResult) UnmarshalJSON

func (r *ToolCallResult) UnmarshalJSON(data []byte) error

type ToolDescriptor

type ToolDescriptor struct {
	Name         string         `json:"name"`
	Title        string         `json:"title"`
	Description  string         `json:"description"`
	InputSchema  map[string]any `json:"inputSchema"`
	OutputSchema map[string]any `json:"outputSchema,omitempty"`
	Sensitive    bool           `json:"sensitive,omitempty"`
}

type ToolsListResult

type ToolsListResult struct {
	Tools []ToolDescriptor `json:"tools"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL