mcp

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromMCPServer

func FromMCPServer(cfg ServerConfig, opts ...Option) (extensionspkg.Extension, error)

Types

type Adapter

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

func (*Adapter) Health

func (*Adapter) Info

func (*Adapter) Invalidate

func (a *Adapter) Invalidate()

func (*Adapter) Reload

func (a *Adapter) Reload(ctx context.Context) error

func (*Adapter) ResolveTools

func (a *Adapter) ResolveTools(ctx context.Context) ([]extensionspkg.ExtensionTool, error)

type Client

type Client interface {
	Discover(ctx context.Context, cfg ServerConfig) (ServerSnapshot, error)
	CallTool(ctx context.Context, cfg ServerConfig, toolName string, raw json.RawMessage) (string, error)
}

type ClientError

type ClientError struct {
	Code    ClientErrorCode
	Message string
	Err     error
}

func (*ClientError) Error

func (e *ClientError) Error() string

func (*ClientError) Unwrap

func (e *ClientError) Unwrap() error

type ClientErrorCode

type ClientErrorCode string
const (
	ClientErrorInvalidConfig   ClientErrorCode = "invalid_config"
	ClientErrorTransport       ClientErrorCode = "transport_error"
	ClientErrorProtocol        ClientErrorCode = "protocol_error"
	ClientErrorTimeout         ClientErrorCode = "timeout"
	ClientErrorHandshakeFailed ClientErrorCode = "handshake_failed"
	ClientErrorListToolsFailed ClientErrorCode = "tools_list_failed"
	ClientErrorCallFailed      ClientErrorCode = "call_failed"
	ClientErrorPermission      ClientErrorCode = "permission_denied"
	ClientErrorInvalidArgs     ClientErrorCode = "invalid_args"
)

type Option

type Option func(*adapterOptions)

func WithClient

func WithClient(client Client) Option

func WithEagerDiscover

func WithEagerDiscover(enabled bool) Option

func WithRefreshTTL

func WithRefreshTTL(ttl time.Duration) Option

type ServerConfig

type ServerConfig struct {
	ID               string
	Name             string
	Version          string
	ProtocolVersion  string
	ProtocolVersions []string
	Command          string
	Args             []string
	Env              map[string]string
	CWD              string
	StartupTimeout   time.Duration
	CallTimeout      time.Duration
	MaxConcurrency   int
	ToolOverrides    map[string]ToolOverride
}

type ServerSnapshot

type ServerSnapshot struct {
	ID      string
	Name    string
	Version string
	Tools   []ToolDescriptor
}

type StdioClient

type StdioClient struct{}

func NewStdioClient

func NewStdioClient() *StdioClient

func (*StdioClient) CallTool

func (c *StdioClient) CallTool(ctx context.Context, cfg ServerConfig, toolName string, raw json.RawMessage) (string, error)

func (*StdioClient) Discover

func (c *StdioClient) Discover(ctx context.Context, cfg ServerConfig) (ServerSnapshot, error)

type ToolDescriptor

type ToolDescriptor struct {
	Name        string
	Description string
	InputSchema map[string]any
}

type ToolOverride

type ToolOverride struct {
	SafetyClass     string
	ReadOnly        *bool
	Destructive     *bool
	AllowedModes    []string
	DefaultTimeoutS int
	MaxTimeoutS     int
	MaxResultChars  int
}

Jump to

Keyboard shortcuts

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