resources

package
v0.69.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeResourceID

func NormalizeResourceID(resourceID string) (string, error)

NormalizeResourceID validates and normalizes a resource identifier as defined by RFC 8707 section 2 and the MCP canonical server URI rules, returning an error when the value cannot be one.

Types

type Registry

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

Registry implements the registry for registered protected resources.

func NewRegistry

func NewRegistry(ctx context.Context, registrationConfFilepath string, logger logrus.FieldLogger) (*Registry, error)

NewRegistry creates a new resource Registry with the provided parameters. An empty registrationConfFilepath yields an empty registry.

func (*Registry) Empty

func (r *Registry) Empty() bool

Empty returns true when no resource is registered.

func (*Registry) Get

func (r *Registry) Get(resourceID string) (*Resource, bool)

Get returns the registered resource for the provided resource identifier, which is normalized before lookup.

func (*Registry) ScopesSupported

func (r *Registry) ScopesSupported() []string

ScopesSupported returns the union of the scopes, implicit ones included, of all registered resources.

func (*Registry) ValidateScopes

func (r *Registry) ValidateScopes(supported []string) error

ValidateScopes returns an error when a registered resource names a scope which is not in the provided list of supported scopes. An undeclared scope would be dropped when authorizing a request, so a resource asking for one is a configuration error.

type RegistryData

type RegistryData struct {
	Resources []*Resource `yaml:"resources,flow"`
}

RegistryData is the base structure of the resources section of our client registry configuration file. All other sections of that file are parsed by their own registry and are ignored here.

type Resource

type Resource struct {
	ID     string   `yaml:"id"`
	Name   string   `yaml:"name"`
	Scopes []string `yaml:"scopes,flow"`

	// ImplicitScopes are granted for this resource whether a client asked for
	// them or not. They are meant for the scopes which are not a permission of
	// the resource but change what a token carries, and a client has no reason
	// to know about.
	ImplicitScopes []string `yaml:"implicit_scopes,flow"`
	// contains filtered or unexported fields
}

Resource is one protected resource, an MCP server, as registered in the resources section of the client registration configuration file.

func (*Resource) AllowsScope

func (r *Resource) AllowsScope(scope string) bool

AllowsScope returns true when the provided scope is one the resource accepts.

func (*Resource) ApplyImplicitScopes

func (r *Resource) ApplyImplicitScopes(scopes map[string]bool)

ApplyImplicitScopes adds the implicit scopes of the associated resource to the provided scopes.

Jump to

Keyboard shortcuts

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