@icoretech/warden-mcp 0.1.20 → 0.2.0
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 +24 -23
- package/bin/patch-bitwarden-cli-lib.js +117 -0
- package/bin/patch-bitwarden-cli.js +3 -27
- package/dist/tools/registerTools.js +60 -51
- package/dist/transports/http.js +2 -0
- package/dist/transports/stdio.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ That lets the agent do end-to-end authenticated workflows such as:
|
|
|
30
30
|
- open a site or backoffice in the browser
|
|
31
31
|
- read the right login from Vaultwarden or Bitwarden
|
|
32
32
|
- fill username and password without hardcoding secrets in prompts or config
|
|
33
|
-
- retrieve a current TOTP code with `
|
|
33
|
+
- retrieve a current TOTP code with `keychain_get_totp` for TOTP-based MFA
|
|
34
34
|
- continue the real task after login, such as navigation, data entry, exports, or routine admin work
|
|
35
35
|
|
|
36
36
|
In practice, this is what makes the server useful for full automation, not just secret lookup. The same MCP session that gives the model browser control can also give it scoped access to the credentials and MFA material needed to finish the workflow.
|
|
@@ -385,6 +385,7 @@ Mutation control:
|
|
|
385
385
|
|
|
386
386
|
- Set `READONLY=true` to block all write operations (create/edit/delete/move/restore/attachments).
|
|
387
387
|
- Set `NOREVEAL=true` to force all `reveal` parameters to `false` server-side. Clients can still request `reveal: true`, but the server will silently downgrade to redacted output. This prevents prompt injection from tricking an LLM agent into exfiltrating secrets.
|
|
388
|
+
- Tool names default to `keychain_*`. Override `TOOL_PREFIX` to change the namespace and `TOOL_SEPARATOR` to change the separator (default `_`, set `.` for legacy clients).
|
|
388
389
|
- Session guardrails:
|
|
389
390
|
- `KEYCHAIN_SESSION_MAX_COUNT` (default `32`)
|
|
390
391
|
- `KEYCHAIN_SESSION_TTL_MS` (default `900000`)
|
|
@@ -482,49 +483,49 @@ npm run dev
|
|
|
482
483
|
|
|
483
484
|
Vault/session:
|
|
484
485
|
|
|
485
|
-
- `
|
|
486
|
-
- `
|
|
487
|
-
- `
|
|
486
|
+
- `keychain_status`
|
|
487
|
+
- `keychain_encode` (base64-encode a string via `bw encode`)
|
|
488
|
+
- `keychain_generate` (returns a generated secret only when `reveal: true`)
|
|
488
489
|
|
|
489
490
|
Items:
|
|
490
491
|
|
|
491
|
-
- `
|
|
492
|
-
- `
|
|
493
|
-
- `
|
|
492
|
+
- `keychain_search_items`, `keychain_get_item`, `keychain_update_item`
|
|
493
|
+
- `keychain_create_login`, `keychain_create_note`, `keychain_create_card`, `keychain_create_identity`, `keychain_create_ssh_key`
|
|
494
|
+
- `keychain_delete_item`, `keychain_restore_item`
|
|
494
495
|
|
|
495
496
|
Folders:
|
|
496
497
|
|
|
497
|
-
- `
|
|
498
|
+
- `keychain_list_folders`, `keychain_create_folder`, `keychain_edit_folder`, `keychain_delete_folder`
|
|
498
499
|
|
|
499
500
|
Orgs/collections:
|
|
500
501
|
|
|
501
|
-
- `
|
|
502
|
-
- `
|
|
503
|
-
- `
|
|
502
|
+
- `keychain_list_organizations`, `keychain_list_collections`
|
|
503
|
+
- `keychain_list_org_collections`, `keychain_create_org_collection`, `keychain_edit_org_collection`, `keychain_delete_org_collection`
|
|
504
|
+
- `keychain_move_item_to_organization`
|
|
504
505
|
|
|
505
506
|
Attachments:
|
|
506
507
|
|
|
507
|
-
- `
|
|
508
|
+
- `keychain_create_attachment`, `keychain_delete_attachment`, `keychain_get_attachment`
|
|
508
509
|
|
|
509
510
|
Sends:
|
|
510
511
|
|
|
511
|
-
- `
|
|
512
|
-
- `
|
|
513
|
-
- `
|
|
514
|
-
- `
|
|
515
|
-
- `
|
|
512
|
+
- `keychain_send_list`, `keychain_send_template`, `keychain_send_get`
|
|
513
|
+
- `keychain_send_create` (quick create via `bw send`)
|
|
514
|
+
- `keychain_send_create_encoded`, `keychain_send_edit` (advanced create/edit via `bw send create|edit`)
|
|
515
|
+
- `keychain_send_remove_password`, `keychain_send_delete`
|
|
516
|
+
- `keychain_receive`
|
|
516
517
|
|
|
517
518
|
Direct “bw get …” helpers:
|
|
518
519
|
|
|
519
|
-
- `
|
|
520
|
-
- `
|
|
521
|
-
- `
|
|
522
|
-
- `
|
|
523
|
-
- `
|
|
520
|
+
- `keychain_get_username` (returns `{ kind:"username", value, revealed:true }`)
|
|
521
|
+
- `keychain_get_password` / `keychain_get_totp` / `keychain_get_notes` (only return real values when `reveal: true`)
|
|
522
|
+
- `keychain_get_uri`, `keychain_get_exposed`
|
|
523
|
+
- `keychain_get_folder`, `keychain_get_collection`, `keychain_get_organization`, `keychain_get_org_collection`
|
|
524
|
+
- `keychain_get_password_history` (only returns historic passwords when `reveal: true`)
|
|
524
525
|
|
|
525
526
|
## Known Limitations
|
|
526
527
|
|
|
527
|
-
- `bw list items --search` (and thus `
|
|
528
|
+
- `bw list items --search` (and thus `keychain_search_items`) does not reliably search inside **custom field values**.
|
|
528
529
|
- SSH keys are stored as secure notes in v1 (until `bw` supports native SSH key item creation).
|
|
529
530
|
- High-risk CLI features are intentionally not exposed yet (export/import).
|
|
530
531
|
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { dirname, isAbsolute, relative, resolve } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const defaultPackageDir = resolve(__dirname, '..');
|
|
10
|
+
|
|
11
|
+
function isModuleNotFoundFor(specifier, error) {
|
|
12
|
+
if (!(error instanceof Error)) return false;
|
|
13
|
+
if ('code' in error && error.code !== 'MODULE_NOT_FOUND') return false;
|
|
14
|
+
return error.message.includes(specifier);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function findInstallRoot(packageJsonPath) {
|
|
18
|
+
let currentDir = dirname(packageJsonPath);
|
|
19
|
+
|
|
20
|
+
while (true) {
|
|
21
|
+
const parentDir = dirname(currentDir);
|
|
22
|
+
if (parentDir === currentDir) break;
|
|
23
|
+
if (
|
|
24
|
+
currentDir.endsWith('/node_modules') ||
|
|
25
|
+
currentDir.endsWith('\\node_modules')
|
|
26
|
+
) {
|
|
27
|
+
return parentDir;
|
|
28
|
+
}
|
|
29
|
+
currentDir = parentDir;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
throw new Error(
|
|
33
|
+
`[warden-mcp] could not determine install root from ${packageJsonPath}`,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function resolvePatchPackagePlan({
|
|
38
|
+
packageDir = defaultPackageDir,
|
|
39
|
+
resolveDependency = (specifier) => require.resolve(specifier),
|
|
40
|
+
exists = existsSync,
|
|
41
|
+
} = {}) {
|
|
42
|
+
const patchesDir = resolve(packageDir, 'patches');
|
|
43
|
+
if (!exists(patchesDir)) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
`[warden-mcp] patches directory not found at ${patchesDir}`,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let cliPackageJsonPath;
|
|
50
|
+
try {
|
|
51
|
+
cliPackageJsonPath = resolveDependency('@bitwarden/cli/package.json');
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (isModuleNotFoundFor('@bitwarden/cli/package.json', error)) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const installRoot = findInstallRoot(cliPackageJsonPath);
|
|
60
|
+
const patchDir = relative(installRoot, patchesDir) || '.';
|
|
61
|
+
if (isAbsolute(patchDir) || patchDir.startsWith('..')) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
`[warden-mcp] patch directory ${patchesDir} is outside install root ${installRoot}`,
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
cwd: installRoot,
|
|
69
|
+
args: [
|
|
70
|
+
resolveDependency('patch-package/dist/index.js'),
|
|
71
|
+
'--patch-dir',
|
|
72
|
+
patchDir,
|
|
73
|
+
'--error-on-fail',
|
|
74
|
+
],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function applyBundledBwPatch({
|
|
79
|
+
packageDir = defaultPackageDir,
|
|
80
|
+
resolveDependency,
|
|
81
|
+
exists,
|
|
82
|
+
spawn = spawnSync,
|
|
83
|
+
nodeExecPath = process.execPath,
|
|
84
|
+
logError = (message) => console.error(message),
|
|
85
|
+
} = {}) {
|
|
86
|
+
let plan;
|
|
87
|
+
try {
|
|
88
|
+
plan = resolvePatchPackagePlan({ packageDir, resolveDependency, exists });
|
|
89
|
+
} catch (error) {
|
|
90
|
+
const message =
|
|
91
|
+
error instanceof Error
|
|
92
|
+
? error.message
|
|
93
|
+
: '[warden-mcp] failed to prepare patch-package';
|
|
94
|
+
logError(message);
|
|
95
|
+
return 1;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (!plan) return 0;
|
|
99
|
+
|
|
100
|
+
const result = spawn(nodeExecPath, plan.args, {
|
|
101
|
+
cwd: plan.cwd,
|
|
102
|
+
stdio: 'inherit',
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
if (result.error) {
|
|
106
|
+
logError(
|
|
107
|
+
`[warden-mcp] failed to execute patch-package: ${result.error.message}`,
|
|
108
|
+
);
|
|
109
|
+
return 1;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return result.status ?? 1;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function isDirectRun(importMetaUrl, argv = process.argv) {
|
|
116
|
+
return argv[1] === fileURLToPath(importMetaUrl);
|
|
117
|
+
}
|
|
@@ -1,31 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { existsSync } from 'node:fs';
|
|
5
|
-
import { createRequire } from 'node:module';
|
|
6
|
-
import { dirname, resolve } from 'node:path';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { applyBundledBwPatch, isDirectRun } from './patch-bitwarden-cli-lib.js';
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const rootDir = resolve(__dirname, '..');
|
|
12
|
-
const cliPackageDir = resolve(__dirname, '../node_modules/@bitwarden/cli');
|
|
13
|
-
|
|
14
|
-
if (!existsSync(cliPackageDir)) {
|
|
15
|
-
process.exit(0);
|
|
5
|
+
if (isDirectRun(import.meta.url)) {
|
|
6
|
+
process.exit(applyBundledBwPatch());
|
|
16
7
|
}
|
|
17
|
-
|
|
18
|
-
const patchPackageEntrypoint = require.resolve('patch-package/dist/index.js');
|
|
19
|
-
const result = spawnSync(process.execPath, [patchPackageEntrypoint], {
|
|
20
|
-
cwd: rootDir,
|
|
21
|
-
stdio: 'inherit',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
if (result.error) {
|
|
25
|
-
console.error(
|
|
26
|
-
`[warden-mcp] failed to execute patch-package: ${result.error.message}`,
|
|
27
|
-
);
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
process.exit(result.status ?? 1);
|
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
export function registerTools(server, deps) {
|
|
4
4
|
const toolMeta = {};
|
|
5
|
+
const rawRegisterTool = server.registerTool.bind(server);
|
|
6
|
+
const legacyPrefix = `${deps.toolPrefix}.`;
|
|
7
|
+
const publicPrefix = `${deps.toolPrefix}${deps.toolSeparator}`;
|
|
8
|
+
const registerTool = ((name, ...args) => {
|
|
9
|
+
const publicName = name.startsWith(legacyPrefix)
|
|
10
|
+
? `${publicPrefix}${name.slice(legacyPrefix.length)}`
|
|
11
|
+
: name;
|
|
12
|
+
return rawRegisterTool(publicName, ...args);
|
|
13
|
+
});
|
|
5
14
|
function parseBoolEnv(...names) {
|
|
6
15
|
for (const name of names) {
|
|
7
16
|
const v = process.env[name];
|
|
@@ -82,7 +91,7 @@ export function registerTools(server, deps) {
|
|
|
82
91
|
match: normalizeUriMatchInput(u.match),
|
|
83
92
|
}));
|
|
84
93
|
}
|
|
85
|
-
|
|
94
|
+
registerTool(`${deps.toolPrefix}.status`, {
|
|
86
95
|
title: 'Vault Status',
|
|
87
96
|
description: 'Returns Bitwarden CLI status (locked/unlocked, server, user).',
|
|
88
97
|
annotations: { readOnlyHint: true },
|
|
@@ -101,7 +110,7 @@ export function registerTools(server, deps) {
|
|
|
101
110
|
content: [{ type: 'text', text: summary }],
|
|
102
111
|
};
|
|
103
112
|
});
|
|
104
|
-
|
|
113
|
+
registerTool(`${deps.toolPrefix}.encode`, {
|
|
105
114
|
title: 'Encode',
|
|
106
115
|
description: 'Base64-encode a string (bw encode).',
|
|
107
116
|
annotations: { readOnlyHint: true },
|
|
@@ -117,7 +126,7 @@ export function registerTools(server, deps) {
|
|
|
117
126
|
content: [{ type: 'text', text: 'OK' }],
|
|
118
127
|
};
|
|
119
128
|
});
|
|
120
|
-
|
|
129
|
+
registerTool(`${deps.toolPrefix}.generate`, {
|
|
121
130
|
title: 'Generate',
|
|
122
131
|
description: 'Generate a password/passphrase (bw generate). Returning the value requires reveal=true.',
|
|
123
132
|
annotations: { readOnlyHint: true },
|
|
@@ -146,7 +155,7 @@ export function registerTools(server, deps) {
|
|
|
146
155
|
content: [{ type: 'text', text: 'OK' }],
|
|
147
156
|
};
|
|
148
157
|
});
|
|
149
|
-
|
|
158
|
+
registerTool(`${deps.toolPrefix}.generate_username`, {
|
|
150
159
|
title: 'Generate Username',
|
|
151
160
|
description: 'Generate a username like the Bitwarden generator (random word, plus-addressed email, catch-all). Returning the value requires reveal=true.',
|
|
152
161
|
annotations: { readOnlyHint: true },
|
|
@@ -174,7 +183,7 @@ export function registerTools(server, deps) {
|
|
|
174
183
|
content: [{ type: 'text', text: 'OK' }],
|
|
175
184
|
};
|
|
176
185
|
});
|
|
177
|
-
|
|
186
|
+
registerTool(`${deps.toolPrefix}.list_folders`, {
|
|
178
187
|
title: 'List Folders',
|
|
179
188
|
description: 'List Bitwarden folders (personal).',
|
|
180
189
|
annotations: { readOnlyHint: true },
|
|
@@ -197,7 +206,7 @@ export function registerTools(server, deps) {
|
|
|
197
206
|
content: [{ type: 'text', text: `Found ${results.length} folder(s).` }],
|
|
198
207
|
};
|
|
199
208
|
});
|
|
200
|
-
|
|
209
|
+
registerTool(`${deps.toolPrefix}.create_folder`, {
|
|
201
210
|
title: 'Create Folder',
|
|
202
211
|
description: 'Create a Bitwarden folder (personal).',
|
|
203
212
|
inputSchema: {
|
|
@@ -214,7 +223,7 @@ export function registerTools(server, deps) {
|
|
|
214
223
|
content: [{ type: 'text', text: 'Created.' }],
|
|
215
224
|
};
|
|
216
225
|
});
|
|
217
|
-
|
|
226
|
+
registerTool(`${deps.toolPrefix}.edit_folder`, {
|
|
218
227
|
title: 'Edit Folder',
|
|
219
228
|
description: 'Rename a Bitwarden folder (personal).',
|
|
220
229
|
inputSchema: {
|
|
@@ -232,7 +241,7 @@ export function registerTools(server, deps) {
|
|
|
232
241
|
content: [{ type: 'text', text: 'Updated.' }],
|
|
233
242
|
};
|
|
234
243
|
});
|
|
235
|
-
|
|
244
|
+
registerTool(`${deps.toolPrefix}.delete_folder`, {
|
|
236
245
|
title: 'Delete Folder',
|
|
237
246
|
description: 'Delete a Bitwarden folder (personal).',
|
|
238
247
|
inputSchema: {
|
|
@@ -249,7 +258,7 @@ export function registerTools(server, deps) {
|
|
|
249
258
|
content: [{ type: 'text', text: 'Deleted.' }],
|
|
250
259
|
};
|
|
251
260
|
});
|
|
252
|
-
|
|
261
|
+
registerTool(`${deps.toolPrefix}.list_org_collections`, {
|
|
253
262
|
title: 'List Org Collections',
|
|
254
263
|
description: 'List organization collections.',
|
|
255
264
|
annotations: { readOnlyHint: true },
|
|
@@ -279,7 +288,7 @@ export function registerTools(server, deps) {
|
|
|
279
288
|
],
|
|
280
289
|
};
|
|
281
290
|
});
|
|
282
|
-
|
|
291
|
+
registerTool(`${deps.toolPrefix}.create_org_collection`, {
|
|
283
292
|
title: 'Create Org Collection',
|
|
284
293
|
description: 'Create an organization collection.',
|
|
285
294
|
inputSchema: {
|
|
@@ -297,7 +306,7 @@ export function registerTools(server, deps) {
|
|
|
297
306
|
content: [{ type: 'text', text: 'Created.' }],
|
|
298
307
|
};
|
|
299
308
|
});
|
|
300
|
-
|
|
309
|
+
registerTool(`${deps.toolPrefix}.edit_org_collection`, {
|
|
301
310
|
title: 'Edit Org Collection',
|
|
302
311
|
description: 'Rename an organization collection.',
|
|
303
312
|
inputSchema: {
|
|
@@ -316,7 +325,7 @@ export function registerTools(server, deps) {
|
|
|
316
325
|
content: [{ type: 'text', text: 'Updated.' }],
|
|
317
326
|
};
|
|
318
327
|
});
|
|
319
|
-
|
|
328
|
+
registerTool(`${deps.toolPrefix}.delete_org_collection`, {
|
|
320
329
|
title: 'Delete Org Collection',
|
|
321
330
|
description: 'Delete an organization collection.',
|
|
322
331
|
inputSchema: {
|
|
@@ -334,7 +343,7 @@ export function registerTools(server, deps) {
|
|
|
334
343
|
content: [{ type: 'text', text: 'Deleted.' }],
|
|
335
344
|
};
|
|
336
345
|
});
|
|
337
|
-
|
|
346
|
+
registerTool(`${deps.toolPrefix}.move_item_to_organization`, {
|
|
338
347
|
title: 'Move Item To Organization',
|
|
339
348
|
description: 'Move an item to an organization (optionally assigning collection ids).',
|
|
340
349
|
inputSchema: {
|
|
@@ -353,7 +362,7 @@ export function registerTools(server, deps) {
|
|
|
353
362
|
content: [{ type: 'text', text: 'Moved.' }],
|
|
354
363
|
};
|
|
355
364
|
});
|
|
356
|
-
|
|
365
|
+
registerTool(`${deps.toolPrefix}.list_organizations`, {
|
|
357
366
|
title: 'List Organizations',
|
|
358
367
|
description: 'List organizations available to the current Bitwarden user.',
|
|
359
368
|
annotations: { readOnlyHint: true },
|
|
@@ -376,7 +385,7 @@ export function registerTools(server, deps) {
|
|
|
376
385
|
content: [{ type: 'text', text: `Found ${results.length} org(s).` }],
|
|
377
386
|
};
|
|
378
387
|
});
|
|
379
|
-
|
|
388
|
+
registerTool(`${deps.toolPrefix}.list_collections`, {
|
|
380
389
|
title: 'List Collections',
|
|
381
390
|
description: 'List collections (optionally filtered by organization).',
|
|
382
391
|
annotations: { readOnlyHint: true },
|
|
@@ -406,7 +415,7 @@ export function registerTools(server, deps) {
|
|
|
406
415
|
],
|
|
407
416
|
};
|
|
408
417
|
});
|
|
409
|
-
|
|
418
|
+
registerTool(`${deps.toolPrefix}.search_items`, {
|
|
410
419
|
title: 'Search Items',
|
|
411
420
|
description: 'Search vault items by text and filters (org/folder/collection/url).',
|
|
412
421
|
annotations: { readOnlyHint: true },
|
|
@@ -436,7 +445,7 @@ export function registerTools(server, deps) {
|
|
|
436
445
|
content: [{ type: 'text', text: `Found ${minimal.length} item(s).` }],
|
|
437
446
|
};
|
|
438
447
|
});
|
|
439
|
-
|
|
448
|
+
registerTool(`${deps.toolPrefix}.get_item`, {
|
|
440
449
|
title: 'Get Item',
|
|
441
450
|
description: 'Get a vault item by id.',
|
|
442
451
|
annotations: { readOnlyHint: true },
|
|
@@ -455,7 +464,7 @@ export function registerTools(server, deps) {
|
|
|
455
464
|
content: [{ type: 'text', text: 'OK' }],
|
|
456
465
|
};
|
|
457
466
|
});
|
|
458
|
-
|
|
467
|
+
registerTool(`${deps.toolPrefix}.get_uri`, {
|
|
459
468
|
title: 'Get URI',
|
|
460
469
|
description: 'Get a login URI by search term (bw get uri).',
|
|
461
470
|
annotations: { readOnlyHint: true },
|
|
@@ -471,7 +480,7 @@ export function registerTools(server, deps) {
|
|
|
471
480
|
content: [{ type: 'text', text: 'OK' }],
|
|
472
481
|
};
|
|
473
482
|
});
|
|
474
|
-
|
|
483
|
+
registerTool(`${deps.toolPrefix}.get_notes`, {
|
|
475
484
|
title: 'Get Notes',
|
|
476
485
|
description: 'Get item notes by search term (bw get notes).',
|
|
477
486
|
annotations: { readOnlyHint: true },
|
|
@@ -488,7 +497,7 @@ export function registerTools(server, deps) {
|
|
|
488
497
|
content: [{ type: 'text', text: 'OK' }],
|
|
489
498
|
};
|
|
490
499
|
});
|
|
491
|
-
|
|
500
|
+
registerTool(`${deps.toolPrefix}.get_exposed`, {
|
|
492
501
|
title: 'Get Exposed',
|
|
493
502
|
description: 'Check exposed status by search term (bw get exposed).',
|
|
494
503
|
annotations: { readOnlyHint: true },
|
|
@@ -504,7 +513,7 @@ export function registerTools(server, deps) {
|
|
|
504
513
|
content: [{ type: 'text', text: 'OK' }],
|
|
505
514
|
};
|
|
506
515
|
});
|
|
507
|
-
|
|
516
|
+
registerTool(`${deps.toolPrefix}.get_folder`, {
|
|
508
517
|
title: 'Get Folder',
|
|
509
518
|
description: 'Get a folder by id (bw get folder).',
|
|
510
519
|
annotations: { readOnlyHint: true },
|
|
@@ -520,7 +529,7 @@ export function registerTools(server, deps) {
|
|
|
520
529
|
content: [{ type: 'text', text: 'OK' }],
|
|
521
530
|
};
|
|
522
531
|
});
|
|
523
|
-
|
|
532
|
+
registerTool(`${deps.toolPrefix}.get_collection`, {
|
|
524
533
|
title: 'Get Collection',
|
|
525
534
|
description: 'Get a collection by id (bw get collection).',
|
|
526
535
|
annotations: { readOnlyHint: true },
|
|
@@ -537,7 +546,7 @@ export function registerTools(server, deps) {
|
|
|
537
546
|
content: [{ type: 'text', text: 'OK' }],
|
|
538
547
|
};
|
|
539
548
|
});
|
|
540
|
-
|
|
549
|
+
registerTool(`${deps.toolPrefix}.get_organization`, {
|
|
541
550
|
title: 'Get Organization',
|
|
542
551
|
description: 'Get an organization by id (bw get organization).',
|
|
543
552
|
annotations: { readOnlyHint: true },
|
|
@@ -553,7 +562,7 @@ export function registerTools(server, deps) {
|
|
|
553
562
|
content: [{ type: 'text', text: 'OK' }],
|
|
554
563
|
};
|
|
555
564
|
});
|
|
556
|
-
|
|
565
|
+
registerTool(`${deps.toolPrefix}.get_org_collection`, {
|
|
557
566
|
title: 'Get Org Collection',
|
|
558
567
|
description: 'Get an org collection by id (bw get org-collection).',
|
|
559
568
|
annotations: { readOnlyHint: true },
|
|
@@ -570,7 +579,7 @@ export function registerTools(server, deps) {
|
|
|
570
579
|
content: [{ type: 'text', text: 'OK' }],
|
|
571
580
|
};
|
|
572
581
|
});
|
|
573
|
-
|
|
582
|
+
registerTool(`${deps.toolPrefix}.delete_item`, {
|
|
574
583
|
title: 'Delete Item',
|
|
575
584
|
description: 'Delete an item by id (soft-delete by default; set permanent=true to hard delete).',
|
|
576
585
|
inputSchema: {
|
|
@@ -588,7 +597,7 @@ export function registerTools(server, deps) {
|
|
|
588
597
|
content: [{ type: 'text', text: 'Deleted.' }],
|
|
589
598
|
};
|
|
590
599
|
});
|
|
591
|
-
|
|
600
|
+
registerTool(`${deps.toolPrefix}.delete_items`, {
|
|
592
601
|
title: 'Delete Items',
|
|
593
602
|
description: 'Delete multiple items by id. Returns per-id results (soft-delete by default; set permanent=true to hard delete).',
|
|
594
603
|
inputSchema: {
|
|
@@ -609,7 +618,7 @@ export function registerTools(server, deps) {
|
|
|
609
618
|
],
|
|
610
619
|
};
|
|
611
620
|
});
|
|
612
|
-
|
|
621
|
+
registerTool(`${deps.toolPrefix}.restore_item`, {
|
|
613
622
|
title: 'Restore Item',
|
|
614
623
|
description: 'Restore an item from trash by id.',
|
|
615
624
|
inputSchema: {
|
|
@@ -626,7 +635,7 @@ export function registerTools(server, deps) {
|
|
|
626
635
|
content: [{ type: 'text', text: 'Restored.' }],
|
|
627
636
|
};
|
|
628
637
|
});
|
|
629
|
-
|
|
638
|
+
registerTool(`${deps.toolPrefix}.create_attachment`, {
|
|
630
639
|
title: 'Create Attachment',
|
|
631
640
|
description: 'Attach a file (base64) to an existing item. Returns the updated (redacted) item.',
|
|
632
641
|
inputSchema: {
|
|
@@ -646,7 +655,7 @@ export function registerTools(server, deps) {
|
|
|
646
655
|
content: [{ type: 'text', text: 'Attached.' }],
|
|
647
656
|
};
|
|
648
657
|
});
|
|
649
|
-
|
|
658
|
+
registerTool(`${deps.toolPrefix}.delete_attachment`, {
|
|
650
659
|
title: 'Delete Attachment',
|
|
651
660
|
description: 'Delete an attachment from an item. Returns the updated (redacted) item.',
|
|
652
661
|
inputSchema: {
|
|
@@ -665,7 +674,7 @@ export function registerTools(server, deps) {
|
|
|
665
674
|
content: [{ type: 'text', text: 'Deleted.' }],
|
|
666
675
|
};
|
|
667
676
|
});
|
|
668
|
-
|
|
677
|
+
registerTool(`${deps.toolPrefix}.get_attachment`, {
|
|
669
678
|
title: 'Get Attachment',
|
|
670
679
|
description: 'Download an attachment from an item and return it as base64 (bw get attachment).',
|
|
671
680
|
annotations: { readOnlyHint: true },
|
|
@@ -682,7 +691,7 @@ export function registerTools(server, deps) {
|
|
|
682
691
|
content: [{ type: 'text', text: 'OK' }],
|
|
683
692
|
};
|
|
684
693
|
});
|
|
685
|
-
|
|
694
|
+
registerTool(`${deps.toolPrefix}.send_list`, {
|
|
686
695
|
title: 'Send List',
|
|
687
696
|
description: 'List all the Sends owned by you (bw send list).',
|
|
688
697
|
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
@@ -696,7 +705,7 @@ export function registerTools(server, deps) {
|
|
|
696
705
|
content: [{ type: 'text', text: 'OK' }],
|
|
697
706
|
};
|
|
698
707
|
});
|
|
699
|
-
|
|
708
|
+
registerTool(`${deps.toolPrefix}.send_template`, {
|
|
700
709
|
title: 'Send Template',
|
|
701
710
|
description: 'Get json templates for send objects (bw send template).',
|
|
702
711
|
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
@@ -712,7 +721,7 @@ export function registerTools(server, deps) {
|
|
|
712
721
|
content: [{ type: 'text', text: 'OK' }],
|
|
713
722
|
};
|
|
714
723
|
});
|
|
715
|
-
|
|
724
|
+
registerTool(`${deps.toolPrefix}.send_get`, {
|
|
716
725
|
title: 'Send Get',
|
|
717
726
|
description: 'Get Sends owned by you. Use text=true to return text content; downloadFile=true to download a file send (bw send get).',
|
|
718
727
|
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
@@ -730,7 +739,7 @@ export function registerTools(server, deps) {
|
|
|
730
739
|
content: [{ type: 'text', text: 'OK' }],
|
|
731
740
|
};
|
|
732
741
|
});
|
|
733
|
-
|
|
742
|
+
registerTool(`${deps.toolPrefix}.send_create`, {
|
|
734
743
|
title: 'Send Create',
|
|
735
744
|
description: 'Create a Bitwarden Send. For file sends, pass filename+contentBase64. (bw send).',
|
|
736
745
|
annotations: {
|
|
@@ -762,7 +771,7 @@ export function registerTools(server, deps) {
|
|
|
762
771
|
content: [{ type: 'text', text: 'OK' }],
|
|
763
772
|
};
|
|
764
773
|
});
|
|
765
|
-
|
|
774
|
+
registerTool(`${deps.toolPrefix}.send_create_encoded`, {
|
|
766
775
|
title: 'Send Create (Encoded JSON)',
|
|
767
776
|
description: 'Create a Send via `bw send create`. Provide `encodedJson` (base64) or `json` (will be bw-encoded). Optional: `text`, `hidden`, or `file` (filename+contentBase64).',
|
|
768
777
|
annotations: {
|
|
@@ -793,7 +802,7 @@ export function registerTools(server, deps) {
|
|
|
793
802
|
content: [{ type: 'text', text: 'OK' }],
|
|
794
803
|
};
|
|
795
804
|
});
|
|
796
|
-
|
|
805
|
+
registerTool(`${deps.toolPrefix}.send_edit`, {
|
|
797
806
|
title: 'Send Edit (Encoded JSON)',
|
|
798
807
|
description: 'Edit a Send via `bw send edit`. Provide `encodedJson` (base64) or `json` (will be bw-encoded). Optional: `itemId` (maps to --itemid).',
|
|
799
808
|
annotations: {
|
|
@@ -817,7 +826,7 @@ export function registerTools(server, deps) {
|
|
|
817
826
|
content: [{ type: 'text', text: 'OK' }],
|
|
818
827
|
};
|
|
819
828
|
});
|
|
820
|
-
|
|
829
|
+
registerTool(`${deps.toolPrefix}.send_remove_password`, {
|
|
821
830
|
title: 'Send Remove Password',
|
|
822
831
|
description: "Remove a Send's saved password (bw send remove-password).",
|
|
823
832
|
annotations: {
|
|
@@ -839,7 +848,7 @@ export function registerTools(server, deps) {
|
|
|
839
848
|
content: [{ type: 'text', text: 'OK' }],
|
|
840
849
|
};
|
|
841
850
|
});
|
|
842
|
-
|
|
851
|
+
registerTool(`${deps.toolPrefix}.send_delete`, {
|
|
843
852
|
title: 'Send Delete',
|
|
844
853
|
description: 'Delete a Send (bw send delete).',
|
|
845
854
|
annotations: {
|
|
@@ -861,7 +870,7 @@ export function registerTools(server, deps) {
|
|
|
861
870
|
content: [{ type: 'text', text: 'OK' }],
|
|
862
871
|
};
|
|
863
872
|
});
|
|
864
|
-
|
|
873
|
+
registerTool(`${deps.toolPrefix}.receive`, {
|
|
865
874
|
title: 'Receive',
|
|
866
875
|
description: 'Access a Bitwarden Send from a url. Use obj=true for JSON object; downloadFile=true for file content. (bw receive)',
|
|
867
876
|
annotations: { readOnlyHint: true, openWorldHint: true },
|
|
@@ -880,7 +889,7 @@ export function registerTools(server, deps) {
|
|
|
880
889
|
content: [{ type: 'text', text: 'OK' }],
|
|
881
890
|
};
|
|
882
891
|
});
|
|
883
|
-
|
|
892
|
+
registerTool(`${deps.toolPrefix}.get_username`, {
|
|
884
893
|
title: 'Get Username',
|
|
885
894
|
description: 'Get a login username by search term (bw get username).',
|
|
886
895
|
annotations: { readOnlyHint: true },
|
|
@@ -896,7 +905,7 @@ export function registerTools(server, deps) {
|
|
|
896
905
|
content: [{ type: 'text', text: 'OK' }],
|
|
897
906
|
};
|
|
898
907
|
});
|
|
899
|
-
|
|
908
|
+
registerTool(`${deps.toolPrefix}.get_password`, {
|
|
900
909
|
title: 'Get Password',
|
|
901
910
|
description: 'Get a login password by search term (bw get password). Returning a password requires reveal=true.',
|
|
902
911
|
annotations: { readOnlyHint: true },
|
|
@@ -913,7 +922,7 @@ export function registerTools(server, deps) {
|
|
|
913
922
|
content: [{ type: 'text', text: 'OK' }],
|
|
914
923
|
};
|
|
915
924
|
});
|
|
916
|
-
|
|
925
|
+
registerTool(`${deps.toolPrefix}.get_totp`, {
|
|
917
926
|
title: 'Get TOTP',
|
|
918
927
|
description: 'Get a TOTP code/seed by search term (bw get totp). Returning a TOTP requires reveal=true.',
|
|
919
928
|
annotations: { readOnlyHint: true },
|
|
@@ -933,7 +942,7 @@ export function registerTools(server, deps) {
|
|
|
933
942
|
content: [{ type: 'text', text: 'OK' }],
|
|
934
943
|
};
|
|
935
944
|
});
|
|
936
|
-
|
|
945
|
+
registerTool(`${deps.toolPrefix}.get_password_history`, {
|
|
937
946
|
title: 'Get Password History',
|
|
938
947
|
description: 'Get an item password history (if any). Returning passwords requires reveal=true.',
|
|
939
948
|
annotations: { readOnlyHint: true },
|
|
@@ -952,7 +961,7 @@ export function registerTools(server, deps) {
|
|
|
952
961
|
content: [{ type: 'text', text: 'OK' }],
|
|
953
962
|
};
|
|
954
963
|
});
|
|
955
|
-
|
|
964
|
+
registerTool(`${deps.toolPrefix}.create_login`, {
|
|
956
965
|
title: 'Create Login',
|
|
957
966
|
description: 'Create a login item.',
|
|
958
967
|
inputSchema: {
|
|
@@ -999,7 +1008,7 @@ export function registerTools(server, deps) {
|
|
|
999
1008
|
content: [{ type: 'text', text: 'Created.' }],
|
|
1000
1009
|
};
|
|
1001
1010
|
});
|
|
1002
|
-
|
|
1011
|
+
registerTool(`${deps.toolPrefix}.create_logins`, {
|
|
1003
1012
|
title: 'Create Logins',
|
|
1004
1013
|
description: 'Create multiple login items in a single call.',
|
|
1005
1014
|
inputSchema: {
|
|
@@ -1054,7 +1063,7 @@ export function registerTools(server, deps) {
|
|
|
1054
1063
|
],
|
|
1055
1064
|
};
|
|
1056
1065
|
});
|
|
1057
|
-
|
|
1066
|
+
registerTool(`${deps.toolPrefix}.set_login_uris`, {
|
|
1058
1067
|
title: 'Set Login URIs',
|
|
1059
1068
|
description: 'Set or update the URIs (and per-URI match types) for a login item. mode=replace overwrites; mode=merge updates/adds by uri.',
|
|
1060
1069
|
inputSchema: {
|
|
@@ -1082,7 +1091,7 @@ export function registerTools(server, deps) {
|
|
|
1082
1091
|
content: [{ type: 'text', text: 'Updated.' }],
|
|
1083
1092
|
};
|
|
1084
1093
|
});
|
|
1085
|
-
|
|
1094
|
+
registerTool(`${deps.toolPrefix}.create_note`, {
|
|
1086
1095
|
title: 'Create Note',
|
|
1087
1096
|
description: 'Create a secure note item.',
|
|
1088
1097
|
inputSchema: {
|
|
@@ -1111,7 +1120,7 @@ export function registerTools(server, deps) {
|
|
|
1111
1120
|
content: [{ type: 'text', text: 'Created.' }],
|
|
1112
1121
|
};
|
|
1113
1122
|
});
|
|
1114
|
-
|
|
1123
|
+
registerTool(`${deps.toolPrefix}.create_ssh_key`, {
|
|
1115
1124
|
title: 'Create SSH Key',
|
|
1116
1125
|
description: 'Create an SSH key object (stored as secure note with fields).',
|
|
1117
1126
|
inputSchema: {
|
|
@@ -1137,7 +1146,7 @@ export function registerTools(server, deps) {
|
|
|
1137
1146
|
content: [{ type: 'text', text: 'Created.' }],
|
|
1138
1147
|
};
|
|
1139
1148
|
});
|
|
1140
|
-
|
|
1149
|
+
registerTool(`${deps.toolPrefix}.create_card`, {
|
|
1141
1150
|
title: 'Create Card',
|
|
1142
1151
|
description: 'Create a payment card item.',
|
|
1143
1152
|
inputSchema: {
|
|
@@ -1172,7 +1181,7 @@ export function registerTools(server, deps) {
|
|
|
1172
1181
|
content: [{ type: 'text', text: 'Created.' }],
|
|
1173
1182
|
};
|
|
1174
1183
|
});
|
|
1175
|
-
|
|
1184
|
+
registerTool(`${deps.toolPrefix}.create_identity`, {
|
|
1176
1185
|
title: 'Create Identity',
|
|
1177
1186
|
description: 'Create an identity item.',
|
|
1178
1187
|
inputSchema: {
|
|
@@ -1223,7 +1232,7 @@ export function registerTools(server, deps) {
|
|
|
1223
1232
|
content: [{ type: 'text', text: 'Created.' }],
|
|
1224
1233
|
};
|
|
1225
1234
|
});
|
|
1226
|
-
|
|
1235
|
+
registerTool(`${deps.toolPrefix}.update_item`, {
|
|
1227
1236
|
title: 'Update Item',
|
|
1228
1237
|
description: 'Update selected fields of an item by id.',
|
|
1229
1238
|
inputSchema: {
|
package/dist/transports/http.js
CHANGED
|
@@ -18,6 +18,7 @@ export function createKeychainApp(opts = {}) {
|
|
|
18
18
|
return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback;
|
|
19
19
|
};
|
|
20
20
|
const TOOL_PREFIX = opts.toolPrefix ?? process.env.TOOL_PREFIX ?? 'keychain';
|
|
21
|
+
const TOOL_SEPARATOR = opts.toolSeparator ?? process.env.TOOL_SEPARATOR ?? '_';
|
|
21
22
|
const APP_NAME = opts.appName ?? process.env.MCP_APP_NAME ?? `${TOOL_PREFIX}-mcp`;
|
|
22
23
|
const sessionTtlMs = opts.sessionTtlMs ??
|
|
23
24
|
parsePositiveInt(process.env.KEYCHAIN_SESSION_TTL_MS, 15 * 60 * 1000);
|
|
@@ -55,6 +56,7 @@ export function createKeychainApp(opts = {}) {
|
|
|
55
56
|
throw new Error('Missing Bitwarden config headers. Provide X-BW-Host, X-BW-Password, and either (X-BW-ClientId + X-BW-ClientSecret) or X-BW-User.');
|
|
56
57
|
},
|
|
57
58
|
toolPrefix: TOOL_PREFIX,
|
|
59
|
+
toolSeparator: TOOL_SEPARATOR,
|
|
58
60
|
});
|
|
59
61
|
return server;
|
|
60
62
|
}
|
package/dist/transports/stdio.js
CHANGED
|
@@ -7,6 +7,7 @@ import { KeychainSdk } from '../sdk/keychainSdk.js';
|
|
|
7
7
|
import { registerTools } from '../tools/registerTools.js';
|
|
8
8
|
export async function runStdioTransport() {
|
|
9
9
|
const TOOL_PREFIX = process.env.TOOL_PREFIX ?? 'keychain';
|
|
10
|
+
const TOOL_SEPARATOR = process.env.TOOL_SEPARATOR ?? '_';
|
|
10
11
|
const APP_NAME = process.env.MCP_APP_NAME ?? `${TOOL_PREFIX}-mcp`;
|
|
11
12
|
// Credentials must be present at startup for stdio mode.
|
|
12
13
|
const bwEnv = readBwEnv();
|
|
@@ -21,6 +22,7 @@ export async function runStdioTransport() {
|
|
|
21
22
|
return new KeychainSdk(bw);
|
|
22
23
|
},
|
|
23
24
|
toolPrefix: TOOL_PREFIX,
|
|
25
|
+
toolSeparator: TOOL_SEPARATOR,
|
|
24
26
|
});
|
|
25
27
|
const transport = new StdioServerTransport();
|
|
26
28
|
// Assign onclose BEFORE connect() to avoid a race where stdin is already
|