mcp

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

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.

func NewManager

func NewManager() *Manager

NewManager creates a new MCP Manager.

func (*Manager) AddClient

func (m *Manager) AddClient(ctx context.Context, config ClientConfig) (Client, error)

func (*Manager) GetClient

func (m *Manager) GetClient(ctx context.Context, clientID string) (Client, error)

func (*Manager) ListClients

func (m *Manager) ListClients(ctx context.Context) ([]Client, error)

func (*Manager) RemoveClient

func (m *Manager) RemoveClient(ctx context.Context, clientID string) error

type Prompt

type Prompt struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

Prompt represents a prompt template exposed by an MCP server.

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

type ToolResult struct {
	Content string `json:"content"`
	IsError bool   `json:"is_error"`
}

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"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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