Documentation
¶
Overview ¶
Package authorization defines data structures that describe an MCP server’s authorization requirements as well as helper types for carrying OAuth2 / OIDC credentials.
The package can be used by both servers and clients:
- Servers declare fine-grained policies (per-tool or per-resource) or a single global policy using Policy and Authorization types.
- Clients can attach a bearer or ID token to a request via Token and pass it through context using the TokenKey constant.
These types mirror the corresponding sections of the Model Context Protocol specification, allowing implementations to share a common, strongly-typed representation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Authorization ¶
type Authorization struct {
RequiredScopes []string `json:"requiredScopes"`
UseIdToken bool `json:"useIdToken,omitempty"`
ProtectedResourceMetadata *meta.ProtectedResourceMetadata `json:"protectedResourceMetadata"`
}
Authorization defines per-resource aI do uthorization requirements.
type IdTokenSource ¶
type Policy ¶ added in v0.2.0
type Policy struct {
// Global resource protection metadata (mutually exclusive with Tools/Resources)
Global *Authorization `json:"global,omitempty"`
// ExcludeURI skips middleware on matching paths
ExcludeURI string `json:"excludeURI,omitempty"`
// Per-tool authorization metadata
Tools map[string]*Authorization `json:"tools,omitempty"`
// Per-tenant authorization metadata (reserved for future use)
Resources map[string]*Authorization `json:"resources,omitempty"`
}
func (*Policy) IsFineGrained ¶ added in v0.2.0
IsFineGrained reports whether this config uses fine-grained (tool/resource) control.
type Token ¶
type Token struct {
Token string `json:"token"`
}
Token carries authentication credentials.
type TokenKeyType ¶
type TokenKeyType string
TokenKeyType is the type used for the context key of Token.
const TokenKey TokenKeyType = "TokenKey"
TokenKey is the context key under which Token is stored.