@bitwarden/mcp-server 2025.10.0 → 2025.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,31 +1,145 @@
1
1
  # Bitwarden MCP Server
2
2
 
3
- Model Context Protocol (MCP) server that enables interaction with the Bitwarden password manager vault via the MCP protocol. The server allows AI models to securely communicate with a user's Bitwarden vault through defined tool interfaces.
3
+ A Model Context Protocol (MCP) server that provides AI assistants with secure access to Bitwarden password manager functionality through two complementary interfaces:
4
+
5
+ - **Vault Management and CLI tools** via Bitwarden CLI
6
+ - **Organization Administration** via Bitwarden Public API
7
+
8
+ [![npm version](https://img.shields.io/npm/v/@bitwarden/mcp-server.svg)](https://www.npmjs.com/package/@bitwarden/mcp-server)
9
+
10
+ > [!WARNING]
11
+ > This MCP server is designed exclusively for local use and must never be hosted publicly or exposed over a network.
12
+ >
13
+ > When you grant an AI assistant access to this server, you are providing the ability to:
14
+ >
15
+ > - Read vault items including passwords, secure notes, and sensitive data
16
+ > - Create, modify, and delete vault items
17
+ > - Access organization secrets and administrative functions
18
+ > - Expose credentials and vault contents through AI responses
19
+ >
20
+ > **You are responsible for:**
21
+ >
22
+ > - Ensuring this server runs only on your local machine or self-hosted environment
23
+ > - Understanding what data you're exposing to your AI assistant
24
+ > - Being aware that AI responses may inadvertently reveal sensitive information
25
+ > - Using appropriate AI providers (consider self-hosted or local LLMs for sensitive data)
26
+ > - Never sharing configuration files containing session tokens or API credentials
27
+ > - Monitoring logs for unexpected activity
28
+ >
29
+ > **Never:**
30
+ >
31
+ > - Deploy this server to cloud hosting, containers, or public servers
32
+ > - Share your MCP configuration files with others
33
+ > - Use this server over untrusted networks
34
+ > - Grant access to untrusted AI clients or services
35
+ >
36
+ > Use this tool responsibly and at your own risk.
37
+
38
+ ## What is MCP?
39
+
40
+ The [Model Context Protocol](https://modelcontextprotocol.io/) is an open standard that enables AI assistants to securely interact with local tools and services. This server exposes Bitwarden's vault management and organization administration capabilities to MCP-compatible AI clients like Claude Desktop.
41
+
42
+ ## Features
43
+
44
+ ### Vault Management and CLI tools (CLI)
45
+
46
+ - **Session Management**: Lock vault, sync with server, check status
47
+ - **Item Operations**: List, retrieve, create, edit, delete, restore vault items
48
+ - Supports logins, secure notes, cards, and identities
49
+ - Advanced filtering by URL, folder, collection, or trash status
50
+ - **Folder Management**: Organize items with folders
51
+ - **Attachments**: Upload, download, and manage file attachments
52
+ - **Password Tools**: Generate secure passwords and retrieve TOTP codes
53
+ - **Bitwarden Send**: Create and manage secure ephemeral shares (text/file)
54
+ - **Organization Items**: Move items to organizations, manage collections
55
+ - **Device Approval**: Approve or deny new device login requests
56
+ - **Member Management**: Confirm organization member registrations
57
+
58
+ ### Organization Administration (API)
59
+
60
+ - **Collections**: Create, update, delete, and manage collection permissions
61
+ - **Members**: Invite, update roles, remove members, manage group assignments
62
+ - **Groups**: Create role-based access groups and assign members
63
+ - **Policies**: Configure and enforce organization security policies
64
+ - **Audit Logs**: Retrieve organization event history
65
+ - **Subscriptions**: View and update organization billing information
66
+ - **Bulk Import**: Import users and groups from external systems
67
+
68
+ ## Quick Start
69
+
70
+ ### Prerequisites
71
+
72
+ **For Vault Management and CLI tools:**
73
+
74
+ - [Bitwarden CLI](https://bitwarden.com/help/cli/) installed (ex. `npm install -g @bitwarden/cli`)
75
+ - Node.js 22+
76
+ - Bitwarden account
77
+
78
+ **For Organization Administration:**
79
+
80
+ - Node.js 22+
81
+ - Bitwarden Teams or Enterprise organization
82
+ - Organization owner or admin permissions
83
+
84
+ ### Configuration
85
+
86
+ > [!WARNING]
87
+ > The configuration files below will contain sensitive credentials that grant access to your Bitwarden vault. Keep these files secure, never commit them to version control, and never share them with others. Ensure your MCP client (e.g., Claude Desktop) is configured to run the server locally only.
88
+
89
+ #### Option 1: Claude Desktop (Recommended)
90
+
91
+ Add to your Claude Desktop configuration file:
92
+
93
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
94
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
4
95
 
5
- ## Prerequisites
6
-
7
- - Node.js 22
8
- - **For CLI operations**: Bitwarden CLI (`bw`) installed, authenticated, and valid session token
9
- - **For API operations**: Bitwarden organization with API access and valid client credentials
96
+ ```json
97
+ {
98
+ "mcpServers": {
99
+ "bitwarden": {
100
+ "command": "npx",
101
+ "args": ["-y", "@bitwarden/mcp-server"],
102
+ "env": {
103
+ "BW_SESSION": "your-session-token-here"
104
+ }
105
+ }
106
+ }
107
+ }
108
+ ```
10
109
 
11
- ## Installation
110
+ **Get your session token:**
12
111
 
13
- ### Option One: Configuration in your AI app
112
+ ```bash
113
+ bw login
114
+ bw unlock --raw
115
+ ```
14
116
 
15
- Open up your application configuration, e.g. for Claude Desktop:
117
+ To enable organization administration features, add API credentials:
16
118
 
17
119
  ```json
18
120
  {
19
121
  "mcpServers": {
20
122
  "bitwarden": {
21
123
  "command": "npx",
22
- "args": ["-y", "@bitwarden/mcp-server"]
124
+ "args": ["-y", "@bitwarden/mcp-server"],
125
+ "env": {
126
+ "BW_SESSION": "your-session-token-here",
127
+ "BW_CLIENT_ID": "organization.your-client-id",
128
+ "BW_CLIENT_SECRET": "your-client-secret"
129
+ }
23
130
  }
24
131
  }
25
132
  }
26
133
  ```
27
134
 
28
- ### Option Two: Local checkout
135
+ **Get organization API credentials:**
136
+
137
+ 1. Go to your Bitwarden Web Vault
138
+ 2. Navigate to your organization → Settings → My Organization
139
+ 3. Scroll to "API Key" section
140
+ 4. Click "View API Key" and authenticate
141
+
142
+ #### Option 2: Locally Built and Referenced
29
143
 
30
144
  Requires that this repository be checked out locally. Once that's done:
31
145
 
@@ -34,195 +148,154 @@ npm install
34
148
  npm run build
35
149
  ```
36
150
 
37
- ## Setup
151
+ Then reference the built `dist/index.js` file from Claude desktop:
38
152
 
39
- The server supports two authentication methods:
40
-
41
- ### Option A: CLI Authentication (for personal vault operations)
153
+ ```json
154
+ {
155
+ "mcpServers": {
156
+ "bitwarden": {
157
+ "command": "node",
158
+ "args": ["local/path/to/mcp-server/dist/index.js"],
159
+ "env": {
160
+ "BW_SESSION": "your-session-token-here"
161
+ }
162
+ }
163
+ }
164
+ }
165
+ ```
42
166
 
43
- 1. **Install Bitwarden CLI**:
167
+ #### Option 3: Other MCP Clients
44
168
 
45
- ```bash
46
- npm install -g @bitwarden/cli
47
- ```
169
+ Any MCP-compatible client can connect to this server via stdio transport. Refer to your client's documentation for configuration details.
48
170
 
49
- 2. **Log in to Bitwarden**:
171
+ ### Environment Variables
50
172
 
51
- ```bash
52
- bw login
53
- ```
173
+ | Variable | Required For | Description | Default |
174
+ | ------------------ | -------------- | ------------------------------------ | -------------------------------- |
175
+ | `BW_SESSION` | CLI operations | Session token from `bw unlock --raw` | - |
176
+ | `BW_CLIENT_ID` | API operations | Organization API client ID | - |
177
+ | `BW_CLIENT_SECRET` | API operations | Organization API client secret | - |
178
+ | `BW_API_BASE_URL` | API operations | Bitwarden API base URL | `https://api.bitwarden.com` |
179
+ | `BW_IDENTITY_URL` | API operations | OAuth2 identity server URL | `https://identity.bitwarden.com` |
54
180
 
55
- 3. **Get session token**:
56
- ```bash
57
- export BW_SESSION=$(bw unlock --raw)
58
- ```
181
+ **Note:** For self-hosted Bitwarden instances, set `BW_API_BASE_URL` and `BW_IDENTITY_URL` to your server URLs.
59
182
 
60
- ### Option B: API Authentication (for organization management)
183
+ ## Usage Examples
61
184
 
62
- 1. **Create API credentials** in your Bitwarden organization settings
185
+ Once configured, you can interact with Bitwarden through your AI assistant:
63
186
 
64
- 2. **Set environment variables**:
187
+ **Vault:**
65
188
 
66
- ```bash
67
- export BW_CLIENT_ID="your_client_id"
68
- export BW_CLIENT_SECRET="your_client_secret"
69
- ```
189
+ - "List all my login items"
190
+ - "Get my credentials for github"
191
+ - "Create a new secure note for my home WiFi information"
192
+ - "Generate a 32-character password and save it for apple.com"
193
+ - "Create a Send link for this file"
70
194
 
71
- 3. **Optional: Set custom API URLs** (if using self-hosted):
72
- ```bash
73
- export BW_API_BASE_URL="https://api.bitwarden.com"
74
- export BW_IDENTITY_URL="https://identity.bitwarden.com"
75
- ```
195
+ **Organization Administration:**
76
196
 
77
- > **Note**: You can use both authentication methods simultaneously for full functionality.
197
+ - "List all members in my organization"
198
+ - "Invite user@example.com as an organization admin"
199
+ - "Create a 'Development Team' collection"
200
+ - "Show me the last 100 audit log events"
201
+ - "What security policies are enabled?"
78
202
 
79
- ## Testing
203
+ ## Available Tools
80
204
 
81
- ### Running unit tests
205
+ ### Vault Management and CLI Tools
82
206
 
83
- The project includes Jest unit tests covering validation, CLI commands, and core functionality.
207
+ - **Session**: `lock`, `sync`, `status`
208
+ - **Retrieval**: `list`, `get`
209
+ - **Items**: `create_item`, `edit_item`, `delete`, `restore`
210
+ - **Folders**: `create_folder`, `edit_folder`
211
+ - **Attachments**: `create_attachment`
212
+ - **Organizations**: `create_org_collection`, `edit_org_collection`, `edit_item_collections`, `move`, `confirm`
213
+ - **Device Approval**: `device_approval_list`, `device_approval_approve`, `device_approval_approve_all`, `device_approval_deny`, `device_approval_deny_all`
214
+ - **Send**: `create_text_send`, `create_file_send`, `list_send`, `get_send`, `edit_send`, `delete_send`, `remove_send_password`
215
+ - **Utilities**: `generate`
84
216
 
85
- ```bash
86
- # Run all tests
87
- npm test
217
+ ### Organization Administration
88
218
 
89
- # Run tests in watch mode
90
- npm run test:watch
219
+ - **Collections**: `list_org_collections`, `get_org_collection`, `update_org_collection`, `delete_org_collection`
220
+ - **Members**: `list_org_members`, `get_org_member`, `invite_org_member`, `update_org_member`, `remove_org_member`, `reinvite_org_member`, `get_org_member_groups`, `update_org_member_groups`
221
+ - **Groups**: `list_org_groups`, `get_org_group`, `create_org_group`, `update_org_group`, `delete_org_group`, `get_org_group_members`, `update_org_group_members`
222
+ - **Policies**: `list_org_policies`, `get_org_policy`, `update_org_policy`
223
+ - **Events**: `get_org_events`
224
+ - **Subscriptions**: `get_org_subscription`, `update_org_subscription`
225
+ - **Import**: `import_org_users_and_groups`
91
226
 
92
- # Run tests with coverage
93
- npm test -- --coverage
227
+ ## Development
94
228
 
95
- # Run specific test file
96
- npm test validation.spec.ts
229
+ ### Setup
97
230
 
98
- # Run tests matching a pattern
99
- npm test -- --testNamePattern="validation"
231
+ ```bash
232
+ git clone https://github.com/bitwarden/mcp-server.git
233
+ cd mcp-server
234
+ npm install
100
235
  ```
101
236
 
102
- ## Inspection and development
103
-
104
- ### MCP Inspector
105
-
106
- Use the MCP Inspector to test the server interactively:
237
+ ### Commands
107
238
 
108
239
  ```bash
109
- # Start the inspector
110
- npm run inspect
240
+ npm run build # Compile TypeScript
241
+ npm test # Run test suite
242
+ npm run lint # Check code style
243
+ npm run lint:fix # Auto-fix linting issues
244
+ npm run inspect # Test with MCP Inspector
111
245
  ```
112
246
 
113
- This will:
114
-
115
- 1. Start the MCP server
116
- 2. Launch the inspector UI in your browser
117
- 3. Allow you to test all available tools interactively
247
+ ### Testing with MCP Inspector
118
248
 
119
- ### Available tools
249
+ The MCP Inspector provides an interactive testing environment:
120
250
 
121
- The server provides comprehensive Bitwarden functionality through two categories of tools:
122
-
123
- #### Personal Vault Tools (CLI Authentication)
124
-
125
- | Tool | Description | Required Parameters |
126
- | ---------- | ---------------------------- | ------------------------------------------------- |
127
- | `lock` | Lock the vault | None |
128
- | `unlock` | Unlock with master password | `password` |
129
- | `sync` | Sync vault data | None |
130
- | `status` | Check CLI status | None |
131
- | `list` | List vault items/folders | `type` (items/folders/collections/organizations) |
132
- | `get` | Get specific item/folder | `object`, `id` |
133
- | `generate` | Generate password/passphrase | Various optional parameters |
134
- | `create` | Create new item or folder | `objectType`, `name`, additional fields for items |
135
- | `edit` | Edit existing item or folder | `objectType`, `id`, optional fields to update |
136
- | `delete` | Delete vault item/folder | `object`, `id`, optional `permanent` |
137
-
138
- #### Organization Management Tools (API Authentication)
139
-
140
- ##### Collections Management
141
-
142
- | Tool | Description | Required Parameters |
143
- | ----------------------- | ----------------------------- | ------------------- |
144
- | `list_org_collections` | List organization collections | None |
145
- | `get_org_collection` | Get collection details | `id` |
146
- | `update_org_collection` | Update existing collection | `id` |
147
- | `delete_org_collection` | Delete collection | `id` |
148
-
149
- ##### Members Management
150
-
151
- | Tool | Description | Required Parameters |
152
- | -------------------------- | --------------------------------- | ------------------- |
153
- | `list_org_members` | List organization members | None |
154
- | `get_org_member` | Get member details | `id` |
155
- | `invite_org_member` | Invite new member | `email`, `type` |
156
- | `update_org_member` | Update existing member | `id` |
157
- | `remove_org_member` | Remove member from organization | `id` |
158
- | `reinvite_org_member` | Re-invite member | `id` |
159
- | `get_org_member_groups` | Get member's group assignments | `id` |
160
- | `update_org_member_groups` | Update member's group assignments | `id`, `groupIds` |
161
-
162
- ##### Groups Management
251
+ ```bash
252
+ npm run build
253
+ npm run inspect
254
+ ```
163
255
 
164
- | Tool | Description | Required Parameters |
165
- | -------------------------- | --------------------------------- | ------------------- |
166
- | `list_org_groups` | List organization groups | None |
167
- | `get_org_group` | Get group details | `id` |
168
- | `create_org_group` | Create new group | `name` |
169
- | `update_org_group` | Update existing group | `id`, `name` |
170
- | `delete_org_group` | Delete group | `id` |
171
- | `get_org_group_members` | Get group's member assignments | `id` |
172
- | `update_org_group_members` | Update group's member assignments | `id`, `memberIds` |
256
+ This opens a web interface where you can:
173
257
 
174
- ##### Policies Management
258
+ - Browse available tools
259
+ - Test tool execution with custom inputs
260
+ - View request/response payloads
261
+ - Debug tool behavior
175
262
 
176
- | Tool | Description | Required Parameters |
177
- | ------------------- | -------------------------- | ------------------- |
178
- | `list_org_policies` | List organization policies | None |
179
- | `get_org_policy` | Get policy details | `type` |
180
- | `update_org_policy` | Update organization policy | `type`, `enabled` |
263
+ ### Best Practices
181
264
 
182
- ##### Organization Management
265
+ - Store credentials securely (use system keychains or environment managers)
266
+ - Rotate session tokens regularly
267
+ - Review audit logs periodically for suspicious activity
268
+ - Never commit credentials to version control
183
269
 
184
- | Tool | Description | Required Parameters |
185
- | ----------------------------- | ---------------------------- | ------------------- |
186
- | `get_org_subscription` | Get subscription details | None |
187
- | `update_org_subscription` | Update subscription settings | None |
188
- | `import_org_users_and_groups` | Import members and groups | None |
270
+ ### Testing
189
271
 
190
- ##### Events and Auditing
272
+ The project includes Jest unit tests covering validation, CLI commands, and core functionality.
191
273
 
192
- | Tool | Description | Required Parameters |
193
- | ---------------- | --------------------------- | ------------------- |
194
- | `get_org_events` | Get organization audit logs | None |
274
+ ```bash
275
+ # Run all tests
276
+ npm test
195
277
 
196
- ### Manual testing
278
+ # Run tests in watch mode
279
+ npm run test:watch
197
280
 
198
- 1. **Start the server**:
281
+ # Run tests with coverage
282
+ npm test -- --coverage
199
283
 
200
- ```bash
201
- export BW_SESSION=$(bw unlock --raw)
202
- node dist/index.js
203
- ```
284
+ # Run specific test file
285
+ npm test validation.spec.ts
204
286
 
205
- 2. **Test with an MCP client** or use the inspector to send tool requests.
287
+ # Run tests matching a pattern
288
+ npm test -- --testNamePattern="validation"
289
+ ```
206
290
 
207
291
  ### Debugging
208
292
 
209
- - **Enable debug logging** by setting environment variables:
210
-
211
- ```bash
212
- export DEBUG=bitwarden:*
213
- export NODE_ENV=development
214
- ```
215
-
216
- - **Check Bitwarden CLI status**:
217
-
218
- ```bash
219
- bw status
220
- ```
293
+ **Enable debug logging** by setting environment variables:
221
294
 
222
- - **Verify session token**:
223
- ```bash
224
- echo $BW_SESSION
225
- ```
295
+ ```bash
296
+ export DEBUG=bitwarden:*
297
+ export NODE_ENV=development
298
+ ```
226
299
 
227
300
  ## Security considerations
228
301
 
@@ -231,34 +304,35 @@ The server provides comprehensive Bitwarden functionality through two categories
231
304
  - **Validate all inputs** using Zod schemas (already implemented)
232
305
  - **Test with non-production data** when possible
233
306
  - **Monitor API usage** through your organization's audit logs
234
- - **Use HTTPS** for all API communications (default)
235
307
  - 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.
236
308
 
237
309
  ## Troubleshooting
238
310
 
239
- ### Common issues
311
+ ### CLI Issues
312
+
313
+ - **Vault is locked**
314
+
315
+ ```bash
316
+ bw unlock --raw
317
+ # Copy the token and update BW_SESSION in your MCP config
318
+ ```
240
319
 
241
- 1. **"Please set the BW_SESSION environment variable"**
242
- - Run: `export BW_SESSION=$(bw unlock --raw)`
320
+ - **Session key is invalid**
321
+ - Session tokens expire after inactivity
322
+ - Run `bw unlock --raw` to get a fresh token
323
+ - Update your MCP configuration with the new token
243
324
 
244
- 2. **"BW_CLIENT_ID and BW_CLIENT_SECRET environment variables are required"**
245
- - Set your API credentials: `export BW_CLIENT_ID="your_id"` and `export BW_CLIENT_SECRET="your_secret"`
246
- - Verify credentials are valid in your Bitwarden organization settings
325
+ ### API Issues
247
326
 
248
- 3. **API authentication failures**
249
- - Check that your organization has API access enabled
250
- - Verify client credentials have appropriate permissions
251
- - Ensure you're using the correct API URLs for your instance
327
+ - **Invalid client credentials**
328
+ - Verify `BW_CLIENT_ID` starts with `organization.`
329
+ - Ensure `BW_CLIENT_SECRET` is correct
330
+ - Check that API keys haven't been rotated in the Admin Console
252
331
 
253
- 4. **Tests failing with environment errors**
254
- - Use the environment mocking helpers in tests
255
- - Ensure test cleanup with `restoreEnvVars()`
332
+ - **403 Forbidden**
333
+ - Verify you have organization owner or admin permissions
334
+ - Some operations require specific roles (e.g., managing members)
256
335
 
257
- 5. **Inspector not starting**
258
- - Check that the server builds successfully: `npm run build`
259
- - Verify Node.js version is 22
336
+ ## Contributing
260
337
 
261
- 6. **CLI commands failing**
262
- - Verify Bitwarden CLI is installed: `bw --version`
263
- - Check vault is unlocked: `bw status`
264
- - Ensure valid session token: `echo $BW_SESSION`
338
+ We welcome contributions! Please see [CONTRIBUTING.md](https://contributing.bitwarden.com/) for guidelines.