server

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxDisplayNameBytes    = 512
	MaxDescriptionBytes    = 1 << 20
	MaxURIBytes            = 16 << 10
	MaxLocatorBytes        = 16 << 10
	MaxFingerprintBytes    = 512
	MaxKindBytes           = 256
	MaxDiscoveryCandidates = 4096

	DefaultConnectionTimeoutMS = 30_000
	MaxConnectionTimeoutMS     = 10 * 60 * 1_000
)
View Source
const (
	NotificationRefreshDebounce = 1 * time.Second
	MaxMCPServerPageSize        = 256
	DefaultMCPPageSize          = 25
)

Variables

View Source
var (
	ErrInvalid             = errors.New("invalid MCP runtime specification")
	ErrClosed              = errors.New("MCP runtime is closed")
	ErrConflict            = errors.New("MCP runtime conflict")
	ErrReferenceUnresolved = errors.New("MCP runtime reference unresolved")
	ErrDigestMismatch      = errors.New("MCP runtime digest mismatch")
)
View Source
var (
	ErrMCPInvalidRuntimeRequest = errors.New("invalid mcp runtime request")
	ErrMCPRuntimeNotReady       = errors.New("mcp runtime is not ready")
	ErrMCPPolicyDenied          = errors.New("mcp policy denied request")
	ErrMCPApprovalNeeded        = errors.New("mcp approval required")
	ErrMCPStaleReference        = errors.New("mcp stale reference")
)

Functions

This section is empty.

Types

type CatalogID

type CatalogID string

func (CatalogID) Validate

func (id CatalogID) Validate() error

type ClientInfo

type ClientInfo struct {
	Name    string
	Version string
}

func (ClientInfo) Validate

func (value ClientInfo) Validate() error

type ClientNotification

type ClientNotification struct {
	Server ServerID
	Kind   ClientNotificationKind

	ResourceURI string

	LoggerName   string
	LoggingLevel string
	LogData      any

	Progress float64
	Total    float64
	Message  string
}

type ClientNotificationKind

type ClientNotificationKind string
const (
	ClientNotificationToolListChanged     ClientNotificationKind = "toolsListChanged"
	ClientNotificationResourceListChanged ClientNotificationKind = "resourcesListChanged"
	ClientNotificationPromptListChanged   ClientNotificationKind = "promptsListChanged"
	ClientNotificationResourceUpdated     ClientNotificationKind = "resourceUpdated"
	ClientNotificationProgress            ClientNotificationKind = "progress"
)

type ClientNotificationSink

type ClientNotificationSink interface {
	OnClientNotification(ctx context.Context, event ClientNotification)
}

type Digest

type Digest string

func DigestBytes

func DigestBytes(value []byte) Digest

func (Digest) Validate added in v0.2.21

func (value Digest) Validate() error

type InvokeMCPToolRequest

type InvokeMCPToolRequest struct {
	Server ServerID `json:"server" required:"true"`
	Body   *InvokeMCPToolRequestBody
}

type InvokeMCPToolRequestBody

type InvokeMCPToolRequestBody struct {
	Source           MCPInvocationSource `json:"source"                     required:"true"`
	ToolName         string              `json:"toolName"                   required:"true"`
	ProviderToolName string              `json:"providerToolName,omitempty"`
	ChoiceID         string              `json:"choiceID,omitempty"`
	ToolDigest       string              `json:"toolDigest,omitempty"`

	Arguments map[string]any `json:"arguments,omitempty"`

	ApprovalID    string `json:"approvalID,omitempty"`
	ApprovalToken string `json:"approvalToken,omitempty"`

	ConversationID string `json:"conversationID,omitempty"`
	MessageID      string `json:"messageID,omitempty"`
	ToolUseID      string `json:"toolUseID,omitempty"`

	AppInstanceID string `json:"appInstanceID,omitempty"`
}

type InvokeMCPToolResponse

type InvokeMCPToolResponse struct {
	Body *InvokeMCPToolResponseBody
}

type InvokeMCPToolResponseBody

type InvokeMCPToolResponseBody struct {
	Server ServerID `json:"server"`

	ToolName         string `json:"toolName"`
	ProviderToolName string `json:"providerToolName,omitempty"`

	Content           []MCPContent `json:"content,omitempty"`
	StructuredContent any          `json:"structuredContent,omitempty"`
	IsError           bool         `json:"isError,omitempty"`

	Provenance MCPToolCallProvenance `json:"provenance"`
	App        *MCPToolAppRenderInfo `json:"app,omitempty"`
}

InvokeMCPToolResponseBody is the host-side response for a server tool call. Provenance is generated by the runtime host, not by the MCP server.

