Documentation
¶
Overview ¶
Package mcp implements a Model Context Protocol server over stdio, exposing the CLI's verbs as tools so an MCP-capable agent (Claude, etc.) can drive the Privasys platform natively. Transport is newline-delimited JSON-RPC 2.0 on stdin/stdout (the MCP stdio transport).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WatchParentDeath ¶ added in v0.32.0
WatchParentDeath calls stop() when the process that spawned this one exits.
An MCP server's lifetime is bound to its client. The primary shutdown signal is stdin EOF (the client closes the pipe), but if the client dies WITHOUT closing our stdin — a Windows pipe-handle leak, or a client crash that leaves a write handle open elsewhere — the stdin read blocks forever and the server lingers. This watchdog is the backstop: when the spawning process is gone, we stop, so an orphaned `privasys mcp serve` cannot pile up.
Types ¶
type Deps ¶
Deps is the per-call context a tool handler needs. It is rebuilt per call so tokens refresh transparently. Issuer/Endpoint are always populated; Client + Token are set and Authed is true only when the user is signed in (so onboarding tools can run before there is a session).
type DepsFunc ¶
DepsFunc returns a fresh Deps. It errors only on hard failures (config load), not on "not signed in" — that surfaces as Authed=false.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server serves MCP over the given reader/writer.
func (*Server) Serve ¶
Serve runs the read/dispatch/write loop until stdin EOF or ctx cancellation.
The scan runs in a goroutine so the main loop can select on ctx.Done(): a blocking stdin read (an orphaned pipe that never delivers EOF) no longer pins the process — a signal or the parent-death watchdog cancels ctx and we return. The reader goroutine may remain parked on that read, but the process is exiting, so it is reaped with us.