profile

package
v0.58.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package profile carries request-scoped in-proxy profile filtering (Spec 057).

A profile is a named, stateless view over a subset of the configured upstream servers, addressable at /mcp/p/<slug>. A ProfileScope is resolved once per request and filters which servers that request may see/call. The URL tier is only one of its sources: the server package's resolver (Profiles v2) also builds a scope from an agent token's profile_pin and from a session's set_profile selection, in that precedence order. The scope stays an independent, auth-type-agnostic primitive that composes with (but does not depend on) the Spec 028 agent-token scope — an unauthenticated /mcp/p/<slug> connection runs as an admin AuthContext yet must still be profile-filtered.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithProfileScope

func WithProfileScope(ctx context.Context, p *ProfileScope) context.Context

WithProfileScope returns a context carrying the given ProfileScope.

Types

type ProfileScope

type ProfileScope struct {
	// Name is the resolved profile slug, used in rejection messages and activity
	// metadata (FR-012).
	Name string
	// contains filtered or unexported fields
}

ProfileScope is the immutable, request-scoped set of servers a profile exposes. It is resolved once — from a token pin, a /mcp/p/<slug> URL, or a session selection — and never mutated for the lifetime of a request.

func NewProfileScope

func NewProfileScope(name string, servers []string) *ProfileScope

NewProfileScope builds a scope for the named profile over the given effective server set. The returned scope is always non-nil (an empty/nil server list is a legal profile that allows nothing).

func ProfileScopeFromContext

func ProfileScopeFromContext(ctx context.Context) *ProfileScope

ProfileScopeFromContext extracts the URL-injected ProfileScope, or nil when the request did not enter via a profile URL.

This is the URL TIER ONLY. Enforcement code must not call it directly: a request can carry a higher-precedence token pin or a session selection that never touches the context. Resolve the effective scope through the server package's resolveActiveProfile instead — reading this alone is how the code_execution sandbox once ran outside a pinned token's profile.

func (*ProfileScope) AllowedServerNames

func (p *ProfileScope) AllowedServerNames() []string

AllowedServerNames returns the list of server names in this profile scope. Returns nil for a nil receiver (allow-all — no restriction list). Returns an empty slice for a non-nil scope with no servers (deny-all).

func (*ProfileScope) Allows

func (p *ProfileScope) Allows(serverName string) bool

Allows reports whether the named server is visible under this scope.

A nil receiver means no profile is in effect for this request — no URL slug, no session selection, no token pin — so it is not profile-filtered and every server is allowed (FR-010). A non-nil scope allows only servers in its set; the empty server name is never allowed for a real scope.

func (*ProfileScope) DeniesAll added in v0.58.0

func (p *ProfileScope) DeniesAll() bool

DeniesAll reports whether this scope allows nothing at all — an empty profile, or the deny-all scope a stale agent-token pin resolves to. A nil receiver is "no profile filtering" and therefore never denies all.

It exists so callers can distinguish "filtered to nothing" from "not filtered" without allocating an AllowedServerNames slice, notably to avoid lazily creating a per-profile Bleve index for a scope that can return no results anyway.

Jump to

Keyboard shortcuts

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