type MCPApprovalDecision

type MCPApprovalDecision string
const (
	MCPApprovalDecisionAllowed          MCPApprovalDecision = "allowed"
	MCPApprovalDecisionDenied           MCPApprovalDecision = "denied"
	MCPApprovalDecisionApprovalRequired MCPApprovalDecision = "approvalRequired"
)

type MCPApprovalEvaluation

type MCPApprovalEvaluation struct {
	Decision   MCPApprovalDecision `json:"decision"`
	Reason     string              `json:"reason,omitempty"`
	ApprovalID string              `json:"approvalID,omitempty"`
	Summary    *MCPApprovalSummary `json:"summary,omitempty"`
}

type MCPApprovalResolution

type MCPApprovalResolution string
const (
	MCPApprovalResolutionAllowOnce   MCPApprovalResolution = "allowOnce"
	MCPApprovalResolutionAllowAlways MCPApprovalResolution = "allowAlways"
	MCPApprovalResolutionDenyOnce    MCPApprovalResolution = "denyOnce"
	MCPApprovalResolutionDenyAlways  MCPApprovalResolution = "denyAlways"
)

type MCPApprovalResolutionResult

type MCPApprovalResolutionResult struct {
	ApprovalID string                `json:"approvalID"`
	Resolution MCPApprovalResolution `json:"resolution"`
	Decision   MCPApprovalDecision   `json:"decision"`

	RememberedForSession bool   `json:"rememberedForSession,omitempty"`
	Token                string `json:"token,omitempty"`
	ExpiresAt            string `json:"expiresAt,omitempty"`
}

MCPApprovalResolutionResult is returned for every successful resolution. Token and ExpiresAt are populated only for allowOnce. Always resolutions are remembered in process memory until the associated MCP session ends.

type MCPApprovalSummary

type MCPApprovalSummary struct {
	Server            ServerID               `json:"server"`
	ServerDisplayName string                 `json:"serverDisplayName,omitempty"`
	Source            MCPInvocationSource    `json:"source"`
	AppInstanceID     string                 `json:"appInstanceID,omitempty"`
	ToolName          string                 `json:"toolName"`
	ToolDigest        string                 `json:"toolDigest,omitempty"`
	Risk              MCPToolRisk            `json:"risk"`
	Arguments         jsonutil.JSONRawString `json:"arguments,omitempty"`
}

type MCPArgumentDefinition

type MCPArgumentDefinition struct {
	Name        string `json:"name"`
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
	Required    bool   `json:"required,omitempty"`
}

type MCPCompleteArgumentRequest

type MCPCompleteArgumentRequest struct {
	Server ServerID `json:"server" required:"true"`
	Body   *MCPCompleteArgumentRequestBody
}

type MCPCompleteArgumentRequestBody

type MCPCompleteArgumentRequestBody struct {
	RefType       string            `json:"refType"                 required:"true"` // resource | prompt
	Name          string            `json:"name"                    required:"true"`
	ArgumentName  string            `json:"argumentName"            required:"true"`
	ArgumentValue string            `json:"argumentValue,omitempty"`
	Context       map[string]string `json:"context,omitempty"`
}

type MCPCompletionResult

type MCPCompletionResult struct {
	Values  []string `json:"values,omitempty"`
	Total   int      `json:"total,omitempty"`
	HasMore bool     `json:"hasMore,omitempty"`
}

type MCPContent

type MCPContent struct {
	Type MCPContentType `json:"type"`

	Text     string `json:"text,omitempty"`
	Data     []byte `json:"data,omitempty"`
	MIMEType string `json:"mimeType,omitempty"`

	URI         string `json:"uri,omitempty"`
	Name        string `json:"name,omitempty"`
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
	Size        *int64 `json:"size,omitempty"`

	Resource *MCPResourceContents `json:"resource,omitempty"`

	Annotations map[string]any `json:"annotations,omitempty"`
	Meta        map[string]any `json:"_meta,omitempty"`
	Icons       []MCPIcon      `json:"icons,omitempty"`
}

type MCPContentType

type MCPContentType string
const (
	MCPContentTypeText         MCPContentType = "text"
	MCPContentTypeImage        MCPContentType = "image"
	MCPContentTypeAudio        MCPContentType = "audio"
	MCPContentTypeResourceLink MCPContentType = "resource_link"
	MCPContentTypeResource     MCPContentType = "resource"
)

type MCPDiscoveryPageToken

type MCPDiscoveryPageToken struct {
	Server         ServerID `json:"server"`
	SnapshotDigest string   `json:"dig"`
	Kind           string   `json:"k"`
	PageSize       int      `json:"ps"`
	Index          int      `json:"i"`
}

