Documentation
¶
Overview ¶
Package mcpauth signs Blitz in to MCP servers over HTTP with OAuth (spec_parity_027 PAR-MCP-04): the authorization-code flow with PKCE, through a local callback or a code pasted over SSH, with the client registered dynamically. The tokens and what refreshing them needs are kept in the secret store (the OS keychain, else an owner-only file), refreshed as they expire, and never shown to the model.
Index ¶
- Variables
- func Forget(store secrets.Store, server string) error
- func Handler(store secrets.Store, server string, r *Record) auth.OAuthHandler
- func Login(ctx context.Context, store secrets.Store, server, serverURL string, ...) error
- func NeedsLogin(server string) auth.OAuthHandler
- func Save(store secrets.Store, server string, r *Record) error
- type Record
Constants ¶
This section is empty.
Variables ¶
var ErrNotSignedIn = errors.New("not signed in")
ErrNotSignedIn means no sign-in is stored for the server.
Functions ¶
func Handler ¶
Handler is the OAuth handler for server in a running workspace: its stored token, refreshed and kept as it expires. A server that asks to sign in (again) is told to run blitz mcp login.
func Login ¶
func Login(ctx context.Context, store secrets.Store, server, serverURL string, show func(authURL string), pasted <-chan string) error
Login signs in to server at serverURL: it registers Blitz with the server's authorization server, has the user authorize it in a browser (show gets the URL to open), and receives the code on a local callback, or from pasted when the browser is elsewhere (an SSH session: paste the address the browser ends on, or the code). The sign-in is saved in store.
func NeedsLogin ¶
func NeedsLogin(server string) auth.OAuthHandler
NeedsLogin is the handler for an HTTP server with no stored sign-in: it adds nothing to requests, and a server that asks for authorization is told to run blitz mcp login.
Types ¶
type Record ¶
type Record struct {
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret,omitempty"`
AuthURL string `json:"auth_url"`
TokenURL string `json:"token_url"`
RedirectURL string `json:"redirect_url"`
Scopes []string `json:"scopes,omitempty"`
Token *oauth2.Token `json:"token"`
}
Record is what a server's sign-in keeps: the client Blitz registered, the authorization server's endpoints, and the latest token.