mcp

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeNeedsAuth      = -32001
	ErrCodeSessionExpired = -32002
)
View Source
const DescriptionMCP = `` /* 1107-byte string literal not displayed */

Descriptions

View Source
const ListMcpResourcesToolName = "mcp_list_resources"
View Source
const MCPToolPrefix = "mcp__"

MCP tool name prefix

View Source
const ReadMcpResourceToolName = "mcp_read_resource"
View Source
const SearchHintMCP = "execute a tool from a connected MCP server"

Search hints

View Source
const ToolNameMCP = "mcp"

Tool name constants

Variables

This section is empty.

Functions

func AddMcpServer

func AddMcpServer(name string, config McpServerConfig, scope ConfigScope) error

func ConnectMcpServers

func ConnectMcpServers(ctx context.Context, manager *MCPClientManager, cwd string) error

func DoesEnterpriseConfigExist

func DoesEnterpriseConfigExist() bool

func GetEnterpriseConfigPath

func GetEnterpriseConfigPath() string

func GetGlobalConfigPath

func GetGlobalConfigPath() string

func GetProjectConfigPath

func GetProjectConfigPath(cwd string) string

func GetUserConfigDir

func GetUserConfigDir() string

func IsMcpServerDisabled

func IsMcpServerDisabled(name string, cwd string) bool

func ParseMcpConfigFromFile

func ParseMcpConfigFromFile(filePath string) (McpJsonConfig, []ValidationError)

func ReconnectMcpServer

func ReconnectMcpServer(ctx context.Context, manager *MCPClientManager, serverName string, cwd string) error

func RegisterPluginMcpServer

func RegisterPluginMcpServer(name string, source string, config McpServerConfig)

func RemoveMcpServer

func RemoveMcpServer(name string, scope ConfigScope) error

func SetMcpServerEnabled

func SetMcpServerEnabled(name string, enabled bool, cwd string) error

func ShouldUseOAuth

func ShouldUseOAuth() bool

Types

type Client

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

Client represents an MCP client

func NewClient

func NewClient(config ServerConfig) (*Client, error)

NewClient creates a new MCP client.

func (*Client) CallTool

func (c *Client) CallTool(ctx context.Context, name string, arguments map[string]any) (map[string]any, error)

CallTool calls a tool on the MCP server.

func (*Client) CallToolWithProgress

func (c *Client) CallToolWithProgress(
	ctx context.Context,
	name string,
	arguments map[string]any,
	onProgress ProgressCallback,
) (map[string]any, error)

CallToolWithProgress calls a tool and receives progress notifications via the provided callback. If onProgress is nil the call behaves like CallTool.

The server receives a _meta.progressToken so it knows to send progress updates.

func (*Client) CanonicalPrompt

func (c *Client) CanonicalPrompt(ctx context.Context, name string, arguments map[string]any) (*PromptResult, error)

CanonicalPrompt fetches a prompt and returns all messages.

func (*Client) CanonicalReadResource

func (c *Client) CanonicalReadResource(ctx context.Context, uri string) (*ResourceReadResult, error)

CanonicalReadResource reads a resource and returns the normalized result.

func (*Client) CanonicalToolCall

func (c *Client) CanonicalToolCall(ctx context.Context, name string, arguments map[string]any) (*ToolCallResult, error)

CanonicalToolCall executes an MCP tool and returns the normalized result.

func (*Client) Close

func (c *Client) Close() error

Close closes the MCP client.

func (*Client) Discovery

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

Discovery fetches all entities exposed by the server.

func (*Client) GetPrompt

func (c *Client) GetPrompt(ctx context.Context, name string, arguments map[string]any) (*PromptMessage, error)

GetPrompt gets a prompt from the MCP server.

func (*Client) Initialize

func (c *Client) Initialize(ctx context.Context) (*InitializeResult, error)

Initialize initializes the MCP server connection.

func (*Client) ListPrompts

func (c *Client) ListPrompts(ctx context.Context) ([]Prompt, error)

ListPrompts lists available prompts from the MCP server.

func (*Client) ListResources

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

ListResources lists available resources from the MCP server.

func (*Client) ListTools

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

ListTools lists available tools from the MCP server.

