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

mcp

package
v0.13.13 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CredentialBearerToken = "bearer_token"
	CredentialHeaders     = "headers"
)

Variables

This section is empty.

Functions

func ParseCredentialEncryptionKey

func ParseCredentialEncryptionKey(value string) ([]byte, error)

func PrepareRotatedCredential

func PrepareRotatedCredential(appID, runID, serverID string, credential RunCredential, cfg RunConfig) ([]byte, error)

PrepareRotatedCredential validates and encrypts a replacement credential for an existing run/server tuple. The tuple is authenticated as AES-GCM AAD, so ciphertext cannot be moved to another run or server record.

func PrepareStoredServers

func PrepareStoredServers(appID, runID string, requests []RunServerRequest, cfg RunConfig) ([]agentcore.RunMCPServer, error)

func ProviderRegistrations

func ProviderRegistrations(ctx context.Context, provider ToolProvider, prefix string) ([]tools.ProviderRegistration, []string, error)

ProviderRegistrations discovers and validates a provider catalog without mutating a registry.

func RegisterProviderTools

func RegisterProviderTools(ctx context.Context, registry *tools.Registry, provider ToolProvider, prefix string) ([]string, error)

func RunToolAlias

func RunToolAlias(serverName, toolName string) string

Types

type AuthenticationError

type AuthenticationError struct {
	ServerID   string
	ServerName string
	Reason     string
	Err        error
}

AuthenticationError identifies a run-scoped MCP credential that must be replaced by the host app before the run can continue. It never contains the credential or a remote response body.

func (*AuthenticationError) Error

func (e *AuthenticationError) Error() string

func (*AuthenticationError) Unwrap

func (e *AuthenticationError) Unwrap() error

type AuthenticationState

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

AuthenticationState records an authentication failure raised after MCP initialization, including failures observed inside a tool call that an adapter may convert into model-visible tool output.

func PrepareRunTools

func PrepareRunTools(ctx context.Context, store agentcore.Store, base *tools.Registry, appID, runID string, cfg RunConfig) (*tools.Registry, map[string]bool, *AuthenticationState, func(), error)

PrepareRunTools connects the run's MCP servers, verifies the app-authorized tools exist, and registers an isolated tool overlay. The returned close function must remain deferred through adapter execution.

func (*AuthenticationState) Failure

type CallResult

type CallResult = sdk.ToolCallResult

type ContentItem

type ContentItem = sdk.ContentItem

type FilteringProvider

type FilteringProvider struct {
	Provider ToolProvider
	Allowed  map[string]bool
}

func (FilteringProvider) CallTool

func (FilteringProvider) ListTools

func (p FilteringProvider) ListTools(ctx context.Context) ([]Tool, error)

type Gateway

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

func NewGateway

func NewGateway(store agentcore.Store, registry *tools.Registry) *Gateway

func NewGatewayWithAllowed

func NewGatewayWithAllowed(store agentcore.Store, registry *tools.Registry, allowed map[string]bool) *Gateway

NewGatewayWithAllowed uses an execution-scoped allowlist. It is used for isolated run MCP overlays whose aliases do not belong to the saved agent.

func (*Gateway) CallTool

func (g *Gateway) CallTool(ctx context.Context, appID, runID string, req ToolCallRequest) (*CallResult, error)

func (*Gateway) ListTools

func (g *Gateway) ListTools(ctx context.Context, appID, runID string) ([]Tool, error)

func (*Gateway) WithCallContext

func (g *Gateway) WithCallContext(callContext tools.CallContext) *Gateway

WithCallContext adds execution-local resources, such as the staged skill root, without changing the persisted run or the public MCP contract.

type HTTPProvider

type HTTPProvider struct {
	BaseURL string
	Token   string
	Client  *http.Client
}

func (HTTPProvider) CallTool

func (HTTPProvider) ListTools

func (p HTTPProvider) ListTools(ctx context.Context) ([]Tool, error)

type ProviderToolCallRequest

type ProviderToolCallRequest = sdk.ProviderToolCallRequest

type RunConfig

type RunConfig struct {
	CredentialKey       []byte
	AllowHTTP           bool
	AllowPrivateNetwork bool
	AllowedHosts        []string
	ConnectTimeout      time.Duration
}

func RunConfigFromEnv

func RunConfigFromEnv(getenv func(string) string) (RunConfig, error)

type RunCredential

type RunCredential struct {
	Type        string            `json:"type"`
	AccessToken string            `json:"access_token,omitempty"`
	Headers     map[string]string `json:"headers,omitempty"`
	ExpiresAt   *time.Time        `json:"expires_at,omitempty"`
}

type RunServerRequest

type RunServerRequest struct {
	ServerID   string               `json:"server_id"`
	ServerName string               `json:"server_name"`
	Transport  string               `json:"transport"`
	URL        string               `json:"url"`
	Tools      []RunTool            `json:"tools"`
	Skills     []agentcore.SkillRef `json:"skills,omitempty"`
	Credential *RunCredential       `json:"credential,omitempty"`
}

type RunTool

type RunTool struct {
	Name   string `json:"name"`
	Access string `json:"access"`
}

type StdioProvider

type StdioProvider struct {
	Command string
	Args    []string
	Env     map[string]string
	// contains filtered or unexported fields
}

func (*StdioProvider) CallTool

func (*StdioProvider) Close

func (p *StdioProvider) Close() error

func (*StdioProvider) ListTools

func (p *StdioProvider) ListTools(ctx context.Context) ([]Tool, error)

type StreamableHTTPProvider

type StreamableHTTPProvider struct {
	Endpoint string
	Token    string
	Client   *http.Client
	// contains filtered or unexported fields
}

func (*StreamableHTTPProvider) CallTool

func (*StreamableHTTPProvider) ListTools

func (p *StreamableHTTPProvider) ListTools(ctx context.Context) ([]Tool, error)

type Tool

type Tool = sdk.Tool

type ToolCallRequest

type ToolCallRequest struct {
	ToolName string          `json:"tool_name"`
	Input    json.RawMessage `json:"input"`
}

type ToolProvider

type ToolProvider interface {
	ListTools(ctx context.Context) ([]Tool, error)
	CallTool(ctx context.Context, name string, input json.RawMessage, meta tools.CommandExecutionContext) (*CallResult, error)
}

Jump to

Keyboard shortcuts

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