MCPDiscoveryPageToken is an opaque cursor for paginating cached discovery snapshots. It is encoded as base64(JSON) and should not be interpreted by callers.

type MCPDiscoverySnapshot

type MCPDiscoverySnapshot struct {
	Server ServerID `json:"server"`

	NegotiatedProtocolVersion string                        `json:"negotiatedProtocolVersion,omitempty"`
	ServerInfo                *MCPImplementationInfo        `json:"serverInfo,omitempty"`
	ServerCapabilities        *MCPServerCapabilitiesSummary `json:"serverCapabilities,omitempty"`
	Instructions              string                        `json:"instructions,omitempty"`

	Tools             []MCPToolCapability      `json:"tools,omitempty"`
	Resources         []MCPResourceRef         `json:"resources,omitempty"`
	ResourceTemplates []MCPResourceTemplateRef `json:"resourceTemplates,omitempty"`
	Prompts           []MCPPromptRef           `json:"prompts,omitempty"`

	Digest   string `json:"digest,omitempty"`
	SyncedAt string `json:"syncedAt,omitempty"`
}

type MCPGetPromptRequest

type MCPGetPromptRequest struct {
	Server ServerID `json:"server" required:"true"`
	Body   *MCPGetPromptRequestBody
}

type MCPGetPromptRequestBody

type MCPGetPromptRequestBody struct {
	PromptName string            `json:"promptName"          required:"true"`
	Arguments  map[string]string `json:"arguments,omitempty"`
}

type MCPGetPromptResponse

type MCPGetPromptResponse struct {
	Body *MCPGetPromptResponseBody
}

type MCPGetPromptResponseBody

type MCPGetPromptResponseBody struct {
	Server      ServerID           `json:"server"`
	PromptName  string             `json:"promptName"`
	Description string             `json:"description,omitempty"`
	Messages    []MCPPromptMessage `json:"messages,omitempty"`
}

type MCPHTTPAuthMode

type MCPHTTPAuthMode string
const (
	MCPHTTPAuthNone              MCPHTTPAuthMode = "none"
	MCPHTTPAuthAPIKey            MCPHTTPAuthMode = "apiKey"
	MCPHTTPAuthOAuth             MCPHTTPAuthMode = "oauth"
	MCPHTTPAuthClientCredentials MCPHTTPAuthMode = "clientCredentials"
)

type MCPIcon

type MCPIcon struct {
	Source   string   `json:"src"`
	MIMEType string   `json:"mimeType,omitempty"`
	Sizes    []string `json:"sizes,omitempty"`
	Theme    string   `json:"theme,omitempty"`
}

type MCPImplementationInfo

type MCPImplementationInfo struct {
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
}

type MCPInvocationSource

type MCPInvocationSource string
const (
	MCPInvocationSourceModel MCPInvocationSource = "model"
	MCPInvocationSourceUser  MCPInvocationSource = "user"
	MCPInvocationSourceApp   MCPInvocationSource = "app"
)

type MCPPromptMessage

type MCPPromptMessage struct {
	Role    string     `json:"role"`
	Content MCPContent `json:"content"`
}

type MCPPromptRef

type MCPPromptRef struct {
	Server      ServerID                         `json:"server"`
	PromptName  string                           `json:"promptName"`
	Title       string                           `json:"title,omitempty"`
	DisplayName string                           `json:"displayName"`
	Description string                           `json:"description,omitempty"`
	Arguments   map[string]MCPArgumentDefinition `json:"arguments,omitempty"`
	Digest      string                           `json:"digest,omitempty"`
}

type MCPReadResourceRequest

type MCPReadResourceRequest struct {
	Server ServerID `json:"server" required:"true"`
	Body   *MCPReadResourceRequestBody
}

type MCPReadResourceRequestBody

type MCPReadResourceRequestBody struct {
	URI string `json:"uri" required:"true"`
}

type MCPReadResourceResponse

type MCPReadResourceResponse struct {
	Body *MCPReadResourceResponseBody
}

type MCPReadResourceResponseBody

type MCPReadResourceResponseBody struct {
	Server   ServerID     `json:"server"`
	URI      string       `json:"uri"`
	Contents []MCPContent `json:"contents,omitempty"`
}

type MCPResourceContents

type MCPResourceContents struct {
	URI      string         `json:"uri"`
	MIMEType string         `json:"mimeType,omitempty"`
	Text     string         `json:"text,omitempty"`
	Blob     []byte         `json:"blob,omitempty"`
	Meta     map[string]any `json:"_meta,omitempty"`
}

