@icoretech/warden-mcp 0.2.6 → 0.2.8

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
@@ -430,6 +430,7 @@ Mutation control:
430
430
 
431
431
  - Set `READONLY=true` to block all write operations (create/edit/delete/move/restore/attachments).
432
432
  - 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.
433
+ - Set `KEYCHAIN_TEXT_COMPAT_MODE=structured_json` to mirror any structured `OK` tool result into `TextContent` as serialized JSON. This is useful for text-only MCP clients that ignore `structuredContent`, but it also duplicates revealed secrets into the plain-text transcript.
433
434
  - Tool names default to `keychain_*`. Override `TOOL_PREFIX` to change the namespace and `TOOL_SEPARATOR` to change the separator (default `_`, set `.` for legacy clients).
434
435
  - Session guardrails:
435
436
  - `KEYCHAIN_SESSION_MAX_COUNT` (default `32`)
@@ -439,6 +440,7 @@ Mutation control:
439
440
  - `KEYCHAIN_METRICS_LOG_INTERVAL_MS` (default `0`, disabled)
440
441
  - `NOREVEAL` / `KEYCHAIN_NOREVEAL` (default `false`; force all reveals to false)
441
442
  - `KEYCHAIN_ALLOW_ENV_FALLBACK` (default `false`; HTTP env-var credential fallback)
443
+ - `KEYCHAIN_TEXT_COMPAT_MODE` (default unset; set to `structured_json` to copy structured `OK` results into `TextContent`)
442
444
 
443
445
  Redaction defaults (item reads):
444
446
 
@@ -475,6 +477,8 @@ If you run `warden-mcp` beyond local development, review these items:
475
477
 
476
478
  8. **Monitor `/metricsz`.** The endpoint is intentionally unauthenticated (for scraper compatibility) but exposes session counts, heap usage, and rejection counters. If this data is sensitive in your environment, restrict access at the network level.
477
479
 
480
+ 9. **Only enable `KEYCHAIN_TEXT_COMPAT_MODE=structured_json` for text-only clients you trust.** It improves compatibility with clients that ignore `structuredContent`, but any revealed secret will also appear in plain-text `TextContent`, making transcript leakage easier.
481
+
478
482
  ## Quick Start
479
483
 
480
484
  ### Minimal local run
@@ -35,6 +35,7 @@ export function registerTools(server, deps) {
35
35
  }
36
36
  const isReadOnly = parseBoolEnv('READONLY', 'KEYCHAIN_READONLY');
37
37
  const isNoReveal = parseBoolEnv('NOREVEAL', 'KEYCHAIN_NOREVEAL');
