mcp

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOrientationDenied = fmt.Errorf("ORIENTATION_DENIED: the requested flight is not selectable from this connection's current authority or does not grant this operation. The operation was not performed: %w", keg.ErrOrientationDenied)

ErrOrientationDenied reports a fresh orientation that lacks the requested authority. Selecting a different accessible flight is explicit per call.

View Source
var ErrOrientationRootUnavailable = fmt.Errorf("ORIENTATION_ROOT_UNAVAILABLE: the connection-pinned root was deleted or is no longer accessible; start a new session to choose a different root. The operation was not performed: %w", keg.ErrOrientationRootUnavailable)

ErrOrientationRootUnavailable reports permanent loss of the connection-pinned root. A different root requires a newly launched session.

View Source
var ErrOrientationStale = fmt.Errorf("ORIENTATION_STALE: authority changed between per-call resolution and dispatch; retry the operation yourself after reviewing current authority. Mutations are never replayed automatically: %w", keg.ErrOrientationStale)

ErrOrientationStale is returned without performing the requested operation.

View Source
var ErrOrientationUnavailable = fmt.Errorf("ORIENTATION_UNAVAILABLE: current orientation authority could not be verified; retry after the Hub is available. The operation was not performed: %w", keg.ErrOrientationUnavailable)

ErrOrientationUnavailable reports a transient failure to recompute live authority. The caller may retry later, but the operation is never replayed.

Functions

func AggregateOrientationKegs added in v0.39.0

func AggregateOrientationKegs(flights []*tapper.Flight, authorized []tapper.OrientationKeg) []tapper.OrientationKeg

AggregateOrientationKegs projects each reachable flight over one identity load and merges duplicate KEGs by highest effective role.

func CanonicalOrientationIdentity added in v0.39.0

func CanonicalOrientationIdentity(identity AuthIdentity) (string, error)

CanonicalOrientationIdentity returns transport-neutral revision material for the authenticated identity on the pinned root's Hub. Hub routing aliases and credentials are deliberately absent so stdio and hosted MCP hash the same authority while unrelated Hub logins cannot stale a call.

func EffectiveOrientationRole added in v0.39.0

func EffectiveOrientationRole(row tapper.OrientationKeg) string

EffectiveOrientationRole intersects the identity's current ACL role with the selected flight's cover cap. full_access is represented by an admin cap, so it naturally contributes the identity role without widening it.

func FinalizeOrientation added in v0.39.0

func FinalizeOrientation(orientation *Orientation) error

FinalizeOrientation computes a deterministic revision when a provider has not supplied one.

func HasSessionOrientation added in v0.35.0

func HasSessionOrientation(ctx context.Context) bool

HasSessionOrientation reports whether the current call is governed by a session orientation gate. A governed recovery session has no flight but still returns true; ungated embedded surfaces return false.

func NewServer

func NewServer(tap *tapper.Tap, version string, defaults KegDefaults, opts ...ServerOptions) *sdkmcp.Server

NewServer builds an MCP server with all registered tools.

func SessionFlight added in v0.35.0

func SessionFlight(ctx context.Context) *tapper.Flight

SessionFlight returns the immutable flight snapshot captured for the current MCP tool-call boundary. Hosted discovery tools use it to apply the same cover as KEG operations without reaching into session storage.

func SessionFullAccess added in v0.39.0

func SessionFullAccess(ctx context.Context) bool

SessionFullAccess reports whether the current call runs under no-flight identity authority. Such a call has no flight snapshot but is not restricted: it reaches everything the identity reaches. Discovery tools must distinguish it from the other flightless state — failed-root recovery, which reaches nothing — because both report a nil SessionFlight.

func SessionOrientationKegs added in v0.39.0

func SessionOrientationKegs(ctx context.Context) []tapper.OrientationKeg

SessionOrientationKegs returns the exact selected-flight projection when flight was supplied, or the live no-flight identity / pinned-root graph projection when discovery omitted it. Aggregate rows are call-local and never cached in session state.

Types

type AuthIdentity added in v0.37.0

type AuthIdentity struct {
	Hub              string   `json:"hub"`
	UserID           int64    `json:"user_id"`
	Username         string   `json:"username"`
	DisplayName      string   `json:"display_name,omitempty"`
	DefaultNamespace string   `json:"default_namespace"`
	Namespaces       []string `json:"namespaces"`
}

AuthIdentity is deliberately credential-free. Do not add token, email, scope, cookie, expiry, or session fields to this MCP wire shape.

