Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) CallTool(ctx context.Context, name string, arguments interface{}, ...) (*types.CallToolResponse, error)
- func (c *Client) CallTools(ctx context.Context, tools []types.ToolCall, extraArgs ...interface{}) (*types.CallToolsResponse, error)
- func (c *Client) CallToolsParallel(ctx context.Context, tools []types.ToolCall, extraArgs ...interface{}) (*types.CallToolsResponse, error)
- func (c *Client) CancelRequest(ctx context.Context, requestID interface{}) error
- func (c *Client) ClearAllHandlers()
- func (c *Client) CompleteProgress(ctx context.Context, token uint64) error
- func (c *Client) Connect(ctx context.Context, options ...types.ConnectionOptions) error
- func (c *Client) CreateProgress(ctx context.Context, total uint64) (uint64, error)
- func (c *Client) Disconnect(ctx context.Context) error
- func (c *Client) GetEventHandlers() map[string]int
- func (c *Client) GetInitResult() *types.InitializeResponse
- func (c *Client) GetLogLevel() types.LogLevel
- func (c *Client) GetMetaInfo() gouTypes.MetaInfo
- func (c *Client) GetNotificationHandlers() map[string]int
- func (c *Client) GetProgress(token uint64) (*types.Progress, error)
- func (c *Client) GetPrompt(ctx context.Context, name string, arguments map[string]interface{}) (*types.GetPromptResponse, error)
- func (c *Client) GetSample(ctx context.Context, itemType types.SampleItemType, itemName string, index int) (*types.SampleData, error)
- func (c *Client) Info() *types.ClientInfo
- func (c *Client) Initialize(ctx context.Context) (*types.InitializeResponse, error)
- func (c *Client) Initialized(ctx context.Context) error
- func (c *Client) IsConnected() bool
- func (c *Client) IsInitialized() bool
- func (c *Client) ListProgress() map[uint64]*types.Progress
- func (c *Client) ListPrompts(ctx context.Context, cursor string) (*types.ListPromptsResponse, error)
- func (c *Client) ListResources(ctx context.Context, cursor string) (*types.ListResourcesResponse, error)
- func (c *Client) ListSamples(ctx context.Context, itemType types.SampleItemType, itemName string) (*types.ListSamplesResponse, error)
- func (c *Client) ListTools(ctx context.Context, cursor string) (*types.ListToolsResponse, error)
- func (c *Client) OnError(handler types.ErrorHandler)
- func (c *Client) OnEvent(eventType string, handler func(event types.Event))
- func (c *Client) OnNotification(method string, handler types.NotificationHandler)
- func (c *Client) ReadResource(ctx context.Context, uri string) (*types.ReadResourceResponse, error)
- func (c *Client) RemoveEventHandler(eventType string, handler func(event types.Event))
- func (c *Client) RemoveNotificationHandler(method string, handler types.NotificationHandler)
- func (c *Client) SetLogLevel(ctx context.Context, level types.LogLevel) error
- func (c *Client) State() types.ConnectionState
- func (c *Client) SubscribeResource(ctx context.Context, uri string) error
- func (c *Client) TriggerErrorStandard(ctx context.Context, err error)
- func (c *Client) TriggerEvent(event types.Event)
- func (c *Client) TriggerNotification(ctx context.Context, notification types.Message)
- func (c *Client) UnsubscribeResource(ctx context.Context, uri string) error
- func (c *Client) UpdateProgress(ctx context.Context, token uint64, progress uint64) error
- type TestConfig
- type TestConnectionOptions
- type TestDSLInfo
- type TransportTestCase
Constants ¶
const ( EnvHTTPURL = "MCP_CLIENT_TEST_HTTP_URL" EnvHTTPToken = "MCP_CLIENT_TEST_HTTP_AUTHORIZATION_TOKEN" EnvSSEURL = "MCP_CLIENT_TEST_SSE_URL" EnvSSEToken = "MCP_CLIENT_TEST_SSE_AUTHORIZATION_TOKEN" )
Test environment variable names
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
DSL *types.ClientDSL
MCPClient *goclient.Client
InitResult *types.InitializeResponse // Store the initialization result
// contains filtered or unexported fields
}
Client the MCP Client
func (*Client) CallTool ¶
func (c *Client) CallTool(ctx context.Context, name string, arguments interface{}, extraArgs ...interface{}) (*types.CallToolResponse, error)
CallTool invokes a specific tool on the server extraArgs are ignored for HTTP/SSE/STDIO transports (only used for Process transport)
func (*Client) CallTools ¶
func (c *Client) CallTools(ctx context.Context, tools []types.ToolCall, extraArgs ...interface{}) (*types.CallToolsResponse, error)
CallTools calls multiple tools in sequence Tools are executed one by one, ensuring order and avoiding race conditions extraArgs are ignored for HTTP/SSE/STDIO transports (only used for Process transport)
func (*Client) CallToolsParallel ¶
func (c *Client) CallToolsParallel(ctx context.Context, tools []types.ToolCall, extraArgs ...interface{}) (*types.CallToolsResponse, error)
CallToolsParallel calls multiple tools concurrently All tools are executed in parallel for better performance Note: Results order matches the input order, but execution is concurrent extraArgs are ignored for HTTP/SSE/STDIO transports (only used for Process transport)
func (*Client) CancelRequest ¶
CancelRequest cancels a specific request
func (*Client) ClearAllHandlers ¶
func (c *Client) ClearAllHandlers()
ClearAllHandlers removes all registered handlers
func (*Client) CompleteProgress ¶
CompleteProgress marks a progress token as complete and removes it
func (*Client) CreateProgress ¶
CreateProgress creates a progress token for tracking
func (*Client) Disconnect ¶
Disconnect closes the connection to the MCP server
func (*Client) GetEventHandlers ¶
GetEventHandlers returns a copy of current event handlers (for debugging/inspection)
func (*Client) GetInitResult ¶
func (c *Client) GetInitResult() *types.InitializeResponse
GetInitResult returns the stored initialization result
func (*Client) GetLogLevel ¶
GetLogLevel returns the current log level
func (*Client) GetMetaInfo ¶
GetMetaInfo returns the meta information of the client
func (*Client) GetNotificationHandlers ¶
GetNotificationHandlers returns a copy of current notification handlers (for debugging/inspection)
func (*Client) GetProgress ¶
GetProgress returns the current progress for a given token
func (*Client) GetPrompt ¶
func (c *Client) GetPrompt(ctx context.Context, name string, arguments map[string]interface{}) (*types.GetPromptResponse, error)
GetPrompt gets a specific prompt with given arguments
func (*Client) GetSample ¶
func (c *Client) GetSample(ctx context.Context, itemType types.SampleItemType, itemName string, index int) (*types.SampleData, error)
GetSample retrieves a specific sample by index
func (*Client) Info ¶
func (c *Client) Info() *types.ClientInfo
Info returns basic client information
func (*Client) Initialize ¶
Initialize initializes the MCP client and exchanges capabilities with the server
func (*Client) Initialized ¶
Initialized sends the initialized notification to the server Note: In mcp-go v0.32.0, this is typically handled automatically after Initialize
func (*Client) IsConnected ¶
IsConnected checks if the client is connected to the server
func (*Client) IsInitialized ¶
IsInitialized checks if the client has been initialized
func (*Client) ListProgress ¶
ListProgress returns all active progress tokens
func (*Client) ListPrompts ¶
func (c *Client) ListPrompts(ctx context.Context, cursor string) (*types.ListPromptsResponse, error)
ListPrompts lists all available prompts
func (*Client) ListResources ¶
func (c *Client) ListResources(ctx context.Context, cursor string) (*types.ListResourcesResponse, error)
ListResources lists all available resources
func (*Client) ListSamples ¶
func (c *Client) ListSamples(ctx context.Context, itemType types.SampleItemType, itemName string) (*types.ListSamplesResponse, error)
ListSamples lists available training samples for a tool or resource
func (*Client) OnError ¶
func (c *Client) OnError(handler types.ErrorHandler)
OnError registers an error handler
func (*Client) OnNotification ¶
func (c *Client) OnNotification(method string, handler types.NotificationHandler)
OnNotification registers a notification handler for a specific method
func (*Client) ReadResource ¶
ReadResource reads a specific resource
func (*Client) RemoveEventHandler ¶
RemoveEventHandler removes an event handler for a specific event type
func (*Client) RemoveNotificationHandler ¶
func (c *Client) RemoveNotificationHandler(method string, handler types.NotificationHandler)
RemoveNotificationHandler removes a notification handler for a specific method
func (*Client) SetLogLevel ¶
SetLogLevel sets the log level for the server
func (*Client) State ¶
func (c *Client) State() types.ConnectionState
State returns the current connection state
func (*Client) SubscribeResource ¶
SubscribeResource subscribes to resource updates
func (*Client) TriggerErrorStandard ¶
TriggerErrorStandard triggers all registered error handlers with a standard error
func (*Client) TriggerEvent ¶
TriggerEvent triggers all registered event handlers for a specific event type
func (*Client) TriggerNotification ¶
TriggerNotification triggers all registered notification handlers for a specific method
func (*Client) UnsubscribeResource ¶
UnsubscribeResource unsubscribes from resource updates
type TestConfig ¶
type TestConfig struct {
HTTPUrl string
HTTPToken string
SSEUrl string
SSEToken string
SkipHTTPTests bool
SkipSSETests bool
SkipStdioTests bool
}
TestConfig holds test configuration
type TestConnectionOptions ¶
type TestConnectionOptions struct {
WithSessionID bool
WithCustomHeaders bool
WithTimeout bool
SessionID string
CustomHeaders map[string]string
ConnectionTimeout time.Duration
}
TestConnectionOptions provides common connection options for testing
type TestDSLInfo ¶
type TestDSLInfo struct {
Transport types.TransportType
Name string
URL string
HasToken bool
Command string
EnabledCaps []string
}
TestDSLInfo holds information about test DSL for logging