verae-mcp-timestamping-serv.../internal/tools/register.go
George Lambert 3ec1f0516b
Some checks failed
test-and-deploy / test (push) Failing after 12m55s
test-and-deploy / deploy-138 (push) Has been cancelled
feat(mcp): optional receipt_format on stamp/verify (text/PDF/JSON/MD/CSV/TSV)
Add receipt_format to stamp and verify. Omitted → text; receipt|PDF-Receipt → PDF;
JSON-Receipt → JSON; MD|MD-Receipt; CSV|CSV-Receipt; TSV|TSV-Receipt.

Stamp always returns receipts[] and adds artifacts[] in the chosen format.
Stdio writes ~/.verae/receipts (0600); public MCP returns content_text/content_base64 only.
Verify accepts inline receipt or receipt_path (stdio), parses id, and re-emits an artifact.

Vendors pdfcert (+ slim statuslang, gofpdf) for CERT-01 PDF. Also lands welcome tool
and email-username helpers already wired into register/public paths.
2026-10-20 16:02:20 -04:00

72 lines
3.6 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: "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)
}