mcp

package
v0.0.0-...-4aca0fc Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToolName

func ToolName(serverID, toolName string) string

func ValidateServerConfig

func ValidateServerConfig(id string, cfg config.MCPServer) error

Types

type Manager

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

func NewManager

func NewManager(cfgs map[string]config.MCPServer) (*Manager, error)

func (*Manager) Close

func (m *Manager) Close() error

Close disconnects every configured MCP server and releases persistent transports.

func (*Manager) ConnectAll

func (m *Manager) ConnectAll(ctx context.Context) error

func (*Manager) ConnectServer

func (m *Manager) ConnectServer(ctx context.Context, id string) error

func (*Manager) DisconnectServer

func (m *Manager) DisconnectServer(id string) error

func (*Manager) ExecuteTool

func (m *Manager) ExecuteTool(ctx context.Context, serverID, toolName string, args map[string]any) (tools.Result, error)

func (*Manager) ExposedToolName

func (m *Manager) ExposedToolName(serverID, toolName string, reserved []provider.ToolDefinition) (string, bool)

ExposedToolName returns the provider-facing name currently assigned to one MCP tool. It uses the same collision rules as ToolDefinitionsWithReserved so persisted MCP calls can be replayed under the name the model can call.

func (*Manager) GetPrompt

func (m *Manager) GetPrompt(ctx context.Context, serverID, name string, args map[string]string) (PromptResult, error)

func (*Manager) ListPrompts

func (m *Manager) ListPrompts(serverID string) []PromptDescriptor

func (*Manager) ListResourceTemplates

func (m *Manager) ListResourceTemplates(serverID string) []ResourceTemplateDescriptor

func (*Manager) ListResources

func (m *Manager) ListResources(serverID string) []ResourceDescriptor

func (*Manager) ListServers

func (m *Manager) ListServers() []ServerState

func (*Manager) ListTools

func (m *Manager) ListTools() []ToolDescriptor

func (*Manager) LoadConfig

func (m *Manager) LoadConfig(cfgs map[string]config.MCPServer) error

func (*Manager) ReadResource

func (m *Manager) ReadResource(ctx context.Context, serverID, uri string) (ResourceReadResult, error)

func (*Manager) ResolveToolName

func (m *Manager) ResolveToolName(name string, reserved []provider.ToolDefinition) (serverID, toolName string, ok bool)

func (*Manager) ToolDefinitions

func (m *Manager) ToolDefinitions() []provider.ToolDefinition

func (*Manager) ToolDefinitionsWithReserved

func (m *Manager) ToolDefinitionsWithReserved(reserved []provider.ToolDefinition) []provider.ToolDefinition

type PromptArgumentDescriptor

type PromptArgumentDescriptor struct {
	Name        string
	Title       string
	Description string
	Required    bool
}

type PromptDescriptor

type PromptDescriptor struct {
	ServerID    string
	ServerName  string
	Name        string
	Title       string
	Description string
	Arguments   []PromptArgumentDescriptor
}

type PromptMessage

type PromptMessage struct {
	Role string
	Text string
}

type PromptResult

type PromptResult struct {
	Description string
	Messages    []PromptMessage
}

type ResourceDescriptor

type ResourceDescriptor struct {
	ServerID    string
	ServerName  string
	URI         string
	Name        string
	Title       string
	Description string
	MIMEType    string
	Size        int64
}

type ResourceReadResult

type ResourceReadResult struct {
	Contents []tools.MCPStoredContentItem
}

type ResourceTemplateDescriptor

type ResourceTemplateDescriptor struct {
	ServerID    string
	ServerName  string
	URITemplate string
	Name        string
	Title       string
	Description string
	MIMEType    string
}

type ServerState

type ServerState struct {
	ID                    string
	Name                  string
	URL                   string
	Status                ServerStatus
	Disabled              bool
	LastError             string
	SessionID             string
	ServerInstructions    string
	ToolCount             int
	ResourceCount         int
	ResourceTemplateCount int
	PromptCount           int
	Tools                 []ToolDescriptor
	Resources             []ResourceDescriptor
	ResourceTemplates     []ResourceTemplateDescriptor
	Prompts               []PromptDescriptor
}

type ServerStatus

type ServerStatus string
const (
	ServerStatusDisconnected ServerStatus = "disconnected"
	ServerStatusConnecting   ServerStatus = "connecting"
	ServerStatusConnected    ServerStatus = "connected"
	ServerStatusError        ServerStatus = "error"
	ServerStatusDisabled     ServerStatus = "disabled"
)

type ToolDescriptor

type ToolDescriptor struct {
	ServerID        string
	ServerName      string
	Name            string
	Title           string
	Description     string
	InputSchema     any
	OutputSchema    any
	ReadOnlyHint    bool
	DestructiveHint *bool
	IdempotentHint  bool
	OpenWorldHint   *bool
}

Jump to

Keyboard shortcuts

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