Skip to content

About

🧩 Template auth-vault β€” MCP credential management server, clean version to fork and adapt

Resources

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

9 Commits

Folders and files

Repository files navigation

@mcp/auth-vault

MCP server for secure credential management, browser-based login automation, SSH key vault, TOTP/2FA auto-solving, and audit logging.

Status:  active    |    License: MIT    |    Version: 0.2.0

Overview

Auth Vault stores encrypted credentials, secrets, and SSH keys (AES-256-GCM), automates browser login flows via Playwright, auto-solves TOTP-based 2FA challenges, and tracks sensitive actions via an audit log. It provides both an MCP interface (for AI clients) and a Web UI dashboard (for manual management).

Interface Port URL
Web UI Dashboard 5600 http://<tailscale-ip>:5600/
MCP SSE 5501 http://<tailscale-ip>:5501/sse
MCP Health 5501 http://<tailscale-ip>:5501/health

Features

  • Encrypted vault β€” credentials, secrets, and SSH keys stored with AES-256-GCM
  • SSH Key Vault β€” generate, store, retrieve, and export SSH keys (Ed25519, RSA-2048/4096)
  • SSH Config generation β€” export SSH config fragments and key files
  • Browser automation β€” Playwright-based login with form filling
  • CAPTCHA detection β€” automatic detection of CAPTCHA challenges during login
  • Trusted devices β€” device fingerprinting with trusted device management
  • TOTP/2FA auto-solve β€” RFC 6238 implementation, generates and submits 2FA codes
  • TOTP rotation detection β€” suggests code refresh when window is near expiry
  • QR code support β€” generate QR for Google Authenticator setup
  • Secrets management β€” API keys, bearer tokens, access/refresh tokens
  • Audit logging β€” JSONL audit log with auto-rotation for sensitive actions
  • Vault health monitoring β€” periodic integrity checks every 12 hours
  • Discovery API β€” metadata overview of all vault contents without decryption
  • Tailscale-only access β€” binds to Tailscale IP by default, blocks external traffic
  • Two service modes β€” STDIO (MCP standard) and SSE (HTTP for persistent connections)

Quick Start

Prerequisites

  • Node.js 22+
  • Playwright Chromium (installed via postinstall)
  • Tailscale (recommended for SSE mode)

Setup

# Install dependencies
pnpm install

# Build TypeScript
pnpm run build

# Configure environment
cp .env.example .env
# Edit .env: set VAULT_ENCRYPTION_KEY (64 hex chars) or leave empty for auto-generated

Configuration

All configuration via .env file or environment variables:

Variable Default Description
VAULT_ROOT ./vault Storage directory for encrypted vault files
VAULT_ENCRYPTION_KEY auto-generated AES-256 key (64 hex chars, persist for data survival)
AUTH_SSE_PORT β€” Enable SSE mode on given port (empty = STDIO mode)
AUTH_BIND_ADDRESS auto (Tailscale) Explicit bind address for SSE mode
BROWSER_HEADLESS true Run Playwright in headless mode
BROWSER_TIMEOUT 30000 Browser operation timeout (ms)
AUDIT_LOG_MAX_BYTES 10485760 Audit log rotation threshold (10 MB)
LOG_LEVEL info Logging level: debug, info, warn, error

Usage

STDIO Mode (default for MCP clients)

node dist/index.js

SSE Mode (HTTP server for persistent connections)

# Set AUTH_SSE_PORT=5501 in .env, then:
node dist/index.js

Web UI Dashboard

node dist/web/server.js
# Dashboard at http://<tailscale-ip>:5600/

CLI Commands

Credentials

pnpm run add-creds       # Add credentials interactively
pnpm run list-creds      # List stored credentials (JSON)
pnpm run get-creds       # Get credential details (JSON)

Secrets

pnpm run add-secret      # Add a secret interactively
pnpm run list-secrets    # List stored secrets (JSON)

SSH Keys

pnpm run add-ssh-key       # Add existing SSH key interactively
pnpm run generate-ssh-key  # Generate new SSH key pair and store
pnpm run list-ssh-keys     # List stored SSH keys (JSON)
pnpm run get-ssh-key       # Get SSH key details (JSON)

REST API

Credentials

Method Path Description
GET /api/credentials List all credentials (metadata only)
GET /api/credentials?includePassword=true List all credentials (with passwords)
GET /api/credentials/:id Get credential details (password hidden by default)
POST /api/credentials Create a new credential
PUT /api/credentials/:id Update a credential
DELETE /api/credentials/:id Delete a credential
GET /api/credentials/:id/devices List trusted devices
POST /api/credentials/:id/devices/add Add a trusted device
DELETE /api/credentials/:id/devices/:fingerprint Remove a trusted device
GET /api/credentials/:id/audit Audit log entries for a credential
POST /api/credentials/:id/trust-device Shortcut to add a trusted device

Secrets

Method Path Description
GET /api/secrets List all secrets (metadata only)
POST /api/secrets Create a new secret
DELETE /api/secrets/:id Delete a secret
GET /api/secrets/:id/detail Get decrypted secret value

SSH Keys

Method Path Description
GET /api/ssh List all SSH keys
GET /api/ssh/:id Get SSH key details (private key hidden by default)
POST /api/ssh Store an SSH key
PUT /api/ssh/:id Update an SSH key
DELETE /api/ssh/:id Delete an SSH key
POST /api/ssh/generate Generate and store a new SSH key pair
GET /api/ssh/:id/config Get SSH config fragment
POST /api/ssh/extract Extract public key from private key
POST /api/ssh/:id/rotate Generate new key pair for existing entry
GET /api/ssh/:id/public Get public key in plain text