38
+ const textCompatMode = process.env.KEYCHAIN_TEXT_COMPAT_MODE?.trim().toLowerCase();
38
39
  function readonlyBlocked() {
39
40
  return {
40
41
  structuredContent: { ok: false, error: 'READONLY' },
@@ -55,6 +56,12 @@ export function registerTools(server, deps) {
55
56
  function toolResult(kind, value, revealed, extra) {
56
57
  return { result: { kind, value, revealed, ...(extra ?? {}) } };
57
58
  }
59
+ function toolTextContent(structuredContent, fallbackText) {
60
+ const text = textCompatMode === 'structured_json'
61
+ ? JSON.stringify(structuredContent)
62
+ : fallbackText;
63
+ return [{ type: 'text', text }];
64
+ }
58
65
  const uriMatchSchema = z.enum([
59
66
  'domain',
60
67
  'host',
@@ -166,7 +173,7 @@ export function registerTools(server, deps) {
166
173
  const encoded = await sdk.encode(input);
167
174
  return {
168
175
  structuredContent: encoded,
169
- content: [{ type: 'text', text: 'OK' }],
176
+ content: toolTextContent(encoded, 'OK'),
170
177
  };
171
178
  });
172
179
  registerTool(`${deps.toolPrefix}.generate`, {
@@ -193,9 +200,10 @@ export function registerTools(server, deps) {
193
200
  }, async (input, extra) => {
194
201
  const sdk = await deps.getSdk(extra.authInfo);
195
202
  const result = await sdk.generate(clampReveal(input));
203
+ const structuredContent = toolResult('generated', result.value, result.revealed);
196
204
  return {
197
- structuredContent: toolResult('generated', result.value, result.revealed),
198
- content: [{ type: 'text', text: 'OK' }],
205
+ structuredContent,
206
+ content: toolTextContent(structuredContent, 'OK'),
199
207
  };
200
208
  });
201
209
  registerTool(`${deps.toolPrefix}.generate_username`, {
@@ -221,9 +229,10 @@ export function registerTools(server, deps) {
221
229
  }, async (input, extra) => {
222
230
  const sdk = await deps.getSdk(extra.authInfo);
223
231
  const result = await sdk.generateUsername(clampReveal(input));
232
+ const structuredContent = toolResult('generated', result.value, result.revealed);
224
233
  return {
225
- structuredContent: toolResult('generated', result.value, result.revealed),
226
- content: [{ type: 'text', text: 'OK' }],
234
+ structuredContent,
235
+ content: toolTextContent(structuredContent, 'OK'),
227
236
  };
228
237
  });
229
238
  registerTool(`${deps.toolPrefix}.list_folders`, {
@@ -509,9 +518,10 @@ export function registerTools(server, deps) {
509
518
  const item = await sdk.getItem(input.id, {
510
519
  reveal: effectiveReveal(input),
511
520
  });
521
+ const structuredContent = { item };
512
522
  return {
513
- structuredContent: { item },
514
- content: [{ type: 'text', text: 'OK' }],
523
+ structuredContent,
524
+ content: toolTextContent(structuredContent, 'OK'),
515
525
  };
516
526
  });
517
527
  registerTool(`${deps.toolPrefix}.get_uri`, {
@@ -525,9 +535,10 @@ export function registerTools(server, deps) {
525
535
  }, async (input, extra) => {
526
536
  const sdk = await deps.getSdk(extra.authInfo);
527
537
  const uri = await sdk.getUri(input);
538
+ const structuredContent = toolResult('uri', uri.value, uri.revealed);
528
539
  return {
529
- structuredContent: toolResult('uri', uri.value, uri.revealed),
530
- content: [{ type: 'text', text: 'OK' }],
540
+ structuredContent,
541
+ content: toolTextContent(structuredContent, 'OK'),
531
542
  };
532
543
  });
533
544
  registerTool(`${deps.toolPrefix}.get_notes`, {
@@ -542,9 +553,10 @@ export function registerTools(server, deps) {
542
553
  }, async (input, extra) => {
543
554
  const sdk = await deps.getSdk(extra.authInfo);
544
555
  const notes = await sdk.getNotes({ term: input.term }, { reveal: effectiveReveal(input) });
556
+ const structuredContent = toolResult('notes', notes.value, notes.revealed);
545
557
  return {
546
- structuredContent: toolResult('notes', notes.value, notes.revealed),
547
- content: [{ type: 'text', text: 'OK' }],
558
+ structuredContent,
559
+ content: toolTextContent(structuredContent, 'OK'),
548
560
  };
549
561
  });
550
562
  registerTool(`${deps.toolPrefix}.get_exposed`, {
@@ -558,9 +570,10 @@ export function registerTools(server, deps) {
558
570
  }, async (input, extra) => {
559
571
  const sdk = await deps.getSdk(extra.authInfo);
560
572
  const exposed = await sdk.getExposed(input);
573
+ const structuredContent = toolResult('exposed', exposed.value, exposed.revealed);
561
574
  return {
562
- structuredContent: toolResult('exposed', exposed.value, exposed.revealed),
563
- content: [{ type: 'text', text: 'OK' }],
575
+ structuredContent,
576
+ content: toolTextContent(structuredContent, 'OK'),
564
577
  };
565
578
  });
566
579
  registerTool(`${deps.toolPrefix}.get_folder`, {
@@ -574,9 +587,10 @@ export function registerTools(server, deps) {
574
587
  }, async (input, extra) => {
575
588
  const sdk = await deps.getSdk(extra.authInfo);
576
589
  const folder = await sdk.getFolder(input);
590
+ const structuredContent = { folder };
577
591
  return {
578
- structuredContent: { folder },
579
- content: [{ type: 'text', text: 'OK' }],
592
+ structuredContent,
593
+ content: toolTextContent(structuredContent, 'OK'),
580
594
  };
581
595
  });
582
596
  registerTool(`${deps.toolPrefix}.get_collection`, {
@@ -591,9 +605,10 @@ export function registerTools(server, deps) {
591
605
  }, async (input, extra) => {
592
606
  const sdk = await deps.getSdk(extra.authInfo);
593
607
  const collection = await sdk.getCollection(input);
608
+ const structuredContent = { collection };
594
609
  return {
595
- structuredContent: { collection },
596
- content: [{ type: 'text', text: 'OK' }],
610
+ structuredContent,
611
+ content: toolTextContent(structuredContent, 'OK'),
597
612
  };
598
613
  });
599
614
  registerTool(`${deps.toolPrefix}.get_organization`, {
@@ -607,9 +622,10 @@ export function registerTools(server, deps) {
607
622
  }, async (input, extra) => {
608
623
  const sdk = await deps.getSdk(extra.authInfo);
609
624
  const organization = await sdk.getOrganization(input);
625
+ const structuredContent = { organization };
610
626
  return {
611
- structuredContent: { organization },
612
- content: [{ type: 'text', text: 'OK' }],
627
+ structuredContent,
628
+ content: toolTextContent(structuredContent, 'OK'),
613
629
  };
614
630
  });
615
631
  registerTool(`${deps.toolPrefix}.get_org_collection`, {
@@ -624,9 +640,10 @@ export function registerTools(server, deps) {
624
640
  }, async (input, extra) => {
625
641
  const sdk = await deps.getSdk(extra.authInfo);
626
642
  const collection = await sdk.getOrgCollection(input);
643
+ const structuredContent = { collection };
627
644
  return {
628
- structuredContent: { collection },
629
- content: [{ type: 'text', text: 'OK' }],
645
+ structuredContent,
646
+ content: toolTextContent(structuredContent, 'OK'),
630
647
  };
631
648
  });
632
649
  registerTool(`${deps.toolPrefix}.delete_item`, {
@@ -741,9 +758,10 @@ export function registerTools(server, deps) {
741
758
  }, async (input, extra) => {
742
759
  const sdk = await deps.getSdk(extra.authInfo);
743
760
  const attachment = await sdk.getAttachment(input);
761
+ const structuredContent = { attachment };
744
762
  return {
745
- structuredContent: { attachment },
746
- content: [{ type: 'text', text: 'OK' }],
763
+ structuredContent,
764
+ content: toolTextContent(structuredContent, 'OK'),
747
765
  };
748
766
  });
749
767
  registerTool(`${deps.toolPrefix}.send_list`, {
@@ -755,9 +773,10 @@ export function registerTools(server, deps) {
755
773
  }, async (_input, extra) => {
756
774
  const sdk = await deps.getSdk(extra.authInfo);
757
775
  const sends = await sdk.sendList();
776
+ const structuredContent = { sends };
758
777
  return {
759
- structuredContent: { sends },
760
- content: [{ type: 'text', text: 'OK' }],
778
+ structuredContent,
779
+ content: toolTextContent(structuredContent, 'OK'),
761
780
  };
762
781
  });
763
782
  registerTool(`${deps.toolPrefix}.send_template`, {
@@ -771,9 +790,10 @@ export function registerTools(server, deps) {
771
790
  }, async (input, extra) => {
772
791
  const sdk = await deps.getSdk(extra.authInfo);
773
792
  const template = await sdk.sendTemplate(input);
793
+ const structuredContent = { template };
774
794
  return {
775
- structuredContent: { template },
776
- content: [{ type: 'text', text: 'OK' }],
795
+ structuredContent,
796
+ content: toolTextContent(structuredContent, 'OK'),
777
797
  };
778
798
  });
779
799
  registerTool(`${deps.toolPrefix}.send_get`, {
@@ -789,9 +809,10 @@ export function registerTools(server, deps) {
789
809
  }, async (input, extra) => {
790
810
  const sdk = await deps.getSdk(extra.authInfo);
791
811
  const result = await sdk.sendGet(input);
812
+ const structuredContent = { result };
792
813
  return {
793
- structuredContent: { result },
794
- content: [{ type: 'text', text: 'OK' }],
814
+ structuredContent,
815
+ content: toolTextContent(structuredContent, 'OK'),
795
816
  };
796
817
  });
797
818
  registerTool(`${deps.toolPrefix}.send_create`, {
@@ -821,9 +842,10 @@ export function registerTools(server, deps) {
821
842
  return readonlyBlocked();
822
843
  const sdk = await deps.getSdk(extra.authInfo);
823
844
  const send = await sdk.sendCreate(input);
845
+ const structuredContent = { send };
824
846
  return {
825
- structuredContent: { send },
826
- content: [{ type: 'text', text: 'OK' }],
847
+ structuredContent,
848
+ content: toolTextContent(structuredContent, 'OK'),
827
849
  };
828
850
  });
829
851
  registerTool(`${deps.toolPrefix}.send_create_encoded`, {
@@ -852,9 +874,10 @@ export function registerTools(server, deps) {
852
874
  return readonlyBlocked();
853
875
  const sdk = await deps.getSdk(extra.authInfo);
854
876
  const send = await sdk.sendCreateEncoded(input);
877
+ const structuredContent = { send };
855
878
  return {
856
- structuredContent: { send },
857
- content: [{ type: 'text', text: 'OK' }],
879
+ structuredContent,
880
+ content: toolTextContent(structuredContent, 'OK'),
858
881
  };
859
882
  });
860
883
  registerTool(`${deps.toolPrefix}.send_edit`, {
@@ -876,9 +899,10 @@ export function registerTools(server, deps) {
876
899
  return readonlyBlocked();
877
900
  const sdk = await deps.getSdk(extra.authInfo);
878
901
  const send = await sdk.sendEdit(input);
902
+ const structuredContent = { send };
879
903
  return {
880
- structuredContent: { send },
881
- content: [{ type: 'text', text: 'OK' }],
904
+ structuredContent,
905
+ content: toolTextContent(structuredContent, 'OK'),
882
906
  };
883
907
  });
884
908
  registerTool(`${deps.toolPrefix}.send_remove_password`, {
@@ -898,9 +922,10 @@ export function registerTools(server, deps) {
898
922
  return readonlyBlocked();
899
923
  const sdk = await deps.getSdk(extra.authInfo);
900
924
  const result = await sdk.sendRemovePassword(input);
925
+ const structuredContent = { result };
901
926
  return {
902
- structuredContent: { result },
903
- content: [{ type: 'text', text: 'OK' }],
927
+ structuredContent,
928
+ content: toolTextContent(structuredContent, 'OK'),
904
929
  };
905
930
  });
906
931
  registerTool(`${deps.toolPrefix}.send_delete`, {
@@ -920,9 +945,10 @@ export function registerTools(server, deps) {
920
945
  return readonlyBlocked();
921
946
  const sdk = await deps.getSdk(extra.authInfo);
922
947
  const result = await sdk.sendDelete(input);
948
+ const structuredContent = { result };
923
949
  return {
924
- structuredContent: { result },
925
- content: [{ type: 'text', text: 'OK' }],
950
+ structuredContent,
951
+ content: toolTextContent(structuredContent, 'OK'),
926
952
  };
927
953
  });
928
954
  registerTool(`${deps.toolPrefix}.receive`, {
@@ -939,9 +965,10 @@ export function registerTools(server, deps) {
939
965
  }, async (input, extra) => {
940
966
  const sdk = await deps.getSdk(extra.authInfo);
941
967
  const result = await sdk.receive(input);
968
+ const structuredContent = { result };
942
969
  return {
943
- structuredContent: { result },
944
- content: [{ type: 'text', text: 'OK' }],
970
+ structuredContent,
971
+ content: toolTextContent(structuredContent, 'OK'),
945
972
  };
946
973
  });
947
974
  registerTool(`${deps.toolPrefix}.get_username`, {
@@ -955,9 +982,10 @@ export function registerTools(server, deps) {
955
982
  }, async (input, extra) => {
956
983
  const sdk = await deps.getSdk(extra.authInfo);
957
984
  const username = await sdk.getUsername(input);
985
+ const structuredContent = toolResult('username', username.value, username.revealed);
958
986
  return {
959
- structuredContent: toolResult('username', username.value, username.revealed),
960
- content: [{ type: 'text', text: 'OK' }],
987
+ structuredContent,
988
+ content: toolTextContent(structuredContent, 'OK'),
961
989
  };
962
990
  });
963
991
  registerTool(`${deps.toolPrefix}.get_password`, {
@@ -972,9 +1000,10 @@ export function registerTools(server, deps) {
972
1000
  }, async (input, extra) => {
973
1001
  const sdk = await deps.getSdk(extra.authInfo);
974
1002
  const password = await sdk.getPassword({ term: input.term }, { reveal: effectiveReveal(input) });
1003
+ const structuredContent = toolResult('password', password.value, password.revealed);
975
1004
  return {
976
- structuredContent: toolResult('password', password.value, password.revealed),
977
- content: [{ type: 'text', text: 'OK' }],
1005
+ structuredContent,
1006
+ content: toolTextContent(structuredContent, 'OK'),
978
1007
  };
979
1008
  });
980
1009
  registerTool(`${deps.toolPrefix}.get_totp`, {
@@ -989,12 +1018,13 @@ export function registerTools(server, deps) {
989
1018
  }, async (input, extra) => {
990
1019
  const sdk = await deps.getSdk(extra.authInfo);
991
1020
  const totp = await sdk.getTotp({ term: input.term }, { reveal: effectiveReveal(input) });
1021
+ const structuredContent = toolResult('totp', totp.value, totp.revealed, {
1022
+ period: totp.period,
1023
+ timeLeft: totp.timeLeft,
1024
+ });
992
1025
  return {
993
- structuredContent: toolResult('totp', totp.value, totp.revealed, {
994
- period: totp.period,
995
- timeLeft: totp.timeLeft,
996
- }),
997
- content: [{ type: 'text', text: 'OK' }],
1026
+ structuredContent,
1027
+ content: toolTextContent(structuredContent, 'OK'),
998
1028
  };
999
1029
  });
1000
1030
  registerTool(`${deps.toolPrefix}.get_password_history`, {
@@ -1011,9 +1041,10 @@ export function registerTools(server, deps) {
1011
1041
  const history = await sdk.getPasswordHistory(input.id, {
1012
1042
  reveal: effectiveReveal(input),
1013
1043
  });
1044
+ const structuredContent = toolResult('password_history', history.value, history.revealed);
1014
1045
  return {
1015
- structuredContent: toolResult('password_history', history.value, history.revealed),
1016
- content: [{ type: 'text', text: 'OK' }],
1046
+ structuredContent,
1047
+ content: toolTextContent(structuredContent, 'OK'),
1017
1048
  };
1018
1049
  });
1019
1050
  registerTool(`${deps.toolPrefix}.create_login`, {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@icoretech/warden-mcp",
4
- "version": "0.2.6",
4
+ "version": "0.2.8",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "description": "Vaultwarden/Bitwarden MCP server backed by Bitwarden CLI (bw).",