mcp

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrToolNotFound        = fmt.Errorf("mcp: tool not found: %w", commonerrors.ErrNotFound)
	ErrPromptNotFound      = fmt.Errorf("mcp: prompt not found: %w", commonerrors.ErrNotFound)
	ErrResourceNotFound    = fmt.Errorf("mcp: resource not found: %w", commonerrors.ErrNotFound)
	ErrNoMCPRegistries     = fmt.Errorf("mcp: no MCP registries attached to consumer: %w", commonerrors.ErrValidation)
	ErrUpstreamUnavailable = fmt.Errorf("mcp: upstream unavailable")
)
View Source
var ErrAudienceMismatch = errors.New("mcp: inbound token audience does not match the upstream's expected audience")
View Source
var ErrNoPrincipal = errors.New("mcp: downstream auth mode requires an authenticated user identity")
View Source
var ErrNoRoleAccess = errors.New("mcp: no role grants MCP access for this identity")
View Source
var ErrNotSupported = errors.New("mcp upstream does not support this method")
View Source
var ErrUnreachable = errors.New("mcp upstream unreachable")

Functions

func IsRPCError

func IsRPCError(err error) bool

Types

type Composer

type Composer interface {
	ListTools(ctx context.Context, rc *appconsumer.RoutableConsumer) ([]Tool, error)
	CallTool(ctx context.Context, rc *appconsumer.RoutableConsumer, name string, arguments json.RawMessage) (json.RawMessage, error)
	ListResources(ctx context.Context, rc *appconsumer.RoutableConsumer) ([]Resource, error)
	ListResourceTemplates(ctx context.Context, rc *appconsumer.RoutableConsumer) ([]ResourceTemplate, error)
	ReadResource(ctx context.Context, rc *appconsumer.RoutableConsumer, uri string) (json.RawMessage, error)
	ListPrompts(ctx context.Context, rc *appconsumer.RoutableConsumer) ([]Prompt, error)
	GetPrompt(ctx context.Context, rc *appconsumer.RoutableConsumer, name string, arguments map[string]string) (json.RawMessage, error)
}

func NewComposer

func NewComposer(dialer Dialer, creds CredentialResolver, discovery DiscoveryCache, logger *slog.Logger) Composer

type ConsentRequiredError

type ConsentRequiredError struct {
	Provider string
	Ticket   string
	Path     string
}

func (*ConsentRequiredError) Error

func (e *ConsentRequiredError) Error() string

type CredentialResolver

type CredentialResolver interface {
	Apply(ctx context.Context, rc *appconsumer.RoutableConsumer, reg *registrydomain.Registry, target *Target) error
}

func NewCredentialResolver

func NewCredentialResolver(
	exchanger sts.Exchanger,
	vault vaultdomain.Repository,
	connect appoauth.ConnectService,
	provider appoauth.ProviderClient,
) CredentialResolver

type Dialer

type Dialer interface {
	Connect(ctx context.Context, target Target) (Upstream, error)
}

type DialerFunc

type DialerFunc func(ctx context.Context, target Target) (Upstream, error)

func (DialerFunc) Connect

func (f DialerFunc) Connect(ctx context.Context, target Target) (Upstream, error)

type DiscoveryCache

type DiscoveryCache interface {
	Get(key string) (any, bool)
	Set(key string, value any)
}

type Introspector

type Introspector interface {
	ListRegistryTools(ctx context.Context, gatewayID ids.GatewayID, registryID ids.RegistryID) ([]Tool, error)
}

func NewIntrospector

func NewIntrospector(registries appregistry.Finder, dialer Dialer) Introspector

type PluginRunner added in v0.3.4

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

PluginRunner runs the resolved plugin chain on the native MCP tools/call path, mirroring pkg/app/proxy for the LLM path. It is a thin adapter over the shared plugins.Executor: it builds stage contexts from JSON-RPC values and maps a plugin block to a JSON-RPC error.

