adapterd

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProtocolVersion is the management API version shared by the daemon and the Dock app.
	ProtocolVersion = 1
	// LocalTokenHeader is the per-profile loopback credential. It is never forwarded upstream.
	LocalTokenHeader = "X-MCP-Runtime-Local-Token" // #nosec G101 -- HTTP header name; no credential value is embedded.
	// DefaultListenAddr is the single loopback listener shared by every profile path.
	DefaultListenAddr = "127.0.0.1:8099"
)
View Source
const (
	AuthEnrolled       = "enrolled"
	AuthSignInRequired = "sign_in_required"
	AuthRenewalFailed  = "renewal_failed"
	AuthNotEnrolled    = "not_enrolled"
)

Variables

This section is empty.

Functions

func LaunchdPlistPath

func LaunchdPlistPath(home string) string

LaunchdPlistPath is the per-user LaunchAgent path.

func RemoveLaunchdPlist

func RemoveLaunchdPlist(path string) error

RemoveLaunchdPlist deletes the managed plist.

func SlugFromServer

func SlugFromServer(server string) (string, error)

SlugFromServer builds a URL path segment from a server name.

func UniqueSlug

func UniqueSlug(base string, taken func(string) bool) string

UniqueSlug returns slug, or slug-2, slug-3, when taken.

func WriteLaunchdPlist

func WriteLaunchdPlist(path, binary string, env map[string]string) error

WriteLaunchdPlist writes the user LaunchAgent. It does not start the daemon.

Types

type AddProfileRequest

type AddProfileRequest struct {
	Server      string `json:"server"`
	Namespace   string `json:"namespace,omitempty"`
	Team        string `json:"team,omitempty"`
	Agent       string `json:"agent,omitempty"`
	PlatformURL string `json:"platformUrl,omitempty"`
	RuntimeURL  string `json:"runtimeUrl"`
}

AddProfileRequest creates one profile. LocalToken is returned once.

type Control

type Control struct {
	Daemon      *Daemon
	RequirePeer bool
	SocketPath  string
}

Control serves the owner-only management API.

func (*Control) Handler

func (c *Control) Handler() http.Handler

func (*Control) Serve

func (c *Control) Serve(ctx context.Context) error

type Daemon

type Daemon struct {
	ListenAddr string
	StateDir   string
	SocketPath string
	Store      *Store
	Secrets    SecretStore
	Hooks      Hooks
	Router     *Router
	Logs       *LogBuffer
	// contains filtered or unexported fields
}

Daemon supervises one loopback listener and many profile paths.

func (*Daemon) AddProfile

func (d *Daemon) AddProfile(ctx context.Context, req AddProfileRequest) (Profile, string, error)

func (*Daemon) ClientConfig

func (d *Daemon) ClientConfig(id string) (Profile, string, error)

ClientConfig returns one profile's local endpoint and credential for the same-user CLI to write to an owner-only MCP client configuration file.

func (*Daemon) DeleteProfile

func (d *Daemon) DeleteProfile(id string, purge bool) error

func (*Daemon) LogTail

func (d *Daemon) LogTail(n int) []string

func (*Daemon) RestartProfile

func (d *Daemon) RestartProfile(ctx context.Context, id string) error

func (*Daemon) Run

func (d *Daemon) Run(ctx context.Context) error

func (*Daemon) SetStartupAtLogin

func (d *Daemon) SetStartupAtLogin(v bool)

func (*Daemon) Status

func (d *Daemon) Status() Status

type FileSecretStore

type FileSecretStore struct {
	// contains filtered or unexported fields
}

FileSecretStore is an owner-only JSON file. Tests and non-Keychain hosts use it.

func NewFileSecretStore

func NewFileSecretStore(path string) *FileSecretStore

func (*FileSecretStore) Delete

func (s *FileSecretStore) Delete(account string) error

func (*FileSecretStore) Get

func (s *FileSecretStore) Get(account string) (string, error)

func (*FileSecretStore) Put

func (s *FileSecretStore) Put(account, secret string) error

type Hooks

type Hooks struct {
	Enroll func(ctx context.Context, p Profile) (Material, error)
}

Hooks let the CLI enroll and renew without the daemon importing the CLI.

type LogBuffer

type LogBuffer struct {
	// contains filtered or unexported fields
}

LogBuffer keeps a bounded list of redacted lines.

func NewLogBuffer

func NewLogBuffer(max int) *LogBuffer

func (*LogBuffer) Add

func (l *LogBuffer) Add(line string)

func (*LogBuffer) Tail

func (l *LogBuffer) Tail(n int) []string

type Material

