Help us shape the future of Go! Take the 2026 Go Developer Survey

service

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TransportStdio          = basemcp.TransportStdio
	TransportSSE            = basemcp.TransportSSE
	TransportStreamableHTTP = basemcp.TransportStreamableHTTP
)

Variables

View Source
var ErrServiceNotConfigured = errors.New("mcp service is not configured")

Functions

func DecodeStoredMCPServiceConfig

func DecodeStoredMCPServiceConfig(data []byte) (any, error)

Types

type AuditConfig added in v0.4.0

type AuditConfig struct {
	CaptureToolArgs bool `json:"capture_tool_args,omitempty"`
}

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 ClientStatus

type ClientStatus = basemcp.ClientStatus

type GatewaySession

type GatewaySession struct {
	ID                string        `json:"id"`
	ServiceID         string        `json:"service_id"`
	UpstreamSessionID string        `json:"upstream_session_id,omitempty"`
	Transport         TransportType `json:"transport"`
	State             SessionState  `json:"state"`
	CreatedAt         time.Time     `json:"created_at"`
	LastUsedAt        time.Time     `json:"last_used_at"`
}

GatewaySession is the gateway's view of one upstream session for an MCP service. It maps a stable gateway-generated ID to the upstream transport session.

type MCPServiceConfig

type MCPServiceConfig 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"`      // remote transports
	PostURL     string            `json:"post_url,omitempty"` // SSE only; if empty, derived from url
	Env         map[string]string `json:"env,omitempty"`
	AutoAuth    bool              `json:"auto_auth,omitempty"`
	AuthConfig  *AuthConfig       `json:"auth,omitempty"`
	Audit       AuditConfig       `json:"audit,omitempty"`
	Disabled    bool              `json:"disabled"`
	Description string            `json:"description,omitempty"`
	CreatedAt   time.Time         `json:"created_at"`
	UpdatedAt   time.Time         `json:"updated_at"`
}

MCPServiceConfig is the configuration for one upstream MCP service.

func (*MCPServiceConfig) Normalize

func (c *MCPServiceConfig) Normalize()

func (*MCPServiceConfig) NormalizeTimestamps

func (c *MCPServiceConfig) NormalizeTimestamps(now time.Time)

func (MCPServiceConfig) Validate

func (c MCPServiceConfig) Validate() error

type Manager

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

func NewManager

func NewManager(store configstore.ConfigStore) *Manager

func (*Manager) CallTool

func (m *Manager) CallTool(ctx context.Context, id string, name string, args map[string]any, progressCh chan<- UpstreamProgress) (*basemcp.ToolResult, error)

func (*Manager) Complete

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, cfg MCPServiceConfig) error

func (*Manager) Delete

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

func (*Manager) Get

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

func (*Manager) GetGatewaySession

func (m *Manager) GetGatewaySession(serviceID string) *GatewaySession

GetGatewaySession returns a snapshot of the active session for serviceID, or nil if no session exists for that service.

func (*Manager) GetPrompt

func (m *Manager) GetPrompt(ctx context.Context, id string, name string, args map[string]any, progressCh chan<- UpstreamProgress) (*basemcp.PromptResult, error)

func (*Manager) Initialize

func (m *Manager) Initialize(ctx context.Context, id string) (map[string]any, error)

func (*Manager) List

func (m *Manager) List(ctx context.Context) ([]MCPServiceConfig, error)

func (*Manager) ListGatewaySessions

func (m *Manager) ListGatewaySessions() []GatewaySession

ListGatewaySessions returns a snapshot of all active gateway sessions, sorted by creation time.

func (*Manager) ListPrompts

func (m *Manager) ListPrompts(ctx context.Context, id string) ([]basemcp.Prompt, error)

func (*Manager) ListPromptsPage

func (m *Manager) ListPromptsPage(ctx context.Context, id string, cursor string) (*basemcp.PromptListResult, error)

func (*Manager) ListResourceTemplates

func (m *Manager) ListResourceTemplates(ctx context.Context, id string) ([]basemcp.ResourceTemplate, error)

func (*Manager) ListResourceTemplatesPage

func (m *Manager) ListResourceTemplatesPage(ctx context.Context, id string, cursor string) (*basemcp.ResourceTemplateListResult, error)

func (*Manager) ListResources

func (m *Manager) ListResources(ctx context.Context, id string) ([]basemcp.Resource, error)

func (*Manager) ListResourcesPage

func (m *Manager) ListResourcesPage(ctx context.Context, id string, cursor string) (*basemcp.ResourceListResult, error)

func (*Manager) ListTools

func (m *Manager) ListTools(ctx context.Context, id string) ([]basemcp.Tool, error)

func (*Manager) ListToolsPage

func (m *Manager) ListToolsPage(ctx context.Context, id string, cursor string) (*basemcp.ToolListResult, error)

func (*Manager) ReadResource

func (m *Manager) ReadResource(ctx context.Context, id string, uri string, progressCh chan<- UpstreamProgress) (*basemcp.ResourceReadResult, error)

func (*Manager) Update

func (m *Manager) Update(ctx context.Context, id string, cfg MCPServiceConfig) error

type SessionState

type SessionState string

SessionState is the lifecycle state of a gateway upstream session.

const (
	SessionStateConnecting SessionState = "connecting"
	SessionStateReady      SessionState = "ready"
	SessionStateError      SessionState = "error"
	SessionStateClosed     SessionState = "closed"
)

type TransportType

type TransportType = basemcp.TransportType

type UpstreamProgress

type UpstreamProgress struct {
	ProgressToken any
	Progress      float64
	Total         *float64
	Message       string
}

UpstreamProgress carries a parsed notifications/progress message from an upstream.

Jump to

Keyboard shortcuts

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