mcp-server

bitwarden/mcp-server

3.6

If you are the rightful owner of mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Bitwarden MCP Server facilitates secure interaction between AI models and a user's Bitwarden vault using the Model Context Protocol.

Tools
10
Resources
0
Prompts
0

Bitwarden MCP Server

Model Context Protocol (MCP) server that enables interaction with the Bitwarden password manager vault via the MCP protocol. The server provides two complementary interfaces:

  • CLI-based tools: Personal vault management and organization operations using the Bitwarden CLI
  • API-based tools: Enterprise organization administration using the Bitwarden Public API

This dual approach allows AI models to securely manage both personal vault items and organization-level resources through defined tool interfaces.

Prerequisites

  • Node.js 22
  • For CLI operations: Bitwarden CLI (bw) installed, authenticated, and valid session token
  • For API operations: Bitwarden organization with API access and valid client credentials

Installation

Option One: Configuration in your AI app

Open up your application configuration, e.g. for Claude Desktop:

{
  "mcpServers": {
    "bitwarden": {
      "command": "npx",
      "args": ["-y", "@bitwarden/mcp-server"]
    }
  }
}

Option Two: Local checkout

Requires that this repository be checked out locally. Once that's done:

npm install
npm run build

Setup

The server supports two authentication methods:

Option A: CLI Authentication (for personal vault operations)

  1. Install Bitwarden CLI:

    npm install -g @bitwarden/cli
    
  2. Log in to Bitwarden:

    bw login
    
  3. Get session token:

    export BW_SESSION=$(bw unlock --raw)
    

Option B: API Authentication (for organization management)

  1. Create API credentials in your Bitwarden organization settings

  2. Set environment variables:

    export BW_CLIENT_ID="your_client_id"
    export BW_CLIENT_SECRET="your_client_secret"
    
  3. Optional: Set custom API URLs (if using self-hosted):

    export BW_API_BASE_URL="https://api.bitwarden.com"
    export BW_IDENTITY_URL="https://identity.bitwarden.com"
    

Note: You can use both authentication methods simultaneously for full functionality.

Testing

Running unit tests

The project includes Jest unit tests covering validation, CLI commands, and core functionality.

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm test -- --coverage

# Run specific test file
npm test validation.spec.ts

# Run tests matching a pattern
npm test -- --testNamePattern="validation"

Inspection and development

MCP Inspector

Use the MCP Inspector to test the server interactively:

# Start the inspector
npm run inspect

This will:

  1. Start the MCP server
  2. Launch the inspector UI in your browser
  3. Allow you to test all available tools interactively

Available tools

The server provides comprehensive Bitwarden functionality through two authentication methods:

CLI Authentication is used for:

  • Personal vault operations (items, folders, passwords)
  • Quick organization queries (list members, collections)
  • Organization member confirmation workflows
  • Collection creation and editing
  • Item collection assignments

API Authentication is used for:

  • Full organization administration (members, groups, policies)
  • Bulk operations and automation
  • Advanced permission management
  • Audit log retrieval
  • Subscription management

Note: You can use both authentication methods simultaneously. The CLI tools are lighter-weight for simple operations, while API tools provide comprehensive organization management.

Personal Vault Tools (CLI Authentication)
Session Management
ToolDescriptionRequired Parameters
lockLock the vaultNone
unlockUnlock with master passwordpassword
syncSync vault dataNone
statusCheck CLI statusNone
Vault Items and Folders
ToolDescriptionRequired Parameters
listList vault items/folderstype (items/folders/collections/organizations/org-members/org-collections)
getGet specific item/folderobject, id, optional organizationid for org-collection
generateGenerate password/passphraseVarious optional parameters
createCreate new item or folderobjectType, name, additional fields for items
editEdit existing item or folderobjectType, id, optional fields to update
edit_item_collectionsEdit which collections an item belongs toitemId, organizationId, collectionIds (array)
moveMove (share) a vault item to an organization with collectionsitemId, organizationId, collectionIds (array)
deleteDelete vault item/folderobject, id, optional permanent
Organization Operations (CLI)
ToolDescriptionRequired Parameters
confirmConfirm invited organization memberorganizationId, memberId
create_org_collectionCreate new organization collectionorganizationId, name, optional externalId, groups
edit_org_collectionEdit existing organization collectionorganizationId, collectionId, optional name, groups
device_approval_listList pending device approval requestsorganizationId
device_approval_approveApprove a device authorization requestorganizationId, requestId
device_approval_approve_allApprove all pending device authorization requestsorganizationId
device_approval_denyDeny a device authorization requestorganizationId, requestId
device_approval_deny_allDeny all pending device authorization requestsorganizationId

