mcpclient

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client wraps the MCP SDK client for health checks and tool discovery

func NewClient

func NewClient() *Client

NewClient creates a new MCP client wrapper

func (*Client) CallTool

func (c *Client) CallTool(ctx context.Context, server *mcp.Server, toolName string, arguments map[string]any) ToolCallResult

CallTool connects to a server and calls a specific tool with arguments

func (*Client) CheckHealth

func (c *Client) CheckHealth(ctx context.Context, server *mcp.Server) HealthResult

CheckHealth performs a health check on an MCP server It connects, performs the initialize handshake, and optionally lists tools

func (*Client) ListTools

func (c *Client) ListTools(ctx context.Context, server *mcp.Server) ([]Tool, error)

ListTools connects to a server and returns its available tools

func (*Client) WithTimeout

func (c *Client) WithTimeout(d time.Duration) *Client

WithTimeout sets the timeout for client operations

type HealthResult

type HealthResult struct {
	Healthy    bool          `json:"healthy"`
	ServerName string        `json:"serverName,omitempty"`
	Version    string        `json:"version,omitempty"`
	Tools      []Tool        `json:"tools,omitempty"`
	Error      error         `json:"error,omitempty"`
	Latency    time.Duration `json:"latency"`
}

HealthResult represents the result of a health check

type Tool

type Tool struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

Tool represents an MCP tool exposed by a server

type ToolCallResult

type ToolCallResult struct {
	Success bool          `json:"success"`
	Content []string      `json:"content,omitempty"` // Text content from the result
	IsError bool          `json:"isError,omitempty"`
	Error   error         `json:"error,omitempty"`
	Latency time.Duration `json:"latency"`
}

ToolCallResult represents the result of calling a tool

Jump to

Keyboard shortcuts

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