func NewPluginRunner added in v0.3.4

func NewPluginRunner(executor appplugins.Executor, logger *slog.Logger) *PluginRunner

NewPluginRunner accepts the shared executor port; a nil executor makes every method a no-op (plugin-free parity with today's MCP path).

func (*PluginRunner) PreRequest added in v0.3.4

func (r *PluginRunner) PreRequest(
	ctx context.Context,
	rc *appconsumer.RoutableConsumer,
	name string,
	arguments json.RawMessage,
) error

PreRequest runs StagePreRequest over the tools/call params. It returns nil to allow the call; a non-nil *RPCError means a policy blocked it (caller skips the upstream dial and writes the error). Per RUN-832 the call fails open on any non-block error (guard unavailable, decode failure): it is logged and nil is returned so the tools/call proceeds.

func (*PluginRunner) PreResponse added in v0.3.4

func (r *PluginRunner) PreResponse(
	ctx context.Context,
	rc *appconsumer.RoutableConsumer,
	name string,
	arguments json.RawMessage,
	result json.RawMessage,
) error

PreResponse runs StagePreResponse over the tool result. It returns nil to keep the original result; a non-nil *RPCError means the response is blocked (caller discards the result and writes the error). Per RUN-832 the call fails open on any non-block error in this direction too: it is logged and the original result is kept.

type Prompt

type Prompt struct {
	Name string
	// contains filtered or unexported fields
}

func (Prompt) MarshalJSON

func (p Prompt) MarshalJSON() ([]byte, error)

func (*Prompt) UnmarshalJSON

func (p *Prompt) UnmarshalJSON(data []byte) error

type RPCError

type RPCError struct {
	Code    int64           `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
}

func (*RPCError) Error

func (e *RPCError) Error() string

type Resource

type Resource struct {
	Name string
	URI  string
	// contains filtered or unexported fields
}

func (Resource) MarshalJSON

func (r Resource) MarshalJSON() ([]byte, error)

func (*Resource) UnmarshalJSON

func (r *Resource) UnmarshalJSON(data []byte) error

type ResourceTemplate

type ResourceTemplate struct {
	Name        string
	URITemplate string
	// contains filtered or unexported fields
}

func (ResourceTemplate) MarshalJSON

func (rt ResourceTemplate) MarshalJSON() ([]byte, error)

func (*ResourceTemplate) UnmarshalJSON

func (rt *ResourceTemplate) UnmarshalJSON(data []byte) error

type RoleScoper

type RoleScoper interface {
	Scope(ctx context.Context, rc *appconsumer.RoutableConsumer, data *appconsumer.Data) (*appconsumer.RoutableConsumer, error)
}

func NewRoleScoper

func NewRoleScoper(oidcResolver approle.OIDCResolver) RoleScoper

type Target

type Target struct {
	URL     string
	Headers map[string]string
	PinKey  string
}

func StaticTarget

func StaticTarget(reg *registrydomain.Registry) Target

type Tool

type Tool struct {
	Name string
	// contains filtered or unexported fields
}

func (Tool) MarshalJSON

func (t Tool) MarshalJSON() ([]byte, error)

func (*Tool) UnmarshalJSON

func (t *Tool) UnmarshalJSON(data []byte) error

type Upstream

type Upstream interface {
	ListTools(ctx context.Context) ([]Tool, error)
	CallTool(ctx context.Context, name string, arguments json.RawMessage) (json.RawMessage, error)
	ListResources(ctx context.Context) ([]Resource, error)
	ListResourceTemplates(ctx context.Context) ([]ResourceTemplate, error)
	ReadResource(ctx context.Context, uri string) (json.RawMessage, error)
	ListPrompts(ctx context.Context) ([]Prompt, error)
	GetPrompt(ctx context.Context, name string, arguments map[string]string) (json.RawMessage, error)
	SupportsResources() bool
	SupportsPrompts() bool
	Close(ctx context.Context)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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