Skip to main content
Glama
go2fa-mcp

go2fa-mcp

by TASCOHN
README.md
# go2fa

Local TOTP (2FA) codes: a web page, a CLI and an MCP server. **Your secret never leaves your device.**

- Web: https://go2fa.app (English and Vietnamese, works offline, light and dark theme)
- Core: one file of plain JavaScript on WebCrypto, no runtime dependencies (`src/core.js`)
- Same house as [Key Atlas](https://keyatlas.vngroundtruth.com) (API key recipes and a local leak scanner)
- License: MIT

For **your own accounts only**. go2fa does not accept lists of accounts or `id|password|2fa` lines, does not check whether accounts are alive, and never puts a secret in a URL.

## CLI

```bash
npx go2fa selftest          # runs the RFC 6238 test vectors, prints "match 18/18"
```

The secret comes from the `GO2FA_SECRET` environment variable or from stdin (a hidden prompt in a terminal). It is **never** accepted as an argument, so it cannot end up in your shell history.

```powershell
# PowerShell
$env:GO2FA_SECRET = Read-Host -MaskInput 'secret'
npx go2fa code              # current code
npx go2fa code --next       # next code
npx go2fa check 123456      # which 30-second window does this code belong to? (clock drift)
```

```bash
# bash
read -rs GO2FA_SECRET && export GO2FA_SECRET
npx go2fa code
```

Options: `--digits 6|7|8`, `--period N`, `--algo SHA1|SHA256|SHA512`. An `otpauth://totp/...` link works instead of a bare Base32 secret and carries its own settings.

## MCP server (stdio, local)

An AI assistant can ask for a code **by label**. The server never returns a secret and never accepts one as a tool argument.

```json
{
  "mcpServers": {
    "go2fa": {
      "command": "npx",
      "args": ["-y", "-p", "go2fa", "go2fa-mcp"],
      "env": { "GO2FA_FILE": "C:\\Users\\you\\go2fa-secrets.json" }
    }
  }
}
```

Secrets are loaded by you, by label, in one of two ways:

- environment variable `GO2FA_SECRET_<LABEL>` (label upper-cased, other characters become `_`)
- a JSON file named by `GO2FA_FILE`: `{ "github": "JBSWY3DPEHPK3PXP" }` (keep it out of version control and protect it with file permissions)

Tools:

| Tool | Input | Returns |
|---|---|---|
| `totp_code` | `label` | the current code and seconds left |
| `totp_check` | `label`, `code` | which window (+-3) the code belongs to |

## Verify

```bash
npm test      # RFC 6238 vectors, cross-check against otpauth on random inputs, boundaries, CLI and MCP checks
```

## Development

`npm run build` copies the core into `public/` and generates the site pages; `npm run dev` serves `public/` locally.