Note: Device approval commands are only available to organization admins/owners for managing trusted device approval requests.

Organization Management Tools (API Authentication)
Collections Management
ToolDescriptionRequired Parameters
list_org_collectionsList organization collectionsNone
get_org_collectionGet collection detailsid
update_org_collectionUpdate existing collectionid
delete_org_collectionDelete collectionid
Members Management
ToolDescriptionRequired Parameters
list_org_membersList organization membersNone
get_org_memberGet member detailsid
invite_org_memberInvite new memberemail, type
update_org_memberUpdate existing memberid
remove_org_memberRemove member from organizationid
reinvite_org_memberRe-invite memberid
get_org_member_groupsGet member's group assignmentsid
update_org_member_groupsUpdate member's group assignmentsid, groupIds
Groups Management
ToolDescriptionRequired Parameters
list_org_groupsList organization groupsNone
get_org_groupGet group detailsid
create_org_groupCreate new groupname
update_org_groupUpdate existing groupid, name
delete_org_groupDelete groupid
get_org_group_membersGet group's member assignmentsid
update_org_group_membersUpdate group's member assignmentsid, memberIds
Policies Management
ToolDescriptionRequired Parameters
list_org_policiesList organization policiesNone
get_org_policyGet policy detailstype
update_org_policyUpdate organization policytype, enabled
Organization Management
ToolDescriptionRequired Parameters
get_org_subscriptionGet subscription detailsNone
update_org_subscriptionUpdate subscription settingsNone
import_org_users_and_groupsImport members and groupsNone
Events and Auditing
ToolDescriptionRequired Parameters
get_org_eventsGet organization audit logsNone

Manual testing

  1. Start the server:

    export BW_SESSION=$(bw unlock --raw)
    node dist/index.js
    
  2. Test with an MCP client or use the inspector to send tool requests.

Debugging

  • Enable debug logging by setting environment variables:

    export DEBUG=bitwarden:*
    export NODE_ENV=development
    
  • Check Bitwarden CLI status:

    bw status
    
  • Verify session token:

    echo $BW_SESSION
    

Security considerations

  • Never commit sensitive credentials (BW_SESSION, BW_CLIENT_ID, BW_CLIENT_SECRET)
  • Use environment variables for all sensitive configuration
  • Validate all inputs using Zod schemas (already implemented)
  • Test with non-production data when possible
  • Monitor API usage through your organization's audit logs
  • Use HTTPS for all API communications (default)
  • Understand the security and privacy impacts of exposing sensitive vault data to LLM and AI tools. Using a self-hosted or local LLM may be appropriate, for example.

Troubleshooting

Common issues

  1. "Please set the BW_SESSION environment variable"

    • Run: export BW_SESSION=$(bw unlock --raw)
  2. "BW_CLIENT_ID and BW_CLIENT_SECRET environment variables are required"

    • Set your API credentials: export BW_CLIENT_ID="your_id" and export BW_CLIENT_SECRET="your_secret"
    • Verify credentials are valid in your Bitwarden organization settings
  3. API authentication failures

    • Check that your organization has API access enabled
    • Verify client credentials have appropriate permissions
    • Ensure you're using the correct API URLs for your instance
  4. Tests failing with environment errors

    • Use the environment mocking helpers in tests
    • Ensure test cleanup with restoreEnvVars()
  5. Inspector not starting

    • Check that the server builds successfully: npm run build
    • Verify Node.js version is 22
  6. CLI commands failing

    • Verify Bitwarden CLI is installed: bw --version
    • Check vault is unlocked: bw status
    • Ensure valid session token: echo $BW_SESSION