func (*Client) Metadata

func (c *Client) Metadata() ClientMetadata

Metadata returns a snapshot of the client metadata.

func (*Client) ReadResource

func (c *Client) ReadResource(ctx context.Context, uri string) ([]ResourceContent, error)

ReadResource reads a resource from the MCP server.

func (*Client) SetMethodsHandler

func (c *Client) SetMethodsHandler(handler MethodHandler)

SetMethodsHandler overrides the default server-method handler.

func (*Client) SetNotificationsHandler

func (c *Client) SetNotificationsHandler(handler NotificationHandler)

SetNotificationsHandler overrides the default notification dispatcher. Use this only if you need to intercept ALL notifications; prefer registering a per-call progress callback via CallToolWithProgress.

func (*Client) SetToolNameMode

func (c *Client) SetToolNameMode(mode ToolNameMode)

SetToolNameMode records how wrapped MCP tool names are exposed.

func (*Client) Start

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

Start starts the underlying transport but intentionally leaves the client in the pending state. Seshat only treats the connection as fully ready after the explicit MCP initialize handshake succeeds.

func (*Client) ToolNameMode

func (c *Client) ToolNameMode() ToolNameMode

ToolNameMode returns the current exposed name mode.

type ClientMetadata

type ClientMetadata struct {
	Status            ClientStatus `json:"status"`
	Initialized       bool         `json:"initialized"`
	ToolNameMode      ToolNameMode `json:"tool_name_mode"`
	LastError         string       `json:"last_error,omitempty"`
	LastInitializedAt *time.Time   `json:"last_initialized_at,omitempty"`
	ServerInfo        *ServerInfo  `json:"server_info,omitempty"`
	// ProtocolVersion is the MCP version agreed during initialize handshake.
	ProtocolVersion string `json:"protocol_version,omitempty"`
}

ClientMetadata captures runtime metadata about an MCP client.

type ClientStatus

type ClientStatus string

ClientStatus represents the lifecycle state of an MCP connection.

const (
	ClientStatusPending   ClientStatus = "pending"
	ClientStatusConnected ClientStatus = "connected"
	ClientStatusNeedsAuth ClientStatus = "needs_auth"
	ClientStatusExpired   ClientStatus = "expired"
	ClientStatusFailed    ClientStatus = "failed"
	ClientStatusClosed    ClientStatus = "closed"
)

type ConfigLoadResult

type ConfigLoadResult struct {
	Servers map[string]ScopedMcpServerConfig
	Errors  []ValidationError
}

func LoadMcpConfigs

func LoadMcpConfigs(cwd string) ConfigLoadResult

type ConfigScope

type ConfigScope string
const (
	ScopeProject    ConfigScope = "project"
	ScopeUser       ConfigScope = "user"
	ScopeLocal      ConfigScope = "local"
	ScopeEnterprise ConfigScope = "enterprise"
)

type ConnectServerConfig

type ConnectServerConfig struct {
	// Name is the server name
	Name string `json:"name"`

	// Command is the command to start the server (for stdio)
	Command string `json:"command,omitempty"`

	// Args are the command arguments (for stdio)
	Args []string `json:"args,omitempty"`

	// URL is the server URL (for http)
	URL string `json:"url,omitempty"`

	// Transport is the transport type ("stdio" or "http")
	Transport string `json:"transport"`

	// Env are environment variables
	Env map[string]string `json:"env,omitempty"`

	// Timeout is the timeout in seconds
	Timeout int `json:"timeout"`

	// Headers are HTTP headers (for http transport)
	Headers map[string]string `json:"headers,omitempty"`
}

ConnectServerConfig is the config for connecting to an MCP server

type Discovery

type Discovery struct {
	Tools     []Tool     `json:"tools,omitempty"`
	Resources []Resource `json:"resources,omitempty"`
	Prompts   []Prompt   `json:"prompts,omitempty"`
}

Discovery contains the entities exposed by an MCP server.

type HTTPTransport

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

HTTPTransport implements the HTTP transport for MCP

func NewHTTPTransport

func NewHTTPTransport(config HTTPTransportConfig) (*HTTPTransport, error)