type FlightCatalogProvider added in v0.41.0

type FlightCatalogProvider interface {
	// FlightCatalog returns readable flights from one catalog projection.
	FlightCatalog(context.Context) ([]*tapper.Flight, error)
}

FlightCatalogProvider supplies an identity-filtered catalog without per-resource reads.

type FlightOrientationProvider added in v0.39.0

type FlightOrientationProvider interface {
	// Resolve reloads the pinned root's live graph and selects one flight for
	// the current call; an empty selection resolves to the root.
	Resolve(context.Context, string, string) (*Orientation, error)
}

FlightOrientationProvider refreshes one connection-pinned root and selects the root or an identity-accessible transitive descendant for one call.

type FlightProvider added in v0.37.0

type FlightProvider interface {
	// ListFlights returns the canonical refs of every flight this identity can see.
	ListFlights(context.Context) ([]string, error)
	// GetFlight resolves one flight by ref.
	GetFlight(context.Context, string) (*tapper.Flight, error)
	// CreateFlight persists a new flight and returns the stored manifest.
	CreateFlight(context.Context, tapper.CreateFlightOptions) (*tapper.Flight, error)
	// UpdateFlight applies a partial edit and returns the stored manifest. The
	// every subsequent authority-bearing call resolves the live graph again.
	UpdateFlight(context.Context, tapper.UpdateFlightOptions) (*tapper.Flight, error)
	// DeleteFlight removes a flight.
	DeleteFlight(context.Context, tapper.DeleteFlightOptions) error
}

FlightProvider supplies identity-authorized flight discovery and mutation. Session capability checks are enforced independently by the MCP gate, so implementations apply only their own transport's authorization.

type FlightSearchResult added in v0.41.0

type FlightSearchResult struct {
	Flights   []FlightSearchRow `json:"flights"`
	Truncated bool              `json:"truncated"`
}

FlightSearchResult is a bounded deterministic metadata result.

func SearchIdentityFlights added in v0.41.0

func SearchIdentityFlights(rows []*tapper.Flight, query string) FlightSearchResult

SearchIdentityFlights matches a literal query over readable metadata.

type FlightSearchRow added in v0.41.0

type FlightSearchRow struct {
	Ref         string `json:"ref"`
	Title       string `json:"title"`
	Description string `json:"description"`
}

FlightSearchRow is descriptive metadata and confers no authority.

type IdentityProvider added in v0.37.0

type IdentityProvider interface {
	// Identities returns the authenticated identities, without credentials.
	// Local MCP reports the selected Hub login; hosted MCP reports the one
	// authenticated account.
	Identities(context.Context) ([]AuthIdentity, error)
}

IdentityProvider reports who the session is authenticated as.

type KegDefaults

type KegDefaults struct {
	tapper.KegTargetOptions
	// contains filtered or unexported fields
}

KegDefaults holds server-wide keg targeting defaults.

type KegDeletionProvider added in v0.41.0

type KegDeletionProvider interface {
	// DeleteKeg removes the explicit canonical KEG and all its data, including snapshots.
	DeleteKeg(context.Context, string) error
}

KegDeletionProvider permanently removes catalog KEGs.

type KegDiscoveryProvider added in v0.37.0

type KegDiscoveryProvider interface {
	// ListKegs returns every identity-authorized canonical keg ref. MCP applies
	// the call-selected flight cover before releasing results, so
	// implementations do not filter by flight themselves.
	ListKegs(context.Context) ([]string, error)
	// CreateKeg provisions a keg and returns its canonical @namespace/keg ref.
	// The MCP gate has already checked the flight's manage_kegs capability;
	// implementations apply their own transport's identity authorization, which
	// the capability never substitutes for.
	CreateKeg(context.Context, tapper.CreateKegOptions) (string, error)
}

KegDiscoveryProvider reports the kegs an identity can reach and creates new ones. Creation lives here rather than on a keg-agnostic surface because both operations answer to the same authenticated catalog.

type KegSearchProvider added in v0.39.0

type KegSearchProvider interface {
	// SearchKegs returns bounded identity-authorized metadata matches.
	SearchKegs(context.Context, string) (KegSearchResult, error)
}

KegSearchProvider searches identity-authorized KEG metadata independently of flight authority.

type KegSearchResult added in v0.39.0

type KegSearchResult struct {
	Kegs      []KegSearchRow `json:"kegs"`
	Warnings  []string       `json:"warnings"`
	Truncated bool           `json:"truncated"`
	Partial   bool           `json:"partial"`
}

