Documentation
¶
Overview ¶
The admin console's read-only JSON API at /api, ported from 8f2af2e:src/keepsake/server/api.py.
The HTTP entry point, which verifies the database first. Ported from 8f2af2e:src/keepsake/server/app.py.
The admin session, ported from 8f2af2e:src/keepsake/server/auth.py: one password, one signed cookie.
Bundle uploads: a gzipped tar of OKF files, read as `keepsake import` reads a directory.
Who a /mcp request acts as. Auth mode none binds one tenant at startup; jwt mode takes the tenant from an HS256 token on every request, so one server serves many tenants.
The MCP wiring, ported from 2de90d2:src/keepsake/server/tools.py's register and 8f2af2e:src/keepsake/server/app.py's streamable HTTP app.
Prometheus metrics, served on their own port so a public Ingress to /mcp never exposes them.
The seven advertised tools, ported from 2de90d2:src/keepsake/server/tools.py's _TOOLS in wire key order.
The seven tool bodies, ported from 2de90d2:src/keepsake/server/tools.py. The tenant comes from the request's caller, so no tool takes one, and no tool returns a body the agent could not read.
Index ¶
- Constants
- func AdminPassword() (string, error)
- func BuildApp(ctx context.Context, cfg Config) (app, metrics http.Handler, closeApp func(), err error)
- func FixedTenant(tenant uuid.UUID) func(http.Handler) http.Handler
- func NewAPI(cs *store.ConceptStore, a *Auth) http.Handler
- func NewMCPHandler(t *Tools) http.Handler
- func UIEnabled() bool
- type Auth
- type Config
- type JWT
- type MisconfiguredAdmin
- type ToolError
- type Tools
- func (t *Tools) Create(ctx context.Context, path string, kw map[string]any) (writeResult, error)
- func (t *Tools) Grep(ctx context.Context, pattern string, limit int) ([]grepHit, error)
- func (t *Tools) List(ctx context.Context, prefix string) (listing, error)
- func (t *Tools) Read(ctx context.Context, path string) (*concept, error)
- func (t *Tools) Relate(ctx context.Context, fromPath, toPath string) (any, error)
- func (t *Tools) Search(ctx context.Context, query string, limit int, prefix *string) ([]card, error)
- func (t *Tools) Update(ctx context.Context, path string, expectedVersion *int, kw map[string]any) (any, error)
Constants ¶
const MaxLimit = 200
MaxLimit caps and advertises a call's results, so one call cannot return the whole corpus.
const MaxVersion = 1<<53 - 1
MaxVersion is the largest integer a JSON number carries exactly, far below bigint's maximum.
const Version = "0.5.0"
Version is this release. scripts/release.sh sets it to Chart.yaml's appVersion.
Variables ¶
This section is empty.
Functions ¶
func AdminPassword ¶
AdminPassword reads KEEPSAKE_ADMIN_PASSWORD, refusing when the console is on without one.
func BuildApp ¶
func BuildApp(ctx context.Context, cfg Config) (app, metrics http.Handler, closeApp func(), err error)
BuildApp returns the app, its metrics handler and a closer, or fails when the database does not isolate tenants.
func FixedTenant ¶ added in v0.3.0
FixedTenant serves every request as tenant, for auth mode none.
func NewAPI ¶
func NewAPI(cs *store.ConceptStore, a *Auth) http.Handler
NewAPI serves the admin API. Mount it at /api with the prefix stripped.
func NewMCPHandler ¶
NewMCPHandler serves the seven keepsake tools over stateless streamable HTTP with JSON responses.
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth is the one admin account. The password is the whole credential.
func NewAuth ¶
NewAuth derives the cookie key from the password with scrypt, so a password change revokes every cookie.
func (*Auth) CheckPassword ¶
type JWT ¶ added in v0.3.0
JWT verifies HS256 tokens from one trusted issuer. Secrets[0] signs; every secret verifies, for rotation.
func JWTFromEnv ¶ added in v0.3.0
JWTFromEnv reads KEEPSAKE_JWT_ISSUER, KEEPSAKE_JWT_AUDIENCE and one secret per line of KEEPSAKE_JWT_SECRET_FILE.
func (*JWT) Middleware ¶ added in v0.3.0
Middleware binds the verified caller, or answers 401 for a bad token and 403 for a token naming no tenant.
type MisconfiguredAdmin ¶
type MisconfiguredAdmin struct{ Msg string }
MisconfiguredAdmin is returned at startup. An enabled console with no password is worse than none.
func (*MisconfiguredAdmin) Error ¶
func (e *MisconfiguredAdmin) Error() string
type ToolError ¶
type ToolError struct{ Msg string }
ToolError is surfaced to the agent. It MUST NOT contain a concept body.
type Tools ¶
type Tools struct {
// contains filtered or unexported fields
}
func (*Tools) Relate ¶
Relate appends the edge, retrying past concurrent writers, since appending a link commutes.