type MCPResourceRef

type MCPResourceRef struct {
	Server      ServerID       `json:"server"`
	URI         string         `json:"uri"`
	Name        string         `json:"name,omitempty"`
	Title       string         `json:"title,omitempty"`
	DisplayName string         `json:"displayName"`
	Description string         `json:"description,omitempty"`
	MimeType    string         `json:"mimeType,omitempty"`
	Size        int64          `json:"size,omitempty"`
	Annotations map[string]any `json:"annotations,omitempty"`
	Digest      string         `json:"digest,omitempty"`
}

type MCPResourceTemplateRef

type MCPResourceTemplateRef struct {
	Server      ServerID                         `json:"server"`
	URITemplate string                           `json:"uriTemplate"`
	Name        string                           `json:"name,omitempty"`
	Title       string                           `json:"title,omitempty"`
	DisplayName string                           `json:"displayName"`
	Description string                           `json:"description,omitempty"`
	MimeType    string                           `json:"mimeType,omitempty"`
	Arguments   map[string]MCPArgumentDefinition `json:"arguments,omitempty"`
	Annotations map[string]any                   `json:"annotations,omitempty"`
	Digest      string                           `json:"digest,omitempty"`
}

type MCPRuntimeStdioConfig

type MCPRuntimeStdioConfig struct {
	Command          string            `json:"command"`
	Args             []string          `json:"args,omitempty"`
	Env              map[string]string `json:"env,omitempty"`
	StartupTimeoutMS int               `json:"startupTimeoutMS,omitempty"`
}

type MCPRuntimeStreamableHTTPConfig

type MCPRuntimeStreamableHTTPConfig struct {
	URL       string          `json:"url"`
	TimeoutMS int             `json:"timeoutMS,omitempty"`
	AuthMode  MCPHTTPAuthMode `json:"authMode"`

	Headers map[string]string `json:"headers,omitempty"`

	ClientCredentialRef         string `json:"clientCredentialRef,omitempty"`
	ClientIDMetadataDocumentURL string `json:"clientIDMetadataDocumentURL,omitempty"`
}

type MCPServerCapabilitiesSummary

type MCPServerCapabilitiesSummary struct {
	Tools                bool           `json:"tools,omitempty"`
	ToolsListChanged     bool           `json:"toolsListChanged,omitempty"`
	Resources            bool           `json:"resources,omitempty"`
	ResourcesSubscribe   bool           `json:"resourcesSubscribe,omitempty"`
	ResourcesListChanged bool           `json:"resourcesListChanged,omitempty"`
	Prompts              bool           `json:"prompts,omitempty"`
	PromptsListChanged   bool           `json:"promptsListChanged,omitempty"`
	Completions          bool           `json:"completions,omitempty"`
	Experimental         map[string]any `json:"experimental,omitempty"`
	Extensions           map[string]any `json:"extensions,omitempty"`
}

type MCPServerRuntimeSnapshot

type MCPServerRuntimeSnapshot struct {
	Server     ServerID        `json:"server"`
	Collection CatalogID       `json:"collection"`
	Status     MCPServerStatus `json:"status"`

	NegotiatedProtocolVersion string                        `json:"negotiatedProtocolVersion,omitempty"`
	ServerInfo                *MCPImplementationInfo        `json:"serverInfo,omitempty"`
	ServerCapabilities        *MCPServerCapabilitiesSummary `json:"serverCapabilities,omitempty"`
	Instructions              string                        `json:"instructions,omitempty"`

	LastError       string `json:"lastError,omitempty"`
	LastConnectedAt string `json:"lastConnectedAt,omitempty"`
	LastSyncedAt    string `json:"lastSyncedAt,omitempty"`

	ToolCount             int `json:"toolCount"`
	ResourceCount         int `json:"resourceCount"`
	ResourceTemplateCount int `json:"resourceTemplateCount"`
	PromptCount           int `json:"promptCount"`

	SnapshotDigest string `json:"snapshotDigest,omitempty"`
}

type MCPServerStatus

type MCPServerStatus string
const (
	MCPServerStatusDisabled     MCPServerStatus = "disabled"
	MCPServerStatusDisconnected MCPServerStatus = "disconnected"
	MCPServerStatusConnecting   MCPServerStatus = "connecting"
	MCPServerStatusReady        MCPServerStatus = "ready"
	MCPServerStatusError        MCPServerStatus = "error"
)

type MCPTaskSupport

type MCPTaskSupport string
const (
	MCPTaskSupportForbidden MCPTaskSupport = "forbidden"
	MCPTaskSupportOptional  MCPTaskSupport = "optional"
	MCPTaskSupportRequired  MCPTaskSupport = "required"
)

type MCPToolAnnotations

type MCPToolAnnotations struct {
	DestructiveHint *bool  `json:"destructiveHint,omitempty"`
	IdempotentHint  bool   `json:"idempotentHint"`
	OpenWorldHint   *bool  `json:"openWorldHint,omitempty"`
	ReadOnlyHint    bool   `json:"readOnlyHint"`
	Title           string `json:"title,omitempty"`
}

type MCPToolAppInfo

type MCPToolAppInfo struct {
	ResourceURI string   `json:"resourceUri,omitempty"`
	Visibility  []string `json:"visibility,omitempty"`
}

type MCPToolAppRenderInfo

type MCPToolAppRenderInfo struct {
	ResourceURI       string       `json:"resourceUri,omitempty"`
	MimeType          string       `json:"mimeType,omitempty"`
	Content           []MCPContent `json:"content,omitempty"`
	StructuredContent any          `json:"structuredContent,omitempty"`
	IsError           bool         `json:"isError,omitempty"`
}

type MCPToolCallProvenance

type MCPToolCallProvenance struct {
	Server     ServerID
	Collection CatalogID

	ServerDisplayName string `json:"serverDisplayName,omitempty"`

	ToolName         string `json:"toolName"`
	ProviderToolName string `json:"providerToolName"`
	ToolDigest       string `json:"toolDigest,omitempty"`
	ChoiceID         string `json:"choiceID,omitempty"`

	ToolUseID  string `json:"toolUseID,omitempty"`
	ApprovalID string `json:"approvalID,omitempty"`

	AppResourceURI string `json:"appResourceUri,omitempty"`
	AppInstanceID  string `json:"appInstanceID,omitempty"`
}

type MCPToolCapability

type MCPToolCapability struct {
	Server           ServerID `json:"server"`
	ToolName         string   `json:"toolName"`
	ProviderToolName string   `json:"providerToolName"`
	ChoiceID         string   `json:"choiceID"`
	Title            string   `json:"title,omitempty"`
	DisplayName      string   `json:"displayName"`
	Description      string   `json:"description,omitempty"`

	InputSchema  map[string]any `json:"inputSchema,omitempty"`
	OutputSchema map[string]any `json:"outputSchema,omitempty"`

	Annotations  *MCPToolAnnotations `json:"annotations,omitempty"`
	InferredRisk MCPToolRisk         `json:"inferredRisk"`

	ApprovalRule  mcpPolicy.MCPApprovalRule  `json:"approvalRule"`
	ExecutionMode mcpPolicy.MCPExecutionMode `json:"executionMode"`

	TaskSupport MCPTaskSupport `json:"taskSupport"`

	App *MCPToolAppInfo `json:"app,omitempty"`

	Digest  string `json:"digest"`
	Enabled bool   `json:"enabled"`
	Stale   bool   `json:"stale,omitempty"`
}

type MCPToolRisk

type MCPToolRisk string
const (
	MCPToolRiskUnknown     MCPToolRisk = "unknown"
	MCPToolRiskRead        MCPToolRisk = "read"
	MCPToolRiskWrite       MCPToolRisk = "write"
	MCPToolRiskDestructive MCPToolRisk = "destructive"
	MCPToolRiskOpenWorld   MCPToolRisk = "openWorld"
)

type MCPTransportType

type MCPTransportType string
const (
	MCPTransportStreamableHTTP MCPTransportType = "streamableHttp"
	MCPTransportStdio          MCPTransportType = "stdio"
)

type ResolvedServer

type ResolvedServer struct {
	Server  ServerID
	Catalog CatalogID
	Version Digest
	Config  RuntimeConfig
}

func (ResolvedServer) Validate

func (value ResolvedServer) Validate() error

type RuntimeConfig

type RuntimeConfig struct {
	Server  ServerID
	Catalog CatalogID

	LogicalName string
	DisplayName string

	Transport                 MCPTransportType
	Stdio                     *MCPRuntimeStdioConfig
	StreamableHTTP            *MCPRuntimeStreamableHTTPConfig
	OAuthClientSecretRequired bool

	Policy mcpPolicy.MCPPolicy

	SensitiveValues []string
}

func (RuntimeConfig) Validate

func (config RuntimeConfig) Validate() error

type ServerID

type ServerID string

func (ServerID) Validate

func (id ServerID) Validate() error

type ServerSource

type ServerSource interface {
	ResolveServer(
		ctx context.Context,
		server ServerID,
	) (ResolvedServer, error)
}

Jump to

Keyboard shortcuts

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