TOTP / 2FA

Method Path Description
GET /api/totp/generate Generate a new TOTP secret with QR code
POST /api/totp/verify Verify a TOTP code (returns rotationSuggested if near expiry)
POST /api/totp/attach Attach a TOTP secret to a credential
POST /api/totp/regenerate Replace TOTP secret on an existing credential
GET /api/totp/:id/next-code Get current + next TOTP codes
GET /api/totp/:id/rotation-info Get TOTP rotation status

Login Automation

Method Path Description
POST /api/login/:id Start automated login (returns needsCaptcha, needs2FA, trustedDevice, retryCount)
POST /api/login/:id/2fa Submit 2FA code during login
GET /api/login/status/:sessionId Check login session status
POST /api/login/:id/cancel Cancel an active login session
GET /api/login/sessions List active login sessions
GET /api/login/:id/fallback Get recovery options (TOTP recovery, backup codes)

Discovery

Method Path Description
GET /api/discovery/overview Metadata overview of all vault entries (no decryption)
GET /api/discovery/stats Aggregate statistics (counts by type, TOTP status)
GET /api/discovery/recent Recent activity (last 10 audit entries + updated credentials)

Audit

Method Path Description
GET /api/audit/actions List audit log entries (newest first)
POST /api/audit/actions Manually log an action
GET /api/audit/summary Activity summary for last 24 hours
GET /api/audit/services Services with audit activity

Health

Method Path Description
GET /health Service health check
GET /api/health/integrity Vault file integrity validation
GET /api/health/summary Combined health (integrity + storage stats + audit stats)

Systemd Services

# MCP SSE server (port 5501)
systemctl status mcp-auth-vault

# Web UI dashboard (port 5600)
systemctl status mcp-auth-vault-web

Both services restart automatically on failure and enable at boot.


Security

  • AES-256-GCM encryption for all stored credentials, secrets, and SSH keys
  • Tailscale-restricted β€” Web UI and SSE mode block non-Tailscale connections
  • Encryption key persisted in .env β€” if lost, data cannot be recovered
  • Headless browser β€” no visible UI during automated logins
  • Audit logging β€” all sensitive actions logged to append-only JSONL file
  • Vault integrity β€” periodic validation every 12 hours
  • Private key material β€” SSH private keys encrypted at rest, never exposed in list endpoints

Project Structure

src/
β”œβ”€β”€ index.ts              # MCP server entry (STDIO + SSE)
β”œβ”€β”€ config.ts             # Zod-validated configuration
β”œβ”€β”€ credentials/
β”‚   β”œβ”€β”€ totp.ts           # TOTP (RFC 6238) implementation
β”‚   β”œβ”€β”€ qr.ts             # QR code generation + TOTP secret generator
β”‚   β”œβ”€β”€ vault.ts          # Encrypted credential store
β”‚   └── types.ts          # Credential type definitions
β”œβ”€β”€ ssh/
β”‚   β”œβ”€β”€ vault.ts          # Encrypted SSH key store
β”‚   β”œβ”€β”€ generator.ts      # SSH key pair generation (Ed25519, RSA)
β”‚   └── types.ts          # SSH key type definitions
β”œβ”€β”€ secrets/
β”‚   β”œβ”€β”€ manager.ts        # Encrypted secrets store
β”‚   └── types.ts          # Secret type definitions
β”œβ”€β”€ audit/
β”‚   β”œβ”€β”€ log.ts            # JSONL audit log with auto-rotation
β”‚   └── health.ts         # Vault integrity check module
β”œβ”€β”€ authVault/
β”‚   └── fingerprint.ts    # Trusted device fingerprinting
β”œβ”€β”€ browser/
β”‚   └── manager.ts        # Playwright session management
β”œβ”€β”€ services/
β”‚   └── definitions.ts    # Login templates (Google, etc.)
β”œβ”€β”€ web/
β”‚   β”œβ”€β”€ server.ts         # Web UI HTTP server + REST API
β”‚   └── dashboard.ts      # HTML dashboard template
β”œβ”€β”€ tools/
β”‚   β”œβ”€β”€ credentials.ts    # MCP tool definitions for credentials
β”‚   β”œβ”€β”€ ssh.ts            # MCP tool definitions for SSH keys
β”‚   β”œβ”€β”€ secrets.ts        # MCP tool definitions for secrets
β”‚   β”œβ”€β”€ services.ts       # MCP tool definitions for services
β”‚   β”œβ”€β”€ login.ts          # MCP tool definitions for login
β”‚   β”œβ”€β”€ audit.ts          # MCP tool definitions for audit/health
β”‚   └── totp.ts           # MCP tool definitions for TOTP
└── cli/
    β”œβ”€β”€ add-credentials.ts
    β”œβ”€β”€ add-secret.ts
    β”œβ”€β”€ add-ssh-key.ts
    β”œβ”€β”€ generate-ssh-key.ts
    β”œβ”€β”€ get-ssh-key.ts
    β”œβ”€β”€ list-ssh-keys.ts
    β”œβ”€β”€ list-credentials.ts
    β”œβ”€β”€ list-secrets.ts
    └── get-credential.ts

Tech Stack

  • Runtime: Node.js 22+, TypeScript ESM
  • MCP: @modelcontextprotocol/sdk v1.16
  • Encryption: Node.js crypto (AES-256-GCM)
  • Browser: Playwright (Chromium)
  • Config: Zod validation
  • UI: Vanilla JS (no framework)
  • QR: qrcode npm package

License

MIT

About

🧩 Template auth-vault β€” MCP credential management server, clean version to fork and adapt

Resources

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages