Client

Note that the MCP.Client using the [Model Context Protocol Go SDK v1.5.0](https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk@v1.5.0).
View as Markdown

Methods

addEventListener

Adds a handler for the specified MCP.ServerEvents or MCP.Events event. Use only functions as handlers; anything except a function leads to the error and scenario termination when a handler is called.

1addEventListener(event: MCP.Events | MCP.ServerEvents | T, callback: (event: MCP._ClientEvents[T]) => any): void

Parameters

event
MCP.Events | MCP.ServerEvents | TRequired
callback
(event: MCP._ClientEvents[T]) => anyRequired

callTool

Call a tool from the MCP server. https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk@v1.5.0/mcp#CallToolParams

1callTool(parameters: Object): void

Parameters

parameters
ObjectRequired

close

Closes the connection (over WebSocket) or connection attempt.

1close(): void

id

Returns the Client id.

1id(): string

listTools

List the tools available from the MCP server. https://pkg.go.dev/github.com/modelcontextprotocol/go-sdk@v1.5.0/mcp#ListToolsParams

1listTools(parameters: Object): void

Parameters

parameters
ObjectRequired

removeEventListener

Removes a handler for the specified MCP.ServerEvents or MCP.Events event.

1removeEventListener(event: MCP.Events | MCP.ServerEvents | T, callback?: (event: MCP._ClientEvents[T]) => any): void

Parameters

event
MCP.Events | MCP.ServerEvents | TRequired
callback
(event: MCP._ClientEvents[T]) => any

webSocketId

Returns the WebSocket id.

1webSocketId(): string