verae-mcp-timestamping-serv.../internal/tools/register.go
George Lambert 2eb9ec72c6
Some checks failed
test-and-deploy / test (push) Failing after 10m46s
test-and-deploy / deploy-138 (push) Has been cancelled
feat(mcp): oauth_start / oauth_complete for social login
Browser OAuth via customer.verae.ai portal (authentik at auth.verae.ai).
oauth_start returns authorize_url+state; oauth_complete polls until xVerae-
access_token. Open without bearer on public MCP; welcome/register copy updated.
2026-10-20 16:40:50 -04:00

83 lines
4.2 KiB
Go

package tools
import "github.com/modelcontextprotocol/go-sdk/mcp"
// NewServer builds an MCP server with the full Verae timestamping tool set.
func NewServer(d *Deps) *mcp.Server {
s := mcp.NewServer(&mcp.Implementation{
Name: "verae-timestamping",
Version: "0.1.0",
}, &mcp.ServerOptions{
Instructions: instructions,
})
Register(s, d)
return s
}
// Register adds welcome, stamp, stamp_batch, verify, hash_report, signup, login, session, create_user.
func Register(s *mcp.Server, d *Deps) {
if d == nil {
d = &Deps{}
}
mcp.AddTool(s, &mcp.Tool{
Name: "welcome",
Description: "Show the Verae welcome and onboarding text: what timestamping is, what this MCP does, " +
"and how to signup or login. Call this when a user connects without an account or asks what Verae is.",
}, d.welcome)
mcp.AddTool(s, &mcp.Tool{
Name: "stamp",
Description: "Commit a SHA-256. scope=local is the leaf file ledger. scope=global posts the digest to api.veraetime.net and reuses the first CID unless restamp is true. " +
"Optional metadata is sent as a verae-meta-git/1 history; blank values do not delete fields. " +
"Optional receipt_format: omit=text; receipt|PDF-Receipt=PDF; JSON-Receipt=JSON; MD|MD-Receipt; CSV|CSV-Receipt; TSV|TSV-Receipt. " +
"Always returns receipts[]; also returns artifacts[] in the chosen format (stdio writes ~/.verae/receipts; public MCP returns content only).",
}, d.stamp)
mcp.AddTool(s, &mcp.Tool{
Name: "stamp_batch",
Description: "Commit up to 500 SHA-256 digests at once. scope=global (default) needs your Verae API key and charges each new digest to your account (your own repeats are free); returns one receipt entry per digest, in order, with the credits charged and your balance.",
}, d.stampBatch)
mcp.AddTool(s, &mcp.Tool{
Name: "verify",
Description: "Check a receipt. want_scope=global asks api.veraetime.net (central source of truth). " +
"Pass receipt_id, or supply receipt / receipt_path with receipt_format (text|JSON-Receipt|MD|CSV|TSV|PDF-Receipt) to extract the id. " +
"On success, re-emits an artifact in the requested format.",
}, d.verify)
mcp.AddTool(s, &mcp.Tool{
Name: "hash_report",
Description: "JSON-array history of receipts for one SHA-256 (Carfax).",
}, d.hashReport)
mcp.AddTool(s, &mcp.Tool{
Name: "signup",
Description: "Self-serve create a VeraeTime user (POST /auth/signup, role=user), then return access_token. " +
"Username must be an email address (a welcome email is sent to that address). " +
"No Authorization required. Write access_token to your MCP bearer file (or Authorization header) before stamp. " +
"On stdio/local transport the token is also stored on this host.",
}, d.signup)
mcp.AddTool(s, &mcp.Tool{
Name: "login",
Description: "Log in to api.veraetime.net and return access_token. Username is the account email address. " +
"On the public HTTP server the host credential is never replaced — only the tool result carries the token. " +
"On stdio/local transport the token is also stored on this host (auth.properties).",
}, d.login)
mcp.AddTool(s, &mcp.Tool{
Name: "oauth_start",
Description: "Start social login (Google/GitHub/Apple/X) via auth.verae.ai. Returns authorize_url + state. " +
"Open authorize_url in a browser window, then call oauth_complete with the same state. " +
"For a new account set accept_tos=true. No Authorization required.",
}, d.oauthStart)
mcp.AddTool(s, &mcp.Tool{
Name: "oauth_complete",
Description: "Finish social login after the browser callback. Pass state from oauth_start; polls until done or wait_sec. " +
"Returns access_token (prefer xVerae- portal key for commercial stamps). No Authorization required.",
}, d.oauthComplete)
mcp.AddTool(s, &mcp.Tool{
Name: "session",
Description: "Validate the caller's VeraeTime JWT (Authorization: Bearer). Returns valid, username, role, and expires_at.",
}, d.session)
mcp.AddTool(s, &mcp.Tool{
Name: "create_user",
Description: "Admin create a VeraeTime user (POST /auth/users / Swagger Auth/createUser). " +
"Username must be an email address (a Welcome to Verae email is sent). " +
"Requires Authorization: Bearer of an admin. Used by operators and edge provision; " +
"self-serve MCP clients should use signup.",
}, d.createUser)
}