mcp

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 12 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 manages a single MCP server connection, backed by modelcontextprotocol/go-sdk

func NewClient

func NewClient(cfg ServerConfig) *Client

NewClient creates a Client for the given server config.

func (*Client) CallTool

func (c *Client) CallTool(name string, args map[string]any) (string, error)

CallTool invokes a tool on the MCP server and returns the result text. When the server returns multiple content blocks, they are joined with newlines. If isError is true, the text is returned as an error. Connects lazily on first call.

func (*Client) Close

func (c *Client) Close() error

Close shuts down the server connection.

func (*Client) Tools

func (c *Client) Tools() []api.ToolSpec

Tools returns the list of tool specs discovered from this server. Connects lazily on first call.

type ServerConfig

type ServerConfig struct {
	Name    string            `json:"name"`
	Command string            `json:"command,omitempty"`
	Args    []string          `json:"args,omitempty"`
	URL     string            `json:"url,omitempty"`
	Env     map[string]string `json:"env,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
	Tools   []string          `json:"tools,omitempty"`
}

ServerConfig describes how to launch and connect to an MCP server. For local servers, specify Command and Args. For remote servers, specify URL.

Jump to

Keyboard shortcuts

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