mcpclient

package
v0.703.4 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultOperationTimeout = 30 * time.Second
	DefaultDiscoveryTimeout = 15 * time.Second
)

Variables

This section is empty.

Functions

func BuildCallError

func BuildCallError(serverName, toolName, operation string, err error) error

func BuildInitializeRequest

func BuildInitializeRequest(clientName string) mcp.InitializeRequest

func BuildTimeoutError

func BuildTimeoutError(serverName, operation string, timeout time.Duration) error

func Handshake added in v0.703.4

func Handshake(ctx context.Context, c Initializer, serverName string, srv config.MCPServer, clientName string) (*mcp.InitializeResult, error)

Handshake initializes c against the configured server and reports the outcome on the extension mcp topic. clientName identifies the part of the host that is connecting and travels both in the MCP client info and in the event, so an operator can tell a discovery pass from a gateway connection.

The error is returned unchanged: callers keep whatever handling they had, and the event is a side effect that cannot fail the connection.

func IsAuthorizationRequired added in v0.631.1

func IsAuthorizationRequired(err error) bool

IsAuthorizationRequired reports whether err indicates that an MCP server needs interactive OAuth authorization (e.g. no token yet, or a refresh token that no longer works). Callers such as the agent layer and the future `pando mcp login` command use this to detect that a tool call failure means "the user needs to (re-)authenticate this server" rather than a generic operational error.

func PublishError

func PublishError(serverName, message string)

func PublishWarn

func PublishWarn(serverName, message string)

func ResolveTimeout

func ResolveTimeout(raw string, fallback time.Duration) time.Duration

func WithTimeout

func WithTimeout(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc)

Types

type Client

type Client interface {
	Initialize(ctx context.Context, req mcp.InitializeRequest) (*mcp.InitializeResult, error)
	ListTools(ctx context.Context, req mcp.ListToolsRequest) (*mcp.ListToolsResult, error)
	CallTool(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error)
	Close() error
}

func New

func New(ctx context.Context, serverName string, srv config.MCPServer) (Client, error)

type Initializer added in v0.703.4

type Initializer interface {
	Initialize(ctx context.Context, req mcp.InitializeRequest) (*mcp.InitializeResult, error)
}

Initializer is the one method Handshake needs. It is declared here rather than taking Client so that the gateway's pooled client and the agent's own client interface both satisfy it without conversion.

Jump to

Keyboard shortcuts

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