Skip to main content
Glama
vaultwarden-mcp

vaultwarden-mcp

by metodex-tech

vaultwarden-mcp

CI License: MIT Node.js >= 20 MCP Container

Let AI agents use your Vaultwarden / Bitwarden secrets — without giving them your vault.

vaultwarden-mcp is a self-hosted Model Context Protocol server that connects any MCP client (GitHub Copilot, Claude Desktop / Claude Code, Cursor, VS Code, Codex, ChatGPT and Claude.ai connectors…) to a Vaultwarden or Bitwarden vault through a default-deny policy. The agent can see item names, read only the fields you explicitly allow, and — the key feature — use a secret in an HTTP request without ever seeing its value.

Русская версия


Contents

Related MCP server: keywarden

Why

Agents increasingly need credentials: an API token to call a service, a database password for a migration, a deploy key. The usual options are bad: paste the secret into the chat (now it lives in the transcript forever), or give the agent full vault access (one prompt injection away from exfiltrating everything).

vaultwarden-mcp sits in between:

  • Nothing is readable by default. You allowlist individual item fields.

  • Secrets can be used without being revealed. use_secret injects the value into an outbound HTTPS request to a URL you pre-approved and masks it in the response. The model only sees the API's answer.

  • A human can stay in the loop. Any read or use can require per-request approval via MCP elicitation.

  • Everything is audited — without ever logging secret values.

Features

🔒 Default-deny policy

Per item, per field allowlist; re-read on every call, so edits take effect immediately.

🕶️ use_secret

Inject a secret into an HTTP request (URL, header or body) bound to allowlisted URL prefixes and methods; response is masked (raw, URL-encoded, base64, JSON-escaped forms).

✋ Human approval

approval: "always" per tool or per secret, via MCP elicitation. Fails closed if the client can't ask.

⏳ Grant limits

expiresAt and maxUses per use_secret grant.

🧾 Audit log

JSON lines (tool, item id, field, origin/path, result, user) to stderr and optionally a file — never values.

🔌 Two transports

stdio for local clients; Streamable HTTP for remote clients.

🪪 Auth for HTTP

Static bearer token, or OAuth 2.1 via any OIDC provider (Authentik, Keycloak, Auth0, Entra ID…) with protected-resource metadata.

👥 Multi-user

With OIDC, each user gets their own vault session, policy and Bitwarden state. Experimental.

📦 Easy to run

npx, Docker image (Bitwarden CLI bundled), docker compose, or SSH forced command.

🧰 Setup CLI

init prepares a data dir; config <client> prints a ready-to-paste client config.

How it works

flowchart LR
    subgraph Clients["MCP clients"]
        A1["Copilot / Claude Code / Cursor<br/>(local, stdio)"]
        A2["ChatGPT / Claude.ai connectors<br/>(remote, HTTP + OAuth)"]
    end

    subgraph Server["vaultwarden-mcp"]
        T["Transport<br/>stdio · Streamable HTTP"]
        AU["Auth<br/>bearer token · OIDC JWT"]
        P["Policy engine<br/>default deny · approval · TTL · max uses"]
        U["use_secret<br/>inject → fetch → mask"]
        L["Audit log<br/>(no values)"]
    end

    IdP["OIDC provider<br/>(e.g. Authentik)"]
    BW["Bitwarden CLI (bw)<br/>unlocked session"]
    VW[("Vaultwarden /<br/>Bitwarden server")]
    API["Allowlisted API<br/>https://api.example.com/v1/"]

    A1 --> T
    A2 --> T
    T --> AU --> P
    AU -. "validate JWT (JWKS)" .-> IdP
    P --> BW --> VW
    P --> U --> API
    P --> L
    U --> L

The server drives the official Bitwarden CLI (bw) with a pre-unlocked session key. The master password never touches the server process: you unlock once, store the session key in a file (or a systemd credential), and the server reads it per call.

Quickstart

You need: a Vaultwarden or Bitwarden account, a personal API key (Vaultwarden: Settings → Security → Keys), and either Node.js ≥ 20 + bw (npm i -g @bitwarden/cli) or Docker.

Option A — local, with npx (stdio)

npx -y vaultwarden-mcp init        # creates ~/.config/vaultwarden-mcp and prints the next steps

init prints the exact commands for your OS. They boil down to:

export BITWARDENCLI_APPDATA_DIR=~/.config/vaultwarden-mcp/bw
bw config server https://vault.example.com
bw login --apikey
bw unlock --raw > ~/.config/vaultwarden-mcp/session && chmod 600 ~/.config/vaultwarden-mcp/session

Then allow some fields in ~/.config/vaultwarden-mcp/policy.json (see Policy) and print a config for your client:

npx -y vaultwarden-mcp config claude-desktop

Option B — local, with Docker (stdio)

Same data directory, but bw runs inside the image — nothing to install except Docker:

docker run --rm -it -v ~/.config/vaultwarden-mcp:/data -e BITWARDENCLI_APPDATA_DIR=/data/bw \
  --entrypoint sh ghcr.io/metodex-tech/vaultwarden-mcp:latest -c \
  'bw config server https://vault.example.com && bw login --apikey && bw unlock --raw > /data/session'

npx -y vaultwarden-mcp config cursor --launch docker

Option C — remote server, over HTTP (docker compose)

For ChatGPT / Claude.ai connectors or a shared team server:

git clone https://github.com/metodex-tech/vaultwarden-mcp && cd vaultwarden-mcp
cp .env.example .env               # choose VW_AUTH=token or oidc, set VW_PUBLIC_URL
mkdir -p data && sudo chown 1000:1000 data
docker compose run --rm --entrypoint bw vaultwarden-mcp config server https://vault.example.com
docker compose run --rm --entrypoint bw vaultwarden-mcp login --apikey
docker compose run --rm --entrypoint sh vaultwarden-mcp -c 'bw unlock --raw > /data/session'
docker compose up -d
curl -s http://127.0.0.1:3000/healthz

Put a TLS reverse proxy in front of port 3000. Details, OIDC and multi-user setup: docs/deployment.md, docs/oidc.md.

WARNING

OIDC / multi-user mode is experimental. It is covered by unit tests but has not yet been verified in a production deployment. HTTP with a static bearer token and stdio (local or over SSH) are the field-tested paths.

Option D — remote server, over SSH (stdio)

No HTTP exposed at all: the client runs ssh, and an authorized_keys forced command starts the server inside a long-running container with docker exec. This is the most locked-down remote setup and works with every stdio client. See docs/deployment.md#ssh-stdio.

npx -y vaultwarden-mcp config copilot --launch ssh --ssh-target mcp@vault-host.example.com

Connecting clients

vaultwarden-mcp config <client> prints a snippet and where to put it. Clients: copilot, claude-desktop, claude-code, cursor, vscode, codex, generic. Launch modes: --launch npx|docker|ssh|http.

{
  "mcpServers": {
    "vaultwarden": {
      "command": "npx",
      "args": ["-y", "vaultwarden-mcp", "serve"],
      "env": {
        "VW_POLICY": "/home/you/.config/vaultwarden-mcp/policy.json",
        "VW_SESSION_FILE": "/home/you/.config/vaultwarden-mcp/session",
        "BITWARDENCLI_APPDATA_DIR": "/home/you/.config/vaultwarden-mcp/bw"
      }
    }
  }
}

Claude Desktop: claude_desktop_config.json; Cursor: ~/.cursor/mcp.json; Copilot CLI: ~/.copilot/mcp-config.json.

claude mcp add vaultwarden \
  -e VW_POLICY=$HOME/.config/vaultwarden-mcp/policy.json \
  -e VW_SESSION_FILE=$HOME/.config/vaultwarden-mcp/session \
  -e BITWARDENCLI_APPDATA_DIR=$HOME/.config/vaultwarden-mcp/bw \
  -- npx -y vaultwarden-mcp serve
{
  "servers": {
    "vaultwarden": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "vaultwarden-mcp", "serve"],
      "env": { "VW_POLICY": "${userHome}/.config/vaultwarden-mcp/policy.json",
               "VW_SESSION_FILE": "${userHome}/.config/vaultwarden-mcp/session",
               "BITWARDENCLI_APPDATA_DIR": "${userHome}/.config/vaultwarden-mcp/bw" }
    }
  }
}
{
  "mcpServers": {
    "vaultwarden": {
      "type": "http",
      "url": "https://vault-mcp.example.com/mcp",
      "headers": { "Authorization": "Bearer <VW_HTTP_TOKEN>" }
    }
  }
}

With OIDC (--auth oauth), omit the header: the client discovers the authorization server from /.well-known/oauth-protected-resource and runs the OAuth flow. For ChatGPT and Claude.ai, add a custom connector with URL https://vault-mcp.example.com/mcp. Clients that only speak stdio can use mcp-remote.

Tools

Tool

What the model gets

Gated by

vault_status

Lock status (unlocked, locked, unauthenticated)

—

list_item_metadata

id, name, type of every item

— (no secret values)

get_secret(id, field)

The value of one allowlisted field: password, username, totp, notes, sshPrivateKey, sshPublicKey, or a custom field as field:<name>

items allowlist + approval.get_secret

use_secret(id, field, request)

The HTTP response of a request in which {{secret}} was replaced by the value — masked

