runtime

package
v0.2.18 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AppExtensionID is the MCP extension identifier for MCP Apps.
	AppExtensionID = "io.modelcontextprotocol/ui"

	// AppMIMEType is the required MIME type for an MCP Apps UI resource.
	AppMIMEType = "text/html;profile=mcp-app"

	VisibilityModel = "model"
	VisibilityApp   = "app"
)
View Source
const (
	NotificationRefreshDebounce = 1 * time.Second
	MaxMCPServerPageSize        = 256
	DefaultMCPPageSize          = 25
)

Variables

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

func DefaultSandboxCSP added in v0.2.17

func DefaultSandboxCSP() string

DefaultSandboxCSP returns a restrictive CSP suitable for srcdoc iframes hosting untrusted MCP App HTML. With sandbox="allow-scripts" the iframe has a unique opaque origin, so 'self' refers to that opaque origin.

func IsAppMIMEType added in v0.2.17

func IsAppMIMEType(mime string) bool

IsAppMIMEType returns true if mime is a valid MCP Apps MIME type, tolerating whitespace and additional parameters after the profile.

func ToolVisibleToApp added in v0.2.17

func ToolVisibleToApp(info *MCPToolAppInfo) bool

ToolVisibleToApp reports whether the tool may be called by an MCP App.

func ToolVisibleToModel added in v0.2.17

func ToolVisibleToModel(info *MCPToolAppInfo) bool

ToolVisibleToModel reports whether the tool can be exposed to the LLM. A nil/empty visibility list defaults to model+app, so unknown servers don't accidentally hide tools.

func ValidateArtifactAppToolInvocation added in v0.2.17

func ValidateArtifactAppToolInvocation(
	p policy.MCPAppsPolicy,
	tool MCPToolCapability,
	appServer artifact.ArtifactRef,
) error

ValidateArtifactAppToolInvocation is the Artifact-backed MCP App authorization check. It is the target API used by the Artifact Store MCP runtime.

func ValidateMCPAppContextUpdates added in v0.2.17

func ValidateMCPAppContextUpdates(
	values []MCPAppModelContextUpdate,
) error

ValidateMCPAppContextUpdates validates application-originated MCP App context updates before they are inserted into model input.

func ValidateMCPAppContextUpdatesForContext added in v0.2.17

func ValidateMCPAppContextUpdatesForContext(
	contextValue MCPConversationContext,
	updates []MCPAppModelContextUpdate,
) error

ValidateMCPAppContextUpdatesForContext binds App-originated model context updates to the exact durable MCP server selection that authorized them.

func ValidateMCPConversationContext added in v0.2.17

func ValidateMCPConversationContext(value MCPConversationContext) error

ValidateMCPConversationContext validates durable MCP conversation selection structure without requiring a live MCP runtime connection.

func ValidateMCPProviderToolMapping added in v0.2.17

func ValidateMCPProviderToolMapping(m MCPProviderToolMapping) error

ValidateMCPProviderToolMapping validates one durable provider-tool mapping emitted during MCP inference hydration. These mappings bind later model tool calls to a specific Artifact-backed MCP server and discovered tool digest.

func ValidateMCPProviderToolMappingsForContext added in v0.2.17

func ValidateMCPProviderToolMappingsForContext(
	contextValue MCPConversationContext,
	mappings []MCPProviderToolMapping,
) error

ValidateMCPProviderToolMappingsForContext validates durable provider-tool mappings against the exact durable MCP context that authorized their inference exposure.

This belongs in MCP validation, not in Conversation storage. Conversation owns persistence, while MCP owns the meaning of a mapping.

Types

type ApprovalManager

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

func NewApprovalManager

func NewApprovalManager(ttl time.Duration) *ApprovalManager

func (*ApprovalManager) Clear added in v0.2.18

func (m *ApprovalManager) Clear()

func (*ApprovalManager) ClearServer added in v0.2.18

func (m *ApprovalManager) ClearServer(
	server artifact.ArtifactRef,
)

ClearServer removes pending tokens and remembered decisions belonging to an MCP server. It is called whenever that server's runtime session ends.

func (*ApprovalManager) Create

func (m *ApprovalManager) Create(
	ctx context.Context,
	summary MCPApprovalSummary,
) (string, error)

func (*ApprovalManager) LookupDecision

func (m *ApprovalManager) LookupDecision(
	summary MCPApprovalSummary,
) (MCPApprovalResolution, bool)

func (*ApprovalManager) Resolve

func (*ApprovalManager) VerifyAndConsumeToken

func (m *ApprovalManager) VerifyAndConsumeToken(
	ctx context.Context,
	token string,
	expected MCPApprovalSummary,
) (string, error)

type ClientFactory

type ClientFactory interface {
	Connect(
		ctx context.Context,
		config server.RuntimeConfig,
		auth auth.ResolvedTransportAuth,
		notifications ClientNotificationSink,
	) (ClientSession, error)
}

type ClientNotification

type ClientNotification struct {
	Server artifact.ArtifactRef
	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 ClientSession

type ClientSession interface {
	Close(ctx context.Context) error

	Discover(
		ctx context.Context,
		config server.RuntimeConfig,
	) (MCPDiscoverySnapshot, error)

	CallTool(
		ctx context.Context,
		toolName string,
		arguments map[string]any,
	) (*InvokeMCPToolResponseBody, error)

	ReadResource(
		ctx context.Context,
		uri string,
	) (*MCPReadResourceResponseBody, error)

	GetPrompt(
		ctx context.Context,
		name string,
		arguments map[string]string,
	) (*MCPGetPromptResponseBody, error)

	Complete(
		ctx context.Context,
		request MCPCompleteArgumentRequestBody,
	) (*MCPCompletionResult, error)
}

type InvokeMCPToolRequest added in v0.2.17

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

type InvokeMCPToolRequestBody added in v0.2.17

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 added in v0.2.17

type InvokeMCPToolResponse struct {
	Body *InvokeMCPToolResponseBody
}

type InvokeMCPToolResponseBody added in v0.2.17

type InvokeMCPToolResponseBody struct {
	Server artifact.ArtifactRef `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"`
}

type MCPAppModelContextUpdate added in v0.2.17

type MCPAppModelContextUpdate struct {
	InstanceID string               `json:"instanceID,omitempty"`
	Server     artifact.ArtifactRef `json:"server"`

	ResourceURI string `json:"resourceUri,omitempty"`

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

	UpdatedAt string `json:"updatedAt,omitempty"`
}

type MCPApprovalDecision added in v0.2.17

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

type MCPApprovalEvaluation added in v0.2.17

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

type MCPApprovalResolution added in v0.2.17

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

type MCPApprovalResolutionResult added in v0.2.18

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 added in v0.2.17

type MCPApprovalSummary struct {
	Server            artifact.ArtifactRef   `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 added in v0.2.17

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

type MCPCompleteArgumentRequest added in v0.2.17

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

type MCPCompleteArgumentRequestBody added in v0.2.17

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 added in v0.2.17

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

type MCPContent added in v0.2.17

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 added in v0.2.17

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

type MCPConversationContext added in v0.2.17

type MCPConversationContext struct {
	Servers           []MCPServerSelection           `json:"servers"`
	Resources         []MCPResourceRef               `json:"resources,omitempty"`
	ResourceTemplates []MCPResourceTemplateSelection `json:"resourceTemplates,omitempty"`
	Prompts           []MCPPromptSelection           `json:"prompts,omitempty"`
}

type MCPDiscoveryPageToken added in v0.2.17

type MCPDiscoveryPageToken struct {
	Server         artifact.ArtifactRef `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 added in v0.2.17

type MCPDiscoverySnapshot struct {
	Server artifact.ArtifactRef `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 added in v0.2.17

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

type MCPGetPromptRequestBody added in v0.2.17

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

type MCPGetPromptResponse added in v0.2.17

type MCPGetPromptResponse struct {
	Body *MCPGetPromptResponseBody
}

type MCPGetPromptResponseBody added in v0.2.17

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

type MCPIcon added in v0.2.17

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

type MCPImplementationInfo added in v0.2.17

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

type MCPInvocationSource added in v0.2.17

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

type MCPPromptMessage added in v0.2.17

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

type MCPPromptRef added in v0.2.17

type MCPPromptRef struct {
	Server      artifact.ArtifactRef             `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 MCPPromptSelection added in v0.2.17

type MCPPromptSelection struct {
	MCPPromptRef

	ArgumentValues map[string]string `json:"argumentValues,omitempty"`
}

type MCPProviderToolMapping added in v0.2.17

type MCPProviderToolMapping struct {
	Server artifact.ArtifactRef `json:"server"`

	ProviderToolName string `json:"providerToolName"`
	ChoiceID         string `json:"choiceID"`

	ToolName   string `json:"toolName"`
	ToolDigest string `json:"toolDigest"`

	ApprovalRule   policy.MCPApprovalRule  `json:"approvalRule,omitempty"`
	ExecutionMode  policy.MCPExecutionMode `json:"executionMode,omitempty"`
	AppResourceURI string                  `json:"appResourceUri,omitempty"`
	Visibility     []string                `json:"visibility,omitempty"`
}

type MCPReadResourceRequest added in v0.2.17

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

type MCPReadResourceRequestBody added in v0.2.17

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

type MCPReadResourceResponse added in v0.2.17

type MCPReadResourceResponse struct {
	Body *MCPReadResourceResponseBody
}

type MCPReadResourceResponseBody added in v0.2.17

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

type MCPResourceContents added in v0.2.17

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 added in v0.2.17

type MCPResourceRef struct {
	Server      artifact.ArtifactRef `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 added in v0.2.17

type MCPResourceTemplateRef struct {
	Server      artifact.ArtifactRef             `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 MCPResourceTemplateSelection added in v0.2.17

type MCPResourceTemplateSelection struct {
	MCPResourceTemplateRef

	ArgumentValues map[string]string `json:"argumentValues,omitempty"`
}

type MCPRuntimeManager

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

func NewMCPRuntimeManager

func NewMCPRuntimeManager(
	resolver server.Resolver,
	secrets server.SecretResolver,
	environment server.EnvironmentResolver,
	authorizer auth.ConnectionAuthorizer,
	factory ClientFactory,
) (*MCPRuntimeManager, error)

func (*MCPRuntimeManager) CallTool

func (*MCPRuntimeManager) CallToolDryRun

func (*MCPRuntimeManager) Close

func (m *MCPRuntimeManager) Close(ctx context.Context) error

func (*MCPRuntimeManager) Complete

func (*MCPRuntimeManager) Connect

Connect resolves and verifies the full Artifact-backed server state once, materializes the runtime configuration, establishes the client session, and captures the session version.

Tool calls do not repeat Source snapshot verification. Mutations explicitly invalidate sessions, while explicit Refresh performs a new full resolution.

func (*MCPRuntimeManager) Disconnect

func (m *MCPRuntimeManager) Disconnect(
	ctx context.Context,
	ref artifact.ArtifactRef,
) error

func (*MCPRuntimeManager) GetPrompt

func (m *MCPRuntimeManager) GetPrompt(
	ctx context.Context,
	ref artifact.ArtifactRef,
	name string,
	arguments map[string]string,
) (*MCPGetPromptResponseBody, error)

func (*MCPRuntimeManager) Invalidate added in v0.2.17

func (m *MCPRuntimeManager) Invalidate(
	ctx context.Context,
	ref artifact.ArtifactRef,
) error

Invalidate removes the derived runtime session after an MCP lifecycle, policy, installation-overlay, or secret-binding mutation.

It deliberately does not resolve the server again. The mutation path has already established that the prior runtime version is obsolete.

func (*MCPRuntimeManager) InvalidateCollection added in v0.2.17

func (m *MCPRuntimeManager) InvalidateCollection(
	ctx context.Context,
	ref collection.CollectionRef,
) error

func (*MCPRuntimeManager) ListPrompts

func (m *MCPRuntimeManager) ListPrompts(
	ctx context.Context,
	ref artifact.ArtifactRef,
) ([]MCPPromptRef, error)

func (*MCPRuntimeManager) ListPromptsPage added in v0.2.17

func (m *MCPRuntimeManager) ListPromptsPage(
	ctx context.Context,
	ref artifact.ArtifactRef,
	pageSize int,
	pageToken string,
) ([]MCPPromptRef, *string, error)

func (*MCPRuntimeManager) ListResourceTemplates

func (m *MCPRuntimeManager) ListResourceTemplates(
	ctx context.Context,
	ref artifact.ArtifactRef,
) ([]MCPResourceTemplateRef, error)

func (*MCPRuntimeManager) ListResourceTemplatesPage added in v0.2.17

func (m *MCPRuntimeManager) ListResourceTemplatesPage(
	ctx context.Context,
	ref artifact.ArtifactRef,
	pageSize int,
	pageToken string,
) ([]MCPResourceTemplateRef, *string, error)

func (*MCPRuntimeManager) ListResources

func (m *MCPRuntimeManager) ListResources(
	ctx context.Context,
	ref artifact.ArtifactRef,
) ([]MCPResourceRef, error)

func (*MCPRuntimeManager) ListResourcesPage added in v0.2.17

func (m *MCPRuntimeManager) ListResourcesPage(
	ctx context.Context,
	ref artifact.ArtifactRef,
	pageSize int,
	pageToken string,
) ([]MCPResourceRef, *string, error)

func (*MCPRuntimeManager) ListTools

func (*MCPRuntimeManager) ListToolsPage added in v0.2.17

func (m *MCPRuntimeManager) ListToolsPage(
	ctx context.Context,
	ref artifact.ArtifactRef,
	pageSize int,
	pageToken string,
) ([]MCPToolCapability, *string, error)

func (*MCPRuntimeManager) OnClientNotification

func (m *MCPRuntimeManager) OnClientNotification(
	ctx context.Context,
	event ClientNotification,
)

func (*MCPRuntimeManager) ReadResource

func (*MCPRuntimeManager) Refresh

func (*MCPRuntimeManager) StartConnect added in v0.2.17

func (*MCPRuntimeManager) Status

type MCPServerCapabilitiesSummary added in v0.2.17

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 added in v0.2.17

type MCPServerRuntimeSnapshot struct {
	Server     artifact.ArtifactRef     `json:"server"`
	Collection collection.CollectionRef `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 MCPServerSelection added in v0.2.17

type MCPServerSelection struct {
	Server artifact.ArtifactRef `json:"server"`

	SnapshotDigest string `json:"snapshotDigest,omitempty"`

	ToolExposure  MCPToolExposure    `json:"toolExposure"` // none | all | selected
	SelectedTools []MCPToolSelection `json:"selectedTools,omitempty"`

	IncludeServerInstructions bool `json:"includeServerInstructions,omitempty"`
}

type MCPServerStatus added in v0.2.17

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

type MCPTaskSupport added in v0.2.17

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

type MCPToolAnnotations added in v0.2.17

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 added in v0.2.17

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

type MCPToolAppRenderInfo added in v0.2.17

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 added in v0.2.17

type MCPToolCallProvenance struct {
	Server     artifact.ArtifactRef     `json:"server"`
	Collection collection.CollectionRef `json:"collection"`

	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 added in v0.2.17

type MCPToolCapability struct {
	Server           artifact.ArtifactRef `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  policy.MCPApprovalRule  `json:"approvalRule"`
	ExecutionMode policy.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 MCPToolExposure added in v0.2.17

type MCPToolExposure string
const (
	MCPToolExposureNone     MCPToolExposure = "none"
	MCPToolExposureAll      MCPToolExposure = "all"
	MCPToolExposureSelected MCPToolExposure = "selected"
)

type MCPToolRisk added in v0.2.17

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

type MCPToolSelection added in v0.2.17

type MCPToolSelection struct {
	Server           artifact.ArtifactRef `json:"server"`
	ToolName         string               `json:"toolName"`
	ProviderToolName string               `json:"providerToolName,omitempty"`
	ChoiceID         string               `json:"choiceID,omitempty"`
	Digest           string               `json:"digest,omitempty"`

	ApprovalRule  *policy.MCPApprovalRule  `json:"approvalRule,omitempty"`
	ExecutionMode *policy.MCPExecutionMode `json:"executionMode,omitempty"`

	AppResourceURI string   `json:"appResourceUri,omitempty"`
	Visibility     []string `json:"visibility,omitempty"`
}

type ToolBridge

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

func NewToolBridge

func NewToolBridge(
	runtime *MCPRuntimeManager,
	approvals *ApprovalManager,
) *ToolBridge

func (*ToolBridge) Evaluate

func (*ToolBridge) EvaluateMapped added in v0.2.17

EvaluateMapped evaluates a model-originated provider-tool call against the persisted mapping produced by MCP inference hydration.

The mapping is authoritative for server identity, provider name, choice ID, discovered digest, and any conversation policy tightening.

func (*ToolBridge) Invoke

func (*ToolBridge) InvokeMapped added in v0.2.17

InvokeMapped invokes a provider-tool mapping after revalidating the current connected runtime snapshot and applying only policy-tightening constraints.

func (*ToolBridge) ResolveApproval added in v0.2.17

func (b *ToolBridge) ResolveApproval(
	ctx context.Context,
	approvalID string,
	resolution MCPApprovalResolution,
) (MCPApprovalResolutionResult, error)

Jump to

Keyboard shortcuts

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