type Material struct {
	CertPEM        []byte
	KeyPEM         []byte
	CA             []byte
	Expires        time.Time
	PlatformURL    string
	Human          string
	Team           string
	Session        string
	SessionExpires time.Time
	TrustDomain    string
	Namespace      string
	OAuthRequired  *bool
}

Material is certificate PEM stored for one profile.

type Profile

type Profile struct {
	ID             string    `json:"id"`
	Slug           string    `json:"slug"`
	Server         string    `json:"server"`
	Namespace      string    `json:"namespace,omitempty"`
	Team           string    `json:"team,omitempty"`
	Agent          string    `json:"agent,omitempty"`
	PlatformURL    string    `json:"platformUrl,omitempty"`
	RuntimeURL     string    `json:"runtimeUrl"`
	Human          string    `json:"human,omitempty"`
	Session        string    `json:"session,omitempty"`
	SessionExpires time.Time `json:"sessionExpires,omitempty"`
	TrustDomain    string    `json:"trustDomain,omitempty"`
	CreatedAt      time.Time `json:"createdAt"`
	CertExpires    time.Time `json:"certExpires,omitempty"`
	AuthState      string    `json:"authState"`
	OAuthRequired  *bool     `json:"oauthRequired,omitempty"`
	LastError      string    `json:"lastError,omitempty"`
	RenewalError   string    `json:"renewalError,omitempty"`
}

Profile is one saved connection to one MCP server.

func (Profile) LocalURL

func (p Profile) LocalURL(listenAddr string) string

LocalURL is the MCP client URL for this profile on listenAddr.

type ProfileStatus

type ProfileStatus struct {
	ID                string     `json:"id"`
	Slug              string     `json:"slug"`
	Server            string     `json:"server"`
	Team              string     `json:"team,omitempty"`
	Human             string     `json:"human,omitempty"`
	Agent             string     `json:"agent,omitempty"`
	PlatformURL       string     `json:"platformUrl,omitempty"`
	RuntimeURL        string     `json:"runtimeUrl,omitempty"`
	Namespace         string     `json:"namespace,omitempty"`
	LocalURL          string     `json:"localUrl"`
	UpstreamReachable *bool      `json:"upstreamReachable"`
	UpstreamCheckedAt time.Time  `json:"upstreamCheckedAt,omitempty"`
	AuthState         string     `json:"authState"`
	OAuthRequired     *bool      `json:"oauthRequired,omitempty"`
	CertExpires       *time.Time `json:"certExpires,omitempty"`
	SessionExpires    *time.Time `json:"sessionExpires,omitempty"`
	CertNotBefore     *time.Time `json:"certNotBefore,omitempty"`
	CertSPIFFE        string     `json:"certSpiffe,omitempty"`
	RenewalError      string     `json:"renewalError,omitempty"`
	LastError         string     `json:"lastError,omitempty"`
}

ProfileStatus separates local readiness from upstream and enrollment state.

type Route

type Route struct {
	Profile Profile
	Token   string
	Handler http.Handler
	// UpstreamReachable is the last connectivity probe, distinct from local readiness.
	UpstreamReachable *bool
	UpstreamCheckedAt time.Time
}

Route is one profile mounted at /<slug>/mcp.

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router serves every profile on one listener and rejects unknown paths.

func NewRouter

func NewRouter() *Router

func (*Router) Delete

func (r *Router) Delete(slug string)

func (*Router) Routes

func (r *Router) Routes() []Route

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Router) Set

func (r *Router) Set(route Route)

type SecretStore

type SecretStore interface {
	Put(account, secret string) error
	Get(account string) (string, error)
	Delete(account string) error
}

SecretStore keeps per-profile credentials out of the profile catalog.

func NewKeychainStore

func NewKeychainStore() SecretStore

NewKeychainStore is unavailable off macOS. Callers use FileSecretStore.

type Status

type Status struct {
	Protocol       int             `json:"protocol"`
	ProcessRunning bool            `json:"processRunning"`
	ListenAddr     string          `json:"listenAddr"`
	ListenerReady  bool            `json:"listenerReady"`
	CheckedAt      time.Time       `json:"checkedAt"`
	StartupAtLogin bool            `json:"startupAtLogin"`
	Profiles       []ProfileStatus `json:"profiles"`
}

Status is the machine-readable daemon snapshot.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is the on-disk profile catalog. Secrets are not stored here.

func NewStore

func NewStore(path string) *Store

func (*Store) Delete

func (s *Store) Delete(id string) error

func (*Store) List

func (s *Store) List() ([]Profile, error)

func (*Store) Put

func (s *Store) Put(p Profile) error

Jump to

Keyboard shortcuts

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