Help us shape the future of Go! Take the 2026 Go Developer Survey

mcpcredential

package
v0.0.51 Latest Latest
Warning

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

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

Documentation

Overview

Package mcpcredential provides the small, root-pinned custody seam used by local MCP onboarding. It deliberately contains no OAuth or client policy.

Index

Constants

View Source
const (
	BackendKeyring = "keyring" // BackendKeyring stores the generated key in the OS keyring.
	BackendFile    = "file"    // BackendFile stores the generated key in a protected file.
	// NativeNamespace is the credential-store namespace reserved for native MCP
	// custody. It is deliberately distinct from the legacy key_env namespace.
	NativeNamespace = "mecatl-mcp-oauth-native/v1" // #nosec G101 -- public namespace discriminator, not a credential.

)

BackendKeyring stores generated keys in the OS keyring; BackendFile uses a protected file.

Variables

View Source
var (

	// ErrObsoleteMarker identifies the prototype marker format handled by reset.
	ErrObsoleteMarker = errors.New("MCP credential marker uses an obsolete format")
	// ErrPendingArtifactMismatch identifies an artifact that does not match its pending marker.
	ErrPendingArtifactMismatch = errors.New("MCP credential artifact identity does not match pending marker")
	// ErrArtifactMissing identifies a missing artifact pinned by custody metadata.
	ErrArtifactMissing = errors.New("MCP credential artifact is missing")
	// ErrArtifactMismatch identifies a valid artifact whose identity differs from its marker.
	ErrArtifactMismatch = errors.New("MCP credential artifact identity does not match marker")
	// ErrResetInProgress identifies custody that only Reset may resume.
	ErrResetInProgress = errors.New("MCP credential custody reset is in progress")
)

Functions

func CanonicalFileKeyPath added in v0.0.49

func CanonicalFileKeyPath(path string) (string, error)

CanonicalFileKeyPath returns the physical path pinned by native file custody. The host lifecycle command uses it to detect profiles that share a key.

func Reset added in v0.0.49

func Reset(ctx context.Context, root, backend, filePath string, keyring Keyring) error

Reset retires native custody for root. Use ResetWithResult when the caller needs to know whether a mismatched artifact was preserved.

Types

type ConfirmFile

type ConfirmFile func(context.Context) (bool, error)

ConfirmFile confirms the attended fallback to file custody.

type Detector

type Detector func(context.Context) (bool, error)

Detector reports whether the platform keyring is available.

type Keyring

type Keyring interface {
	Get(string, string) (string, error)
	Set(string, string, string) error
	Delete(string, string) error
}

Keyring reads and writes the OS credential entry used by MCP custody.

type MarkerInspection

type MarkerInspection string

MarkerInspection is the bounded, non-secret result of inspecting custody metadata.

const (
	// MarkerMissing means the custody marker does not exist.
	MarkerMissing MarkerInspection = "missing"
	// MarkerUnavailable means the custody root or marker cannot be inspected.
	MarkerUnavailable MarkerInspection = "unavailable"
	// MarkerLocked means the custody root is locked.
	MarkerLocked MarkerInspection = "locked"
	// MarkerRecovery means the marker requires recovery.
	MarkerRecovery MarkerInspection = "recovery required"
	// MarkerPresent means the custody marker is valid.
	MarkerPresent MarkerInspection = "present"
)

func InspectMarker

func InspectMarker(root string) MarkerInspection

InspectMarker checks only the root-pinned custody marker. It never opens a keyring, reads a credential, or returns marker contents. The result is safe for status/list projections.

type Options

type Options struct {
	Requested, FilePath, Platform string
	Detect                        Detector
	ConfirmFile                   ConfirmFile
	Attended                      bool
	Keyring                       Keyring
}

Options controls MCP credential custody selection.

type ResetResult added in v0.0.49

type ResetResult struct {
	ArtifactPreserved bool
}

ResetResult reports custody that reset deliberately left untouched.

func ResetWithResult added in v0.0.49

func ResetWithResult(ctx context.Context, root, backend, filePath string, keyring Keyring, preserveArtifact bool) (ResetResult, error)

ResetWithResult retires the native custody for root. preserveArtifact is set when the host has found another configured root using the same file key path. A mismatched artifact is never deleted; the resetting marker records that decision so retries preserve it too.

type Selection

type Selection struct {
	Backend, Locator string
	Key              []byte
}

Selection is the selected custody backend and the key it opened or created.

func Open

func Open(ctx context.Context, root, backend, filePath string, keyring Keyring) (Selection, error)

Open opens an existing root-pinned MCP credential backend.

func Resolve

func Resolve(ctx context.Context, root string, opts Options) (Selection, error)

Resolve selects and opens the root-pinned MCP credential backend.

Jump to

Keyboard shortcuts

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