use rule: URL prefixes, methods, expiresAt, maxUses, approval

Example use_secret call made by the model:

{
  "id": "6f0c…",
  "field": "password",
  "request": {
    "method": "GET",
    "url": "https://api.example.com/v1/me",
    "headers": { "Authorization": "Bearer {{secret}}" }
  }
}

Prefer use_secret over get_secret whenever the secret is only needed to call an API: the value never enters the model context, the transcript, or the client's logs.

Policy

A JSON file (default /policy/allowlist.json, set with VW_POLICY). Missing file = deny everything. Re-read on every call.

{
  "approval": { "get_secret": "always", "use_secret": "never" },
  "items": {
    "2b1e0c9a-0000-4000-8000-000000000001": ["username", "password"]
  },
  "use": {
    "2b1e0c9a-0000-4000-8000-000000000002": {
      "password": {
        "http": {
          "allowedUrls": ["https://api.example.com/v1/"],
          "methods": ["GET", "POST"]
        },
        "maxUses": 50,
        "expiresAt": "2026-12-31T23:59:59Z",
        "approval": "always"
      }
    }
  }
}
  • items — fields readable via get_secret.

  • use — fields usable via use_secret, independently of items (a secret can be usable but not readable).

  • approval — "never" or "always"; the most specific setting wins (per-grant → per-tool → VW_APPROVAL). Unknown values fail closed to "always".

Full reference: docs/policy.md · Example: examples/policy.example.json.

Configuration

All configuration is via environment variables (see .env.example).

Variable

Default

Description

VW_POLICY (alias VW_ALLOWLIST)

/policy/allowlist.json

Policy file path

VW_SESSION_FILE

$CREDENTIALS_DIRECTORY/bw-session if present

File with the bw session key (alternatively set BW_SESSION)

BITWARDENCLI_APPDATA_DIR

bw default

Bitwarden CLI state directory

BW_CLI_PATH

bw

Path to the Bitwarden CLI

VW_APPROVAL

never

Default approval mode (never / always)

VW_AUDIT_LOG

—

Also append audit JSON lines (always written to stderr) to this file

VW_STATE_DIR

—

Persist use_secret maxUses counters in use-counts.json here (shared by all processes; per user under users/ in multi-user mode). Without it, counters live in memory

VW_TRANSPORT

stdio

http is equivalent to serve --http

VW_HTTP_HOST / VW_HTTP_PORT

127.0.0.1 / 3000

HTTP listen address

VW_PUBLIC_URL

—

External base URL, e.g. https://vault-mcp.example.com (required for OIDC)

VW_ALLOWED_HOSTS

public URL host + loopback

Host header allowlist (DNS-rebinding protection)

VW_SESSION_IDLE_SECONDS

1800

Idle MCP session expiry

VW_AUTH

inferred

oidc, token or none (none only on loopback)

VW_HTTP_TOKEN / VW_HTTP_TOKEN_FILE

—

Static bearer token (≥ 24 chars)

VW_OIDC_ISSUER / VW_OIDC_AUDIENCE

—

OIDC issuer URL and expected aud

VW_OIDC_REQUIRED_SCOPES

—

Comma-separated scopes every token must have

VW_USERS_DIR

—

Enables multi-user mode: one sub-directory per OIDC user

VW_ALLOWED_USERS

everyone authenticated

Comma-separated sub, email or username allowlist

Security model

What we protect: vault contents from an AI agent that is curious, wrong, or prompt-injected; and from anyone who reaches the HTTP endpoint.

Threat

Mitigation

Prompt injection asks the agent to dump secrets

Default deny; only allowlisted fields; prefer use_secret; optional human approval per request.

Agent sends a usable secret to an attacker's server

use_secret URL prefixes match exact origin + path segment boundary (no example.com.evil.net, no user@host tricks); HTTPS only; redirects are not followed; the secret may not alter the destination.

API echoes the secret back

Response body, status text and Location are masked in raw, URL-encoded, base64/base64url and JSON-escaped form.

Runaway usage

maxUses, expiresAt, approval; every call is audited.

Secret leaks into logs

Audit records ids, fields, origin/path, results — never values or full URLs with query strings. Errors from outbound requests are replaced with generic messages.

Unauthenticated network access

HTTP refuses to start without auth on non-loopback addresses; token compared in constant time; OIDC JWTs validated against JWKS (issuer, audience, expiry, scopes); Host-header allowlist.

One user reads another's vault

Per-user directories (session, policy, bw state); MCP sessions are bound to the identity that created them.

Stolen session key

Keep it in a 0600 file or systemd credential; the server never sees the master password. Lock the vault (bw lock) to revoke instantly.

