Documentation
¶
Index ¶
- type AuthConfig
- type Client
- type ClientConfig
- type ClientStatus
- type MCPManager
- type Manager
- func (m *Manager) AddClient(ctx context.Context, config ClientConfig) (Client, error)
- func (m *Manager) GetClient(ctx context.Context, clientID string) (Client, error)
- func (m *Manager) ListClients(ctx context.Context) ([]Client, error)
- func (m *Manager) RemoveClient(ctx context.Context, clientID string) error
- type Prompt
- type PromptResult
- type Resource
- type ResourceContent
- type Tool
- type ToolResult
- type TransportType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthConfig ¶
type AuthConfig struct {
Type string `json:"type"` // api_key, oauth2, basic
APIKey string `json:"api_key,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
}
AuthConfig contains MCP authentication configuration.
type Client ¶
type Client interface {
ID() string
Name() string
Status() ClientStatus
Connect(ctx context.Context) error
Disconnect(ctx context.Context) error
ListTools(ctx context.Context) ([]Tool, error)
CallTool(ctx context.Context, name string, args map[string]any) (*ToolResult, error)
ListResources(ctx context.Context) ([]Resource, error)
ReadResource(ctx context.Context, uri string) (*ResourceContent, error)
ListPrompts(ctx context.Context) ([]Prompt, error)
GetPrompt(ctx context.Context, name string, args map[string]any) (*PromptResult, error)
}
Client represents a connection to an MCP server.
type ClientConfig ¶
type ClientConfig struct {
ID string `json:"id"`
Name string `json:"name"`
Transport TransportType `json:"transport"`
Command string `json:"command,omitempty"` // stdio only
Args []string `json:"args,omitempty"` // stdio only
URL string `json:"url,omitempty"` // sse/websocket
Env map[string]string `json:"env,omitempty"`
AutoAuth bool `json:"auto_auth,omitempty"`
AuthConfig *AuthConfig `json:"auth,omitempty"`
}
ClientConfig is the configuration for an MCP client.
type ClientStatus ¶
type ClientStatus string
ClientStatus represents the connection status of an MCP client.
const ( ClientStatusInactive ClientStatus = "inactive" ClientStatusConnecting ClientStatus = "connecting" ClientStatusConnected ClientStatus = "connected" ClientStatusError ClientStatus = "error" )
type MCPManager ¶
type MCPManager interface {
AddClient(ctx context.Context, config ClientConfig) (Client, error)
RemoveClient(ctx context.Context, clientID string) error
GetClient(ctx context.Context, clientID string) (Client, error)
ListClients(ctx context.Context) ([]Client, error)
}
MCPManager manages MCP client connections.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the default implementation of MCPManager.
type PromptResult ¶
type PromptResult struct {
Description string `json:"description,omitempty"`
Messages []any `json:"messages"`
}
PromptResult is the result of getting a prompt.
type Resource ¶
type Resource struct {
URI string `json:"uri"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
MimeType string `json:"mime_type,omitempty"`
}
Resource represents a resource exposed by an MCP server.
type ResourceContent ¶
type ResourceContent struct {
URI string `json:"uri"`
MimeType string `json:"mime_type"`
Text string `json:"text,omitempty"`
Blob []byte `json:"blob,omitempty"`
}
ResourceContent is the content of a resource.
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema map[string]any `json:"input_schema"`
}
Tool represents a tool exposed by an MCP server.
type ToolResult ¶
ToolResult is the result of calling an MCP tool.
type TransportType ¶
type TransportType string
TransportType defines the MCP transport type.
const ( TransportStdio TransportType = "stdio" TransportSSE TransportType = "sse" TransportWebSocket TransportType = "websocket" )
Click to show internal directories.
Click to hide internal directories.