TOTP codes
Store a 2FA secret on your webhook and let agents fetch a fresh one-time code, without Token Vault or the agent ever seeing the secret.
A 2FA (TOTP) credential holds a one-time-password seed. When an agent reads it, your webhook computes the current code (RFC 6238) and returns the code, never the seed. The credential page shows the same live code with a countdown. Token Vault sees neither the seed nor the code.
The reference webhook supports this out of the box (capability totp).
Add one
In Add credential, choose Other, then 2FA (TOTP). Fill one of:
| Field | Example |
|---|---|
| otpauth:// URI (from the QR code) | otpauth://totp/Example:user@example.com?secret=JBSWY3DPEHPK3PXP&issuer=Example |
| Secret Key (Base32) | JBSWY3DPEHPK3PXP |
Typing in one clears the other. The Add flow sends the seed plus the descriptors (issuer, account, algorithm, digits, period) to your webhook, not the URI.
Do not attach MCP servers to a TOTP credential (the web app does not offer it). Access is Value.
Supported inputs and parameters
| Input | What happens |
|---|---|
| otpauth:// URI | Secret, issuer, account, algorithm, digits and period are extracted. |
| Raw Base32 secret | Stored with defaults: SHA1, 6 digits, 30 second period. |
| Parameter | Default | Values |
|---|---|---|
| Algorithm | SHA1 | SHA1, SHA256, SHA512 |
| Digits | 6 | 6, 7, 8 |
| Period | 30 s | Seconds each code is valid |
What just happened
| Hop | Sees the seed? | Sees the code? |
|---|---|---|
| Token Vault | No | No |
| Agent | No | Yes |
| Your webhook | Yes | Yes |
The credential page uses /v1/totp-code the same way, with a totp_code ticket.
Security properties
| Property | How |
|---|---|
| Seed is not returned | Stored by ticket in storage you control, behind a webhook you run. Never returned. |
| Encrypted at rest | The reference webhook encrypts; your webhook, your choice. |
| Code-only responses | The webhook returns the code and timing, not the seed. |
| Policy-gated | Every read passes the agent's grant and policies first. |
| Audited | Agent reads log AGENT_CREDENTIAL_ACCESS. The credential page's live code is not logged as a credential access. See Activity. |
| Revocable | Revoke the grant or suspend the agent. |
| Short-lived | A code expires within one period. |
Troubleshooting
- Code does not match your authenticator. Check the webhook host's clock, and that algorithm, digits and period match the provider.
- "Token is not a TOTP token". The credential was stored with another type. Add it again as 2FA (TOTP).
- Countdown looks off. It is computed from
remainingSecondsreturned by the webhook. A skewed webhook clock shifts it.
Implement it in your own webhook
The reference TypeScript webhook already does all of this. Read on only for a from-scratch or custom-language webhook. Advertise the totp capability at /v1/exchange and /v1/health, intercept TOTP in /v1/credential, and add /v1/totp-code as described in the webhook protocol. The examples use Python and pyotp; any RFC 6238 library works.
Code generation
import time
import pyotp
def generate_totp_code(secret: str, stored_doc: dict) -> dict:
meta = stored_doc.get("meta", {})
algorithm = meta.get("totpAlgorithm", "SHA1")
digits = meta.get("totpDigits", 6)
period = meta.get("totpPeriod", 30)
digest = {"SHA1": "sha1", "SHA256": "sha256", "SHA512": "sha512"}.get(algorithm.upper(), "sha1")
totp = pyotp.TOTP(secret, digits=digits, interval=period, digest=digest)
return {
"code": totp.now(),
"remainingSeconds": period - (int(time.time()) % period),
"period": period,
"digits": digits,
}Intercept in /v1/credential
After decrypting the stored credential and before returning it:
token_type = token.get("tokenType", stored_doc.get("meta", {}).get("tokenType", ""))
if token_type == "TOTP" and token.get("totpSecret"):
result = generate_totp_code(token["totpSecret"], stored_doc)
token = {
"accessToken": result["code"],
"tokenType": "TOTP",
"serviceName": service,
"remainingSeconds": result["remainingSeconds"],
"period": result["period"],
"digits": result["digits"],
"totpGenerated": True,
}The pattern is: detect after decryption, transform before returning. The seed never reaches the caller.
/v1/totp-code
Accept GET and POST, verify the ticket like /v1/credential, accept ticket purposes totp_code, agent_credential and user_reveal, and reject store and proxy tickets (otherwise the endpoint becomes a TOTP oracle). Return:
{ "code": "492071", "remainingSeconds": 17, "period": 30, "digits": 6 }Keep totpSecret in your list of encrypted fields. If you get an empty accessToken, check the interception exists and that the seed is valid Base32 (letters A to Z and digits 2 to 7).
Ready to try it?
Sign in with Google or email. Your credentials stay on your own webhook, and the quickstart gets Claude Code making its first MCP tool call in about 15 minutes.
Connect with your own OAuth app
Connect Google, GitHub, Spotify or a custom provider with an OAuth app you register yourself, so the provider sends the sign-in result to your webhook and no code or token passes through Token Vault.
Raw credentials
Store a service account key or other raw credential on your webhook, which mints short-lived access tokens for agents instead of handing out the long-lived key.