Out of scope / limitations — please read:

  • A field you allow for get_secret is disclosed to the model and the client provider. Use use_secret when possible.

  • An allowed API can still be misused within its scope (e.g. POST to an allowed endpoint). Scope URL prefixes and methods tightly.

  • Masking can't catch every transformation (hashes, partial echoes, encrypted forms).

  • Without VW_STATE_DIR, maxUses counters are in memory and reset when the server process restarts (in SSH-stdio mode, per connection). Set VW_STATE_DIR to persist them.

  • Whoever controls the host running the server and its session key controls the allowed secrets.

  • Approval relies on the MCP client implementing elicitation honestly.

See SECURITY.md for reporting vulnerabilities.

Comparison with @bitwarden/mcp-server

vaultwarden-mcp

@bitwarden/mcp-server

Goal

Let agents use specific secrets safely

Let agents manage the vault (CRUD, org admin)

Default access

Deny all, field-level allowlist

Full vault of the unlocked account

Use a secret without revealing it

✅ use_secret

❌

Human approval per request

✅ elicitation

❌

Grant TTL / use limits

✅

❌

Remote HTTP with OAuth / multi-user

✅

stdio only

Write access to the vault

❌ (by design)

✅

They are complementary: use Bitwarden's server for vault administration, this one for agents that should only consume secrets.

Roadmap

  • Telegram / webhook approval channel (for clients without elicitation)

  • use_secret for local commands (inject into env of an allowlisted command)

  • Persistent use counters (VW_STATE_DIR)

  • Additional unlock providers: Bitwarden Secrets Manager, TPM-sealed session key

  • Publish to npm, GHCR and the MCP Registry

Development

npm ci
npm run lint
npm test                       # node --test, uses a mock bw (fixtures/mock-bw.js)
BW_CLI_PATH=fixtures/mock-bw.js npm run smoke

Contributing

PRs welcome — see CONTRIBUTING.md. Changes that widen what an agent can see must come with tests and a threat-model note.

Reporting vulnerabilities

Please don't open public issues for security problems — see SECURITY.md.

License

MIT © metodex-tech. Not affiliated with Bitwarden, Inc. or the Vaultwarden project.

Available Tools

4 tools
get_secretGet allowlisted secretA

Return one secret field of a vault item, only if that item id and field are listed in the server-side allowlist. Every call is audited. Prefer use_secret when the value only needs to be sent to an API.

Inputs: id (required), field (required).

list_item_metadataList vault item metadataA

List item IDs, names, and types only. Passwords, notes, fields, attachments, and secret values are never returned.

Inputs: no named parameters.

use_secretUse a secret without revealing itA

Send an HTTPS request with a vault secret injected server-side. Write {{secret}} where the secret goes (URL, header value, or body); the value is substituted by the server and is never returned to you. Responses are masked. Only URLs allowlisted for that item/field in the server policy are permitted; the policy may also require human approval and limit uses or lifetime.

Inputs: id (required), field (required), request (required).

vault_statusVault statusA

Return only whether the Bitwarden CLI vault is unlocked, locked, unauthenticated, or in an unknown state.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 4 tools

    Disambiguation4/5

    get_secret and use_secret both involve secret access and could initially look overlapping, but the descriptions clearly distinguish returning a value versus server-side injection without disclosure. vault_status and list_item_metadata are cleanly separate from the secret-access tools.

    Naming Consistency4/5

    Three names follow a clear verb_noun pattern (get_secret, list_item_metadata, use_secret), while vault_status is noun-based and lacks a verb. This is a minor inconsistency but the overall convention remains readable and predictable.

    Tool Count5/5

    Four tools is well-scoped for a security-sensitive secret broker: check status, discover allowed items, retrieve a secret, and use a secret. Each tool has a distinct role and none feels redundant.

    Completeness4/5

    The surface covers the core secret-consumption lifecycle: vault state, item discovery, controlled retrieval, and server-side use. Write or administrative operations are intentionally absent for security, though a way to inspect policy/allowlist details could be a useful minor addition.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to securely use real secrets (API keys, database passwords) by requiring human approval for each release, ensuring secrets never enter the model's context.
      2
      Apache 2.0
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to make authenticated API calls and run commands with secrets injected, while keeping credentials completely hidden from the model, with policy enforcement, grants, and audit logging.
      6
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to access only task-relevant data with secrets hidden and personal details pseudonymized, while enforcing destination policies to prevent data leakage even under prompt injection.
      2
      AGPL 3.0
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to look up stored logins by URL, name, or alias and use them without seeing the secrets, injecting authentication into HTTP requests, running commands with credentials in the environment and scrubbed output, and fetching 2FA codes, subject to per-credential policies and user approval.
      23
      MIT