Help us shape the future of Go! Take the 2026 Go Developer Survey

mcp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTransport   = errors.New("invalid transport type")
	ErrConnectionFailed   = errors.New("failed to connect to MCP server")
	ErrServerDisconnected = errors.New("server disconnected")
)

Functions

This section is empty.

Types

type Client

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

Client is a wrapper around an MCP client with common operations.

func NewClient

func NewClient(config ServerConfig) *Client

NewClient creates a new MCP client.

func (*Client) CallTool

func (c *Client) CallTool(ctx context.Context, name string, args map[string]interface{}) (interface{}, error)

CallTool invokes a tool with the given arguments.

func (*Client) Close

func (c *Client) Close() error

Close closes the connection to the MCP server.

func (*Client) Connect

func (c *Client) Connect(ctx context.Context) error

Connect establishes a connection to the MCP server.

func (*Client) GetCapabilities

func (c *Client) GetCapabilities() *mcp.ServerCapabilities

GetCapabilities returns the server capabilities.

func (*Client) GetMetadata

func (c *Client) GetMetadata(ctx context.Context) (*ServerMetadata, error)

GetMetadata retrieves server metadata.

func (*Client) IsConnected

func (c *Client) IsConnected() bool

IsConnected returns whether the client is connected.

func (*Client) ListResources

func (c *Client) ListResources(ctx context.Context) ([]ResourceInfo, error)

ListResources returns the list of available resources.

func (*Client) ListTools

func (c *Client) ListTools(ctx context.Context) ([]ToolInfo, error)

ListTools returns the list of available tools.

type ResourceInfo

type ResourceInfo struct {
	URI         string `json:"uri"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	MIMEType    string `json:"mimeType,omitempty"`
}

ResourceInfo contains information about a resource.

type ServerConfig

type ServerConfig struct {
	Type    TransportType     `json:"type"`
	Command string            `json:"command"`
	Args    []string          `json:"args"`
	Env     map[string]string `json:"env"`
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers"`
}

ServerConfig defines the configuration for connecting to an MCP server.

type ServerMetadata

type ServerMetadata struct {
	Name         string `json:"name"`
	Version      string `json:"version"`
	Protocol     string `json:"protocol"`
	Title        string `json:"title,omitempty"`
	Instructions string `json:"instructions,omitempty"`
	WebsiteURL   string `json:"websiteUrl,omitempty"`
}

ServerMetadata contains information about an MCP server.

type ToolInfo

type ToolInfo struct {
	Name        string                 `json:"name"`
	Description string                 `json:"description"`
	InputSchema map[string]interface{} `json:"inputSchema"`
}

ToolInfo contains information about a tool.

type TransportType

type TransportType string

TransportType specifies the transport protocol.

const (
	TransportStdio TransportType = "stdio"
	TransportHTTP  TransportType = "http"
)

Jump to

Keyboard shortcuts

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