NewHTTPTransport creates a new HTTP transport

func (*HTTPTransport) Close

func (t *HTTPTransport) Close() error

Close closes the HTTP transport

func (*HTTPTransport) Send

Send sends a JSON-RPC request via HTTP

func (*HTTPTransport) SendNotification

func (t *HTTPTransport) SendNotification(ctx context.Context, notification *JSONRPCNotification) error

SendNotification sends a JSON-RPC notification via HTTP

func (*HTTPTransport) SetMethodsHandler

func (t *HTTPTransport) SetMethodsHandler(handler MethodHandler)

SetMethodsHandler sets the handler for incoming method calls

func (*HTTPTransport) SetNotificationsHandler

func (t *HTTPTransport) SetNotificationsHandler(handler NotificationHandler)

SetNotificationsHandler sets the handler for incoming notifications

func (*HTTPTransport) Start

func (t *HTTPTransport) Start(ctx context.Context) error

Start starts the HTTP transport

type HTTPTransportConfig

type HTTPTransportConfig struct {
	// URL is the server URL
	URL string

	// Headers are HTTP headers
	Headers map[string]string

	// Timeout is the request timeout
	Timeout time.Duration
}

HTTPTransportConfig represents configuration for HTTP transport

type InitializeResult

type InitializeResult struct {
	// ProtocolVersion is the MCP protocol version
	ProtocolVersion string `json:"protocolVersion"`

	// ServerInfo contains server information
	ServerInfo ServerInfo `json:"serverInfo"`

	// Capabilities are the server capabilities
	Capabilities ServerCapabilities `json:"capabilities"`
}

InitializeResult represents the result of initializing the server

type IntegrationOptions

type IntegrationOptions struct {
	ToolNameMode ToolNameMode `json:"tool_name_mode,omitempty"`
}

IntegrationOptions controls how MCP servers are wrapped into the tool registry.

type IntegrationResult

type IntegrationResult struct {
	// MCPTools are the wrapped MCP tools (across all servers that succeeded).
	MCPTools []tool.Tool

	// ServerResults holds per-server outcome — one entry per configured server.
	// Inspect this to diagnose which servers loaded and which failed.
	ServerResults []ServerResult

	// Error is set only when zero tools were registered across all configured
	// servers. For partial failures, inspect ServerResults instead.
	Error error
	// contains filtered or unexported fields
}

IntegrationResult represents the result of MCP integration

func IntegrateMCPServers

func IntegrateMCPServers(ctx context.Context, registry *tool.Registry, serverConfigs []ServerConfig) *IntegrationResult

IntegrateMCPServers takes a tool registry and a list of MCP server configurations, creates MCP clients, and registers all wrapped tools (tools, resources, prompts, plus listMcpResources and readMcpResource) in the registry.

func IntegrateMCPServersWithOptions

func IntegrateMCPServersWithOptions(ctx context.Context, registry *tool.Registry, serverConfigs []ServerConfig, options *IntegrationOptions) *IntegrationResult

func (*IntegrationResult) Close

func (r *IntegrationResult) Close() error

Close releases all successfully integrated MCP clients. It is safe to call multiple times.

type JSONRPCError

type JSONRPCError struct {
	Code    int            `json:"code"`
	Message string         `json:"message"`
	Data    map[string]any `json:"data,omitempty"`
}

JSONRPCError represents a JSON-RPC error

type JSONRPCNotification

type JSONRPCNotification struct {
	JSONRPC string         `json:"jsonrpc"`
	Method  string         `json:"method"`
	Params  map[string]any `json:"params,omitempty"`
}

JSONRPCNotification represents a JSON-RPC notification

type JSONRPCRequest

type JSONRPCRequest struct {
	JSONRPC string         `json:"jsonrpc"`
	ID      int64          `json:"id"`
	Method  string         `json:"method"`
	Params  map[string]any `json:"params,omitempty"`
}

JSONRPCRequest represents a JSON-RPC request

type JSONRPCResponse

type JSONRPCResponse struct {
	JSONRPC string         `json:"jsonrpc"`
	ID      int64          `json:"id"`
	Result  map[string]any `json:"result,omitempty"`
	Error   *JSONRPCError  `json:"error,omitempty"`
}

