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

mcptoolset

package
v1.41.2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package mcptoolset provides a Toolset implementation for MCP servers.

MCP (Model Context Protocol) allows connecting to external tool servers that expose tools via a standardized protocol.

The toolset uses lazy initialization - the MCP connection is only established when Tools() is first called.

Transport Support:

  • stdio: Uses mcp-go library for subprocess communication
  • sse, streamable-http: Uses Hector's httpclient with retry/backoff

Index

Constants

View Source
const (
	// DefaultSSEResponseTimeout is the default timeout for reading SSE responses
	// Set to 5 minutes to accommodate long-running operations
	DefaultSSEResponseTimeout = 5 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Name identifies this toolset.
	Name string

	// URL is the MCP server URL (for HTTP transports).
	URL string

	// Transport specifies the MCP transport (sse, streamable-http, stdio).
	Transport string

	// Command for stdio transport.
	Command string

	// Args for stdio transport.
	Args []string

	// Env for stdio transport.
	Env map[string]string

	// Filter limits which tools are exposed.
	Filter []string

	// MaxRetries for HTTP requests (default: 3).
	MaxRetries int

	// SSETimeout for SSE response reading (default: 5m).
	SSETimeout time.Duration
}

Config configures an MCP toolset.

type Toolset

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

Toolset is an MCP-backed toolset with lazy initialization.

func New

func New(cfg Config) (*Toolset, error)

New creates a new MCP toolset.

func (*Toolset) Close

func (t *Toolset) Close() error

Close closes the MCP connection.

func (*Toolset) Name

func (t *Toolset) Name() string

Name returns the toolset name.

func (*Toolset) Tools

func (t *Toolset) Tools(ctx agent.ReadonlyContext) ([]tool.Tool, error)

Tools returns the available tools, connecting lazily if needed.

func (*Toolset) WithFilter

func (t *Toolset) WithFilter(filter []string) tool.Toolset

WithFilter returns a new toolset that wraps this one with a specific filter. The returned toolset shares the underlying connection.

Jump to

Keyboard shortcuts

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