mcp

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 25 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 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