JSONRPCResponse represents a JSON-RPC response

type MCPClientManager

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

MCPClientManager manages MCP server connections

func GlobalMCPManager

func GlobalMCPManager() *MCPClientManager

GlobalMCPManager returns the global MCP client manager

func (*MCPClientManager) AllTools

func (m *MCPClientManager) AllTools(ctx context.Context, registry *tool.Registry) ([]tool.Tool, error)

AllTools returns all tools from all connected servers as native tools

func (*MCPClientManager) Connect

func (m *MCPClientManager) Connect(ctx context.Context, config ConnectServerConfig) error

Connect connects to an MCP server and registers its tools

func (*MCPClientManager) ConnectWithOAuth

func (m *MCPClientManager) ConnectWithOAuth(ctx context.Context, config ConnectServerConfig) error

func (*MCPClientManager) Disconnect

func (m *MCPClientManager) Disconnect(serverName string) error

Disconnect disconnects from an MCP server

func (*MCPClientManager) GetClient

func (m *MCPClientManager) GetClient(serverName string) (*Client, bool)

GetClient returns an MCP client by server name

func (*MCPClientManager) GetConnectedServers

func (m *MCPClientManager) GetConnectedServers() []string

GetConnectedServers returns all connected server names

func (*MCPClientManager) GetServerStatuses

func (m *MCPClientManager) GetServerStatuses() []MCPServerStatus

func (*MCPClientManager) GetServerTools

func (m *MCPClientManager) GetServerTools(ctx context.Context, serverName string) ([]Tool, error)

GetServerTools returns all tools from a connected server

func (*MCPClientManager) ListServers

func (m *MCPClientManager) ListServers() []string

ListServers returns all connected server names

type MCPOAuthConfig

type MCPOAuthConfig struct {
	ClientID     string
	ClientSecret string
	AuthURL      string
	TokenURL     string
	Scopes       []string
}

func GetOAuthConfig

func GetOAuthConfig() *MCPOAuthConfig

type MCPServerStatus

type MCPServerStatus struct {
	Name        string       `json:"name"`
	Status      ClientStatus `json:"status"`
	Scope       ConfigScope  `json:"scope"`
	Type        string       `json:"type"`
	LastError   string       `json:"last_error,omitempty"`
	ConnectedAt time.Time    `json:"connected_at,omitempty"`
	ToolCount   int          `json:"tool_count"`
}

type MCPTool

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

MCPTool implements a template MCP tool that forwards to connected MCP servers

func NewMCPTool

func NewMCPTool(manager *MCPClientManager) *MCPTool

NewMCPTool creates a new MCP tool

func (*MCPTool) BackfillInput

func (t *MCPTool) BackfillInput(ctx context.Context, input map[string]any) map[string]any

BackfillInput enriches input with derived fields

func (*MCPTool) Call

func (t *MCPTool) Call(
	ctx context.Context,
	input tool.CallInput,
	permissionCheck types.CanUseToolFn,
) (tool.CallResult, error)

Call executes an MCP tool call

func (*MCPTool) CheckPermissions

func (t *MCPTool) CheckPermissions(ctx context.Context, input map[string]any, toolCtx tool.ToolUseContext) types.PermissionResult

CheckPermissions checks tool-specific permissions

func (*MCPTool) Definition

func (t *MCPTool) Definition() tool.Definition

Definition returns the tool definition

func (*MCPTool) Description

func (t *MCPTool) Description(ctx context.Context) (string, error)

Description returns a human-readable description of the tool

func (*MCPTool) FormatResult

func (t *MCPTool) FormatResult(data any) string

FormatResult formats the tool output

func (*MCPTool) IsConcurrencySafe

func (t *MCPTool) IsConcurrencySafe(input map[string]any) bool

IsConcurrencySafe returns whether the tool can run concurrently

func (*MCPTool) IsEnabled

func (t *MCPTool) IsEnabled() bool

IsEnabled returns whether the tool is enabled

func (*MCPTool) IsReadOnly

func (t *MCPTool) IsReadOnly(input map[string]any) bool

IsReadOnly returns whether the tool is read-only

func (*MCPTool) ValidateInput

