mcp

package
v0.38.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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.

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 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
	// return value is authoritative: a session editing its own flight adopts
	// exactly these bytes.
	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 IdentityProvider added in v0.37.0

type IdentityProvider interface {
	// Identities returns the authenticated identities, without credentials.
	// Local MCP reports every configured 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 KegDiscoveryProvider added in v0.37.0

type KegDiscoveryProvider interface {
	// ListKegs returns every identity-authorized canonical keg ref. MCP applies
	// the immutable active-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 Orientation added in v0.37.0

type Orientation struct {
	Flight   *tapper.Flight
	Payload  string
	Kegs     []tapper.OrientationKeg
	Warnings []string
}

Orientation is one complete, immutable MCP authority candidate.

type OrientationProvider added in v0.37.0

type OrientationProvider interface {
	// Load selects the active flight 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 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
	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