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.
74 lines
4.7 KiB
Go
74 lines
4.7 KiB
Go
package tools
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/modelcontextprotocol/go-sdk/mcp"
|
|
)
|
|
|
|
// Welcome message shown on connect (via instructions) and by the welcome tool.
|
|
// Keep this the source of truth for onboarding copy.
|
|
const welcomeMessage = `Welcome to Verae.
|
|
|
|
Account and auth are required for use of this MCP. Before stamp, verify, hash_report, or session, you must create an account or sign in and attach your access_token.
|
|
|
|
Verae Timestamping proves that a specific digital object existed at a point in time. You hash the file (or data) locally — Verae never needs the file bytes, only the digest — then commit that digest. The result is a receipt you can verify later (and share) without revealing the original content.
|
|
|
|
This MCP server is how AI clients (Grok, Claude, Cursor, and others) and local tools talk to Verae:
|
|
• welcome — onboarding (no account required)
|
|
• signup / login — create an account or sign in with email+password; you receive an access_token (required next)
|
|
• oauth_start / oauth_complete — social login (Google/GitHub/Apple/X) via a browser window at auth.verae.ai
|
|
• stamp / stamp_batch — commit one or many SHA-256 digests (local ledger or global VeraeTime)
|
|
• verify / hash_report — check a receipt or list history for a digest
|
|
• session — confirm your bearer is still valid
|
|
|
|
Public HTTP (mcp.verae.ai): every tool except welcome, signup, login, oauth_start, and oauth_complete needs Authorization: Bearer (VeraeTime JWT or xVerae- API key). There is no host-login fallback. Put access_token in your client's bearer file (Grok: bearer_token_file → ~/.verae/mcp-bearer) or send Authorization on each tools/call. Do not paste tokens into chat.
|
|
|
|
Important: the username must be an email address (welcome mail is sent there on signup).
|
|
|
|
Next step — create or sign in to your account:
|
|
1. Social: call oauth_start (accept_tos=true for new accounts), open authorize_url in a browser, then oauth_complete with state → access_token.
|
|
2. New here with password? Call tool signup with your email as username and a password → access_token (Welcome email is sent).
|
|
3. Already registered? Call tool login with your email and password → access_token.
|
|
4. Save the token in your MCP client, call session to confirm, then stamp or verify.
|
|
|
|
Global stamps may meter prepaid credits when edge billing is enabled.`
|
|
|
|
const instructions = "Welcome to Verae Timestamping MCP (mcp.verae.ai). " +
|
|
"Account and auth are required for use. Username must be an email address. " +
|
|
"On first connect, or whenever the user has no Verae account / bearer, greet them warmly: " +
|
|
"welcome them to Verae, briefly explain digests-only timestamping (hash locally; stamp digests; get a verifiable receipt), " +
|
|
"explain that this MCP requires signup or login before stamp/verify/session, " +
|
|
"tell them the username must be an email address (a Welcome to Verae email is sent on signup), " +
|
|
"then ask them to sign in (tool login) or create an account (tool signup). " +
|
|
"Prefer calling tool welcome to show the full onboarding text, then guide signup or login. " +
|
|
"Only welcome, signup, login, oauth_start, and oauth_complete work without a bearer. " +
|
|
"Social login: oauth_start → open authorize_url → oauth_complete. " +
|
|
"After signup/login/oauth, save access_token to the client's bearer file (Grok: ~/.verae/mcp-bearer via bearer_token_file) or Authorization header — never paste tokens into chat. " +
|
|
"When VERAE_MCP_EDGE_URL is set, global stamps meter on zap.verae.ai. " +
|
|
"Admin create_user is for operators only."
|
|
|
|
// WelcomeOut is returned by the welcome tool.
|
|
type WelcomeOut struct {
|
|
Title string `json:"title"`
|
|
Message string `json:"message"`
|
|
NextSteps []string `json:"next_steps"`
|
|
ToolsHint []string `json:"tools_hint"`
|
|
HasAccount string `json:"ask"`
|
|
}
|
|
|
|
func (d *Deps) welcome(_ context.Context, _ *mcp.CallToolRequest, _ EmptyArgs) (*mcp.CallToolResult, WelcomeOut, error) {
|
|
return nil, WelcomeOut{
|
|
Title: "Welcome to Verae",
|
|
Message: welcomeMessage,
|
|
NextSteps: []string{
|
|
"Social: oauth_start (accept_tos=true if new) → open authorize_url → oauth_complete → access_token",
|
|
"New user (password): signup with email username + password → access_token (Welcome email is sent)",
|
|
"Existing user (password): login with email + password → access_token",
|
|
"Save access_token to your MCP bearer file or Authorization header (do not paste into chat)",
|
|
"Call tool session to confirm, then stamp a SHA-256 digest",
|
|
},
|
|
ToolsHint: []string{"welcome", "oauth_start", "oauth_complete", "signup", "login", "session", "stamp", "stamp_batch", "verify", "hash_report"},
|
|
HasAccount: "Account and auth are required for use. Prefer oauth_start/oauth_complete for Google/GitHub/Apple/X, or signup/login with an email username.",
|
|
}, nil
|
|
}
|