func (t *MCPTool) ValidateInput(ctx context.Context, input map[string]any) (map[string]any, error)

ValidateInput validates tool input

type McpJsonConfig

type McpJsonConfig struct {
	MCPServers map[string]McpServerConfig `json:"mcpServers,omitempty"`
}

type McpServerConfig

type McpServerConfig struct {
	Type    McpServerType     `json:"type,omitempty"`
	Command string            `json:"command,omitempty"`
	Args    []string          `json:"args,omitempty"`
	Env     map[string]string `json:"env,omitempty"`
	URL     string            `json:"url,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
	Timeout int               `json:"timeout,omitempty"`
	Scope   ConfigScope       `json:"scope,omitempty"`
}

func ExpandEnvVars

func ExpandEnvVars(config McpServerConfig) (McpServerConfig, []string)

type McpServerType

type McpServerType string
const (
	ServerTypeStdio     McpServerType = "stdio"
	ServerTypeHTTP      McpServerType = "http"
	ServerTypeSSE       McpServerType = "sse"
	ServerTypeWebSocket McpServerType = "ws"
	ServerTypeSDK       McpServerType = "sdk"
)

type MethodHandler

type MethodHandler func(ctx context.Context, request *JSONRPCRequest) (*JSONRPCResponse, error)

MethodHandler handles incoming method calls from the server

type NotificationHandler

type NotificationHandler func(notification *JSONRPCNotification)

NotificationHandler handles incoming notifications

type PluginMcpServer

type PluginMcpServer struct {
	Name   string
	Source string
	Config McpServerConfig
}

func GetPluginMcpServers

func GetPluginMcpServers() []PluginMcpServer

type ProgressCallback

type ProgressCallback func(progress float64, total *float64, message string)

ProgressCallback is called when an MCP server sends a progress notification during a tool call. progress is the ratio of completion (0–1 when total is set); total may be nil if the server does not report it.

type Prompt

type Prompt struct {
	// Name is the prompt name
	Name string `json:"name"`

	// Description explains the prompt
	Description string `json:"description,omitempty"`

	// Arguments are the prompt arguments
	Arguments []PromptArgument `json:"arguments,omitempty"`
}

Prompt represents an MCP prompt

type PromptArgument

type PromptArgument struct {
	// Name is the argument name
	Name string `json:"name"`

	// Description explains the argument
	Description string `json:"description,omitempty"`

	// Required indicates if the argument is required
	Required bool `json:"required"`
}

PromptArgument represents a prompt argument

type PromptMessage

type PromptMessage struct {
	// Role is the message role
	Role string `json:"role"`

	// Content is the message content
	Content any `json:"content"`
}

PromptMessage represents a message in a prompt

type PromptResult

type PromptResult struct {
	Messages []PromptMessage `json:"messages,omitempty"`
}

PromptResult is the canonical result of an MCP prompt fetch.

type PromptsCapability

type PromptsCapability struct {
	// ListChanged indicates if the prompts list can change
	ListChanged bool `json:"listChanged,omitempty"`
}

PromptsCapability represents prompt capabilities

type Resource

type Resource struct {
	// URI is the resource URI
	URI string `json:"uri"`

	// Name is the resource name
	Name string `json:"name"`

	// Description explains the resource
	Description string `json:"description,omitempty"`

	// MimeType is the resource MIME type
	MimeType string `json:"mimeType,omitempty"`
}

Resource represents an MCP resource

type ResourceContent

type ResourceContent struct {
	// URI is the resource URI
	URI string `json:"uri"`

	// MimeType is the content type
	MimeType string `json:"mimeType,omitempty"`

	// Text is the text content
	Text string `json:"text,omitempty"`

	// Blob is the binary content (base64)
	Blob string `json:"blob,omitempty"`
}

ResourceContent represents the content of a resource

type ResourceReadResult

type ResourceReadResult struct {
	Contents []ResourceContent `json:"contents,omitempty"`
}

ResourceReadResult is the canonical result of an MCP resource read.

type ResourcesCapability

type ResourcesCapability struct {
	// Subscribe indicates if resources can be subscribed to
	Subscribe bool `json:"subscribe,omitempty"`

	// ListChanged indicates if the resources list can change
	ListChanged bool `json:"listChanged,omitempty"`
}

ResourcesCapability represents resource capabilities

type ScopedMcpServerConfig

type ScopedMcpServerConfig struct {
	McpServerConfig
	Scope ConfigScope
}

func GetMcpServerConfigByName

func GetMcpServerConfigByName(name string, cwd string) *ScopedMcpServerConfig

type ServerCapabilities

type ServerCapabilities struct {
	// Tools are the tool capabilities
	Tools *ToolsCapability `json:"tools,omitempty"`

	// Resources are the resource capabilities
	Resources *ResourcesCapability `json:"resources,omitempty"`

	// Prompts are the prompt capabilities
	Prompts *PromptsCapability `json:"prompts,omitempty"`
}

ServerCapabilities represents the server's capabilities

type ServerConfig

type ServerConfig struct {
	// Name is the server name
	Name string `json:"name"`

	// Command is the command to start the server (for stdio)
	Command string `json:"command,omitempty"`

	// Args are the command arguments (for stdio)
	Args []string `json:"args,omitempty"`

	// URL is the server URL (for http/sse/websocket)
	URL string `json:"url,omitempty"`

	// Transport is the transport type
	Transport TransportType `json:"transport"`

	// Env are environment variables for the server process
	Env map[string]string `json:"env,omitempty"`

	// Timeout is the timeout for operations
	Timeout time.Duration `json:"timeout"`

	// Headers are HTTP headers (for http/sse)
	Headers map[string]string `json:"headers,omitempty"`
}

ServerConfig represents configuration for an MCP server

type ServerInfo

type ServerInfo struct {
	// Name is the server name
	Name string `json:"name"`

	// Version is the server version
	Version string `json:"version"`

	// ProtocolVersion is the MCP protocol version
	ProtocolVersion string `json:"protocolVersion"`
}

ServerInfo represents information about the MCP server

type ServerResult

type ServerResult struct {
	// Name is the server name from ServerConfig.
	Name string
	// ToolsRegistered is the number of tools successfully registered.
	ToolsRegistered int
	// Error is non-nil if the server could not be connected, initialized, or wrapped.
	Error error
}

ServerResult captures the outcome of integrating one MCP server.

type StdioTransport

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

StdioTransport implements the stdio transport for MCP

func NewStdioTransport

func NewStdioTransport(config StdioTransportConfig) (*StdioTransport, error)

NewStdioTransport creates a new stdio transport

func (*StdioTransport) Close

func (t *StdioTransport) Close() error

Close closes the transport

func (*StdioTransport) Send

Send sends a JSON-RPC request

func (*StdioTransport) SendNotification

func (t *StdioTransport) SendNotification(ctx context.Context, notification *JSONRPCNotification) error

SendNotification sends a JSON-RPC notification

func (*StdioTransport) SetMethodsHandler

func (t *StdioTransport) SetMethodsHandler(handler MethodHandler)

SetMethodsHandler sets the handler for incoming method calls

func (*StdioTransport) SetNotificationsHandler

func (t *StdioTransport) SetNotificationsHandler(handler NotificationHandler)

SetNotificationsHandler sets the handler for incoming notifications

func (*StdioTransport) Start

func (t *StdioTransport) Start(ctx context.Context) error

Start starts the stdio transport

type StdioTransportConfig

type StdioTransportConfig struct {
	// Command is the command to run
	Command string

	// Args are the command arguments
	Args []string

	// Env are environment variables
	Env map[string]string

	// Stdin is the stdin to use (for testing)
	Stdin io.Reader

	// Stdout is the stdout to use (for testing)
	Stdout io.Writer

	// Stderr is the stderr to use (for testing)
	Stderr io.Writer
}

StdioTransportConfig represents configuration for stdio transport

type Tool

type Tool struct {
	// Name is the tool name
	Name string `json:"name"`

	// Description explains what the tool does
	Description string `json:"description"`

	// InputSchema is the JSON schema for the tool input
	InputSchema map[string]any `json:"inputSchema"`
}

Tool represents an MCP tool

type ToolCallResult

type ToolCallResult struct {
	Raw        map[string]any `json:"raw,omitempty"`
	Text       string         `json:"text,omitempty"`
	IsError    bool           `json:"is_error,omitempty"`
	Structured map[string]any `json:"structured,omitempty"`
	Meta       map[string]any `json:"meta,omitempty"`
}

ToolCallResult is the canonical result of an MCP tool call.

type ToolNameMode

type ToolNameMode string

ToolNameMode controls how wrapped MCP tool names are exposed.

const (
	ToolNameModePrefixed   ToolNameMode = "prefixed"
	ToolNameModeUnprefixed ToolNameMode = "unprefixed"
)

type ToolServerConfig

type ToolServerConfig struct {
	// Name is the server name
	Name string

	// Command is the command to start the server (for stdio)
	Command string

	// Args are the command arguments (for stdio)
	Args []string

	// URL is the server URL (for http)
	URL string

	// Transport is the transport type (stdio or http)
	Transport string

	// Env are environment variables
	Env map[string]string

	// Headers are HTTP headers (for http transport)
	Headers map[string]string
}

ToolServerConfig represents MCP server configuration for the MCP tool surface. Kept separate from the transport-level ServerConfig to avoid conflating runtime connection intent with the canonical MCP client config.

type ToolWrapperMetadata

type ToolWrapperMetadata struct {
	ServerName string       `json:"server_name"`
	ToolName   string       `json:"tool_name"`
	NameMode   ToolNameMode `json:"name_mode"`
}

ToolWrapperMetadata is attached to wrapped MCP tools.

type ToolsCapability

type ToolsCapability struct {
	// ListChanged indicates if the tools list can change
	ListChanged bool `json:"listChanged,omitempty"`
}

ToolsCapability represents tool capabilities

type Transport

type Transport interface {
	// Start starts the transport
	Start(ctx context.Context) error

	// Send sends a request
	Send(ctx context.Context, req *JSONRPCRequest) (*JSONRPCResponse, error)

	// SendNotification sends a notification
	SendNotification(ctx context.Context, notification *JSONRPCNotification) error

	// Close closes the transport
	Close() error

	// SetNotificationsHandler sets the handler for incoming notifications
	SetNotificationsHandler(handler NotificationHandler)

	// SetMethodsHandler sets the handler for incoming method calls
	SetMethodsHandler(handler MethodHandler)
}

Transport represents an MCP transport

type TransportType

type TransportType string

TransportType represents the type of MCP transport

const (
	TransportTypeStdio     TransportType = "stdio"
	TransportTypeHTTP      TransportType = "http"
	TransportTypeSSE       TransportType = "sse"
	TransportTypeWebSocket TransportType = "websocket"
)

type ValidationError

type ValidationError struct {
	File       string `json:"file,omitempty"`
	Path       string `json:"path,omitempty"`
	Message    string `json:"message"`
	Suggestion string `json:"suggestion,omitempty"`
	Severity   string `json:"severity"`
}

type Wrapper

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

func NewWrapper

func NewWrapper(client *Client, serverName string, options *IntegrationOptions) *Wrapper

func (*Wrapper) WrapAll

func (w *Wrapper) WrapAll(ctx context.Context) ([]tool.Tool, error)

func (*Wrapper) WrapListResourcesTool

func (w *Wrapper) WrapListResourcesTool() (tool.Tool, error)

func (*Wrapper) WrapPrompt

func (w *Wrapper) WrapPrompt(prompt Prompt) (tool.Tool, error)

func (*Wrapper) WrapReadResourceTool

func (w *Wrapper) WrapReadResourceTool() (tool.Tool, error)

func (*Wrapper) WrapResource

func (w *Wrapper) WrapResource(resource Resource) (tool.Tool, error)

func (*Wrapper) WrapResources

func (w *Wrapper) WrapResources(resources []Resource) ([]tool.Tool, error)

func (*Wrapper) WrapTool

func (w *Wrapper) WrapTool(mcpTool Tool) (tool.Tool, error)

func (*Wrapper) WrapTools

func (w *Wrapper) WrapTools(mcpTools []Tool) ([]tool.Tool, error)

Jump to

Keyboard shortcuts

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