KegSearchResult includes partial-discovery warnings without failing useful results from reachable hubs.

func SearchIdentityKegsResult added in v0.41.0

func SearchIdentityKegsResult(rows []tapper.OrientationKeg, query string) KegSearchResult

SearchIdentityKegsResult retains truncation information for MCP callers.

type KegSearchRow added in v0.39.0

type KegSearchRow struct {
	Ref         string `json:"ref"`
	Role        string `json:"role"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Visibility  string `json:"visibility"`
	Source      string `json:"source"`
}

KegSearchRow is identity-authorized KEG metadata. Search results are not a flight projection and never grant operational authority.

func SearchIdentityKegs added in v0.39.0

func SearchIdentityKegs(rows []tapper.OrientationKeg, query string) []KegSearchRow

SearchIdentityKegs performs case-insensitive literal matching over canonical ref, title, and description, returning at most 50 canonically ordered rows.

type Orientation added in v0.37.0

type Orientation struct {
	Root             *tapper.Flight
	Flight           *tapper.Flight
	Path             []string
	AvailableFlights []string
	Identity         string
	Revision         string
	// RootHub binds the proof to this connection's validating Hub.
	RootHub        string
	AllowedTargets []string
	Payload        string
	Kegs           []tapper.OrientationKeg
	// AggregateKegs is the pinned root plus every accessible transitive
	// descendant, merged by highest effective role. It exists only on a live
	// per-call candidate and is never published into shared session state.
	AggregateKegs []tapper.OrientationKeg
	Warnings      []string
	// FullAccess marks an ungoverned no-flight candidate. It uses the identity's
	// real KEG roles, publishes the complete tool inventory, and emits no Hub
	// orientation header.
	FullAccess            bool
	ReconnectInstructions string
}

Orientation is one complete MCP authority candidate.

type OrientationProvider added in v0.37.0

type OrientationProvider interface {
	// Load selects the pinned root and renders it into a complete candidate.
	// It is the transport's reload boundary: whatever "which flight am I on"
	// depends on is re-read here and nowhere else.
	Load(context.Context) (*Orientation, error)
	// Render renders the exact supplied manifest. It must not consult a mutable
	// selection again, because its caller has already decided which flight is
	// authoritative and is only asking for the payload.
	Render(context.Context, *tapper.Flight) (*Orientation, error)
}

OrientationProvider owns transport-specific flight selection and rendering.

type PublicFlight added in v0.41.0

type PublicFlight struct {
	Name         string              `json:"name"`
	Hash         string              `json:"hash"`
	Title        string              `json:"title"`
	Description  string              `json:"description"`
	Source       string              `json:"source"`
	Visibility   string              `json:"visibility"`
	Capabilities []string            `json:"capabilities"`
	Cover        []PublicFlightCover `json:"cover"`
	Subflights   []string            `json:"subflights"`
	Instructions string              `json:"instructions"`
}

PublicFlight is a deliberately explicit, permission-filtered manifest view. Do not serialize Flight itself: effective cover and internal identity fields are not manifest fields and do not describe the authority of an inspection.

type PublicFlightCover added in v0.41.0

type PublicFlightCover struct {
	Namespace string `json:"namespace"`
	Keg       string `json:"keg"`
	Role      string `json:"role"`
	Depth     int    `json:"depth"`
}

type ServerOptions added in v0.12.0

type ServerOptions struct {
	// Logger is the structured logger for invocation logging. When nil,
	// invocation logging is silently skipped.
	Logger *slog.Logger
	// Reporter receives privacy-minimized tool invocation telemetry. It is
	// independent of Logger and may be nil.
	Reporter tapper.InvocationReporter
	// Providers replace transport-specific registration branches. Nil providers
	// use local adapters over tap; hosted callers inject authenticated catalog
	// and account implementations.
	OrientationProvider OrientationProvider
	FlightProvider      FlightProvider
	KegProvider         KegDiscoveryProvider
	KegSearchProvider   KegSearchProvider
	IdentityProvider    IdentityProvider
	// SharedFilesystem reports that this server and the agent host driving it
	// see the same filesystem. That holds for stdio (`tap mcp`), where a path in
	// a tool argument names the same file on both sides, and never for a hosted
	// endpoint, where it would name the server's own disk. It selects the
	// attachment transfer tools: see registerFileTools. The zero value is the
	// safe one, so a caller that forgets it gets the hosted surface.
	SharedFilesystem bool
}

ServerOptions holds configuration for creating an MCP server.

Jump to

Keyboard shortcuts

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