mcpauth

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 17 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcpauth signs Blitz in to MCP servers over HTTP with OAuth (spec_027_parity 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

Constants

This section is empty.

Variables

View Source
var ErrNotSignedIn = errors.New("not signed in")

ErrNotSignedIn means no sign-in is stored for the server.

Functions

func Forget

func Forget(store secrets.Store, server string) error

Forget removes server's sign-in.

func Handler

func Handler(store secrets.Store, server string, r *Record) auth.OAuthHandler

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, whose state is checked; a code alone isn't taken, as its state can't be). 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.

func Save

func Save(store secrets.Store, server string, r *Record) error

Save keeps server's sign-in.

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.

func Load

func Load(store secrets.Store, server string) (*Record, error)

Load reads server's sign-in (ErrNotSignedIn when there's none).

Jump to

Keyboard shortcuts

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