@didit-protocol/mcp-server 5.1.36 → 5.1.51

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.
Files changed (102) hide show
  1. package/README.md +201 -29
  2. package/dist/app-api-key.d.ts +5 -0
  3. package/dist/app-api-key.d.ts.map +1 -0
  4. package/dist/app-api-key.js +108 -0
  5. package/dist/app-api-key.js.map +1 -0
  6. package/dist/auth/cached-verifier.d.ts +38 -0
  7. package/dist/auth/cached-verifier.d.ts.map +1 -0
  8. package/dist/auth/cached-verifier.js +82 -0
  9. package/dist/auth/cached-verifier.js.map +1 -0
  10. package/dist/auth/introspection-verifier.d.ts +12 -0
  11. package/dist/auth/introspection-verifier.d.ts.map +1 -1
  12. package/dist/auth/introspection-verifier.js +40 -14
  13. package/dist/auth/introspection-verifier.js.map +1 -1
  14. package/dist/chatgpt-app.d.ts +1 -0
  15. package/dist/chatgpt-app.d.ts.map +1 -1
  16. package/dist/chatgpt-app.js +2 -0
  17. package/dist/chatgpt-app.js.map +1 -1
  18. package/dist/config.d.ts +12 -3
  19. package/dist/config.d.ts.map +1 -1
  20. package/dist/config.js +55 -8
  21. package/dist/config.js.map +1 -1
  22. package/dist/device-login.d.ts +98 -0
  23. package/dist/device-login.d.ts.map +1 -0
  24. package/dist/device-login.js +455 -0
  25. package/dist/device-login.js.map +1 -0
  26. package/dist/http.d.ts.map +1 -1
  27. package/dist/http.js +61 -5
  28. package/dist/http.js.map +1 -1
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +595 -47
  32. package/dist/index.js.map +1 -1
  33. package/dist/investigator-agent.d.ts +4 -0
  34. package/dist/investigator-agent.d.ts.map +1 -0
  35. package/dist/investigator-agent.js +10 -0
  36. package/dist/investigator-agent.js.map +1 -0
  37. package/dist/login-cli.d.ts +6 -0
  38. package/dist/login-cli.d.ts.map +1 -0
  39. package/dist/login-cli.js +47 -0
  40. package/dist/login-cli.js.map +1 -0
  41. package/dist/mcp-modern.d.ts +1 -0
  42. package/dist/mcp-modern.d.ts.map +1 -1
  43. package/dist/mcp-modern.js +1 -1
  44. package/dist/mcp-modern.js.map +1 -1
  45. package/dist/permissions.d.ts.map +1 -1
  46. package/dist/permissions.js +29 -4
  47. package/dist/permissions.js.map +1 -1
  48. package/dist/privileged-tools.d.ts +1 -0
  49. package/dist/privileged-tools.d.ts.map +1 -1
  50. package/dist/privileged-tools.js +2 -1
  51. package/dist/privileged-tools.js.map +1 -1
  52. package/dist/schema/feature-config-schema.json +941 -28
  53. package/dist/security.d.ts +9 -8
  54. package/dist/security.d.ts.map +1 -1
  55. package/dist/security.js +11 -3
  56. package/dist/security.js.map +1 -1
  57. package/dist/signature-download.d.ts +31 -0
  58. package/dist/signature-download.d.ts.map +1 -0
  59. package/dist/signature-download.js +122 -0
  60. package/dist/signature-download.js.map +1 -0
  61. package/dist/tools/auth.d.ts +2 -0
  62. package/dist/tools/auth.d.ts.map +1 -1
  63. package/dist/tools/auth.js +114 -14
  64. package/dist/tools/auth.js.map +1 -1
  65. package/dist/tools/billing.d.ts +33 -2
  66. package/dist/tools/billing.d.ts.map +1 -1
  67. package/dist/tools/billing.js +252 -12
  68. package/dist/tools/billing.js.map +1 -1
  69. package/dist/tools/compliance.d.ts.map +1 -1
  70. package/dist/tools/compliance.js +37 -0
  71. package/dist/tools/compliance.js.map +1 -1
  72. package/dist/tools/investigator.d.ts +19 -0
  73. package/dist/tools/investigator.d.ts.map +1 -0
  74. package/dist/tools/investigator.js +449 -0
  75. package/dist/tools/investigator.js.map +1 -0
  76. package/dist/tools/members.d.ts +8 -0
  77. package/dist/tools/members.d.ts.map +1 -1
  78. package/dist/tools/members.js +73 -4
  79. package/dist/tools/members.js.map +1 -1
  80. package/dist/tools/observability.d.ts +6 -0
  81. package/dist/tools/observability.d.ts.map +1 -1
  82. package/dist/tools/observability.js +11 -3
  83. package/dist/tools/observability.js.map +1 -1
  84. package/dist/tools/search.d.ts.map +1 -1
  85. package/dist/tools/search.js +89 -5
  86. package/dist/tools/search.js.map +1 -1
  87. package/dist/tools/session-explain-levers.d.ts +6 -0
  88. package/dist/tools/session-explain-levers.d.ts.map +1 -1
  89. package/dist/tools/session-explain-levers.js +40 -7
  90. package/dist/tools/session-explain-levers.js.map +1 -1
  91. package/dist/tools/sessions.d.ts +24 -0
  92. package/dist/tools/sessions.d.ts.map +1 -1
  93. package/dist/tools/sessions.js +196 -2
  94. package/dist/tools/sessions.js.map +1 -1
  95. package/dist/tools/settings.d.ts.map +1 -1
  96. package/dist/tools/settings.js +3 -1
  97. package/dist/tools/settings.js.map +1 -1
  98. package/dist/tools/standalone.d.ts +5 -0
  99. package/dist/tools/standalone.d.ts.map +1 -1
  100. package/dist/tools/standalone.js +18 -2
  101. package/dist/tools/standalone.js.map +1 -1
  102. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -55,6 +55,7 @@ const privileged_tools_1 = require("./privileged-tools");
55
55
  const internal_tools_1 = require("./internal-tools");
56
56
  const blocklist = __importStar(require("./tools/blocklist"));
57
57
  const cases = __importStar(require("./tools/cases"));
58
+ const investigator_1 = require("./tools/investigator");
58
59
  const reports = __importStar(require("./tools/reports"));
59
60
  const observability = __importStar(require("./tools/observability"));
60
61
  const members = __importStar(require("./tools/members"));
@@ -64,6 +65,8 @@ const workflowGraph = __importStar(require("./tools/workflow-graph"));
64
65
  const feature_config_schema_1 = require("./feature-config-schema");
65
66
  const analytics = __importStar(require("./tools/analytics"));
66
67
  const compliance = __importStar(require("./tools/compliance"));
68
+ const device_login_1 = require("./device-login");
69
+ const login_cli_1 = require("./login-cli");
67
70
  const config_1 = require("./config");
68
71
  const blank_args_1 = require("./blank-args");
69
72
  const chatgpt_app_1 = require("./chatgpt-app");
@@ -387,6 +390,7 @@ const TOOL_GROUP_BY_PREFIX = [
387
390
  ["account_", "Account Setup"],
388
391
  ["context_", "Account & Org"],
389
392
  ["org_", "Account & Org"],
393
+ ["billing_", "Billing"],
390
394
  ["session_", "Sessions"],
391
395
  ["workflow_", "Workflows & Questionnaires"],
392
396
  ["questionnaire_", "Workflows & Questionnaires"],
@@ -396,6 +400,7 @@ const TOOL_GROUP_BY_PREFIX = [
396
400
  ["vendor_", "Vendor Users & Businesses"],
397
401
  ["transaction_", "Transactions (AML)"],
398
402
  ["case_", "Cases"],
403
+ ["investigator_", "Investigator"],
399
404
  ["webhook_", "Webhooks & Alerts"],
400
405
  ["alert_", "Webhooks & Alerts"],
401
406
  ["report_", "Reports & Audit"],
@@ -420,6 +425,8 @@ const SCOPE_AGNOSTIC_TOOLS = new Set([
420
425
  "didit_account_resend_otp",
421
426
  "didit_account_login",
422
427
  "didit_account_verify_2fa",
428
+ "didit_account_device_login_start",
429
+ "didit_account_device_login_poll",
423
430
  "didit_org_list",
424
431
  "didit_context_get",
425
432
  // Public pricing catalog: no org/app scope to resolve.
@@ -435,10 +442,13 @@ const ACCOUNT_BOOTSTRAP_TOOLS = new Set([
435
442
  "didit_account_resend_otp",
436
443
  "didit_account_login",
437
444
  "didit_account_verify_2fa",
445
+ "didit_account_device_login_start",
446
+ "didit_account_device_login_poll",
438
447
  ]);
439
448
  // These tools remain available in local/stdio contexts, but should not be part
440
449
  // of the authenticated ChatGPT app catalog because public app review disallows
441
450
  // digital-credit checkout flows and live credential/secret exposure.
451
+ const MONEY_TOOL = "didit_org_top_up";
442
452
  const HOSTED_APP_EXCLUDED_TOOLS = new Set([
443
453
  ...ACCOUNT_BOOTSTRAP_TOOLS,
444
454
  "didit_org_reveal_application_api_key",
@@ -532,6 +542,8 @@ function toolTitle(name) {
532
542
  // name: revealing a live secret, moving money, consequential decisions, and overwrites.
533
543
  const EXPLICIT_DESTRUCTIVE_TOOLS = new Set([
534
544
  "didit_org_reveal_application_api_key",
545
+ // Issues a credential; clients ask before running it.
546
+ "didit_org_create_api_key",
535
547
  "didit_org_top_up",
536
548
  "didit_case_manage",
537
549
  "didit_session_update_status",
@@ -541,6 +553,8 @@ const EXPLICIT_DESTRUCTIVE_TOOLS = new Set([
541
553
  "didit_workflow_edit_graph",
542
554
  "didit_workflow_set_graph",
543
555
  "didit_workflow_publish",
556
+ // Investigator decisions and policy answers: human decisions behind confirm:true.
557
+ ...investigator_1.INVESTIGATOR_DECISION_TOOLS,
544
558
  ...internal_tools_1.INTERNAL_DESTRUCTIVE_TOOLS,
545
559
  ]);
546
560
  // Tools that can reach outside the current Didit workspace/account boundary by
@@ -556,6 +570,7 @@ const EXPLICIT_OPEN_WORLD_TOOLS = new Set([
556
570
  ...internal_tools_1.INTERNAL_OPEN_WORLD_TOOLS,
557
571
  "didit_verify_email_send",
558
572
  "didit_verify_phone_send",
573
+ "didit_session_check_import_provider",
559
574
  "didit_webhook_create",
560
575
  "didit_webhook_update",
561
576
  ]);
@@ -564,7 +579,13 @@ const EXPLICIT_OPEN_WORLD_TOOLS = new Set([
564
579
  const EXPLICIT_WRITE_TOOLS = new Set([
565
580
  "didit_report_export",
566
581
  "didit_session_generate_pdf",
582
+ "didit_session_get_signature_evidence",
583
+ "didit_session_get_signature_field_image",
584
+ "didit_session_get_signed_document",
585
+ "didit_session_manage_import",
586
+ "didit_session_validate_signatures",
567
587
  "didit_session_webhook_resend",
588
+ ...investigator_1.INVESTIGATOR_WRITE_TOOLS,
568
589
  ]);
569
590
  // The inverse: tools whose names carry no read-like token but whose handlers never
570
591
  // change server state (requirements/workflow-check are deterministic reads over the
@@ -573,12 +594,15 @@ const EXPLICIT_WRITE_TOOLS = new Set([
573
594
  // requires read:workflows, and applying the graph goes through the didit_workflow_* writes).
574
595
  const EXPLICIT_READ_TOOLS = new Set([
575
596
  ...internal_tools_1.INTERNAL_READ_TOOLS,
597
+ ...privileged_tools_1.PRIVILEGED_READ_TOOLS,
576
598
  // build_graph computes a graph from a plain feature spec, persisting nothing.
577
599
  "didit_workflow_build_graph",
578
600
  // The per-session webhook delivery log (its only verb-like token is "webhooks").
579
601
  "didit_session_webhooks",
580
602
  // Folds a session's decision payload and its workflow graph into the outcome trace.
581
603
  "didit_session_explain_decision",
604
+ // Quotes a plan change (a GET): nothing is bought, the person confirms in the console.
605
+ "didit_billing_quote_plan",
582
606
  ]);
583
607
  function annotationsFor(name) {
584
608
  const tokens = name.replace(/^didit_/, "").split("_");
@@ -618,6 +642,13 @@ function annotationsFor(name) {
618
642
  function createServer(options = {}) {
619
643
  const hosted = options.hosted === true;
620
644
  const profile = options.profile ?? "full";
645
+ // THE money gate of the hosted server. Every hosted endpoint hides and refuses didit_org_top_up
646
+ // unless it passes `moneyTools: true`, and only the unlisted /mcp/payments endpoint does (http.ts).
647
+ // It never opens on a reduced catalog profile (the ChatGPT catalog has no credit-purchase flow),
648
+ // and stdio is the person's own local server, where the tool is always offered. Checked in three
649
+ // places below: tools/list, the tools/call refusal, and the balance enrichment.
650
+ const moneyTools = hosted && options.moneyTools === true && profile === "full";
651
+ const hostedMoneyBlocked = hosted && !moneyTools;
621
652
  // `access_token` on the auth-service discovery tools is a stdio full-profile convenience: it lets
622
653
  // someone running the local server hand over the Bearer that didit_account_login returned.
623
654
  // A hosted server authenticates with OAuth and reads the caller's Bearer from
@@ -668,7 +699,9 @@ function createServer(options = {}) {
668
699
  },
669
700
  {
670
701
  name: "didit_account_verify_email",
671
- description: "Verify email with the 6-character code. Returns access_token, refresh_token, organization, application (with client_id and api_key).",
702
+ description: "Verify email with the 6-character code. Returns access_token, refresh_token, organization, application (with client_id and api_key). " +
703
+ "If the account already has two-factor authentication it returns 2fa_required (and a temp_token when it has an authenticator) instead of tokens: finish with didit_account_verify_2fa. " +
704
+ "If the account's organization enforces SSO it returns sso_required: no token or API key is issued here, so ask the person to sign in through their organization's SSO in the Didit console in a browser; do not retry.",
672
705
  inputSchema: {
673
706
  type: "object",
674
707
  properties: {
@@ -692,7 +725,9 @@ function createServer(options = {}) {
692
725
  {
693
726
  name: "didit_account_login",
694
727
  description: "Login to existing Didit account. Returns access_token and refresh_token. If the account has two-factor " +
695
- "authentication it returns 2fa_required and a temp_token instead: finish with didit_account_verify_2fa.",
728
+ "authentication it returns 2fa_required and a temp_token instead: finish with didit_account_verify_2fa. " +
729
+ "If the account's organization enforces SSO it returns sso_required: no token is issued by password, so ask the person to sign in through SSO in the console, or use didit_account_device_login_start. " +
730
+ "For an account that signs in with a passkey or SSO (no password), use didit_account_device_login_start instead.",
696
731
  inputSchema: {
697
732
  type: "object",
698
733
  properties: {
@@ -702,6 +737,19 @@ function createServer(options = {}) {
702
737
  required: ["email", "password"],
703
738
  },
704
739
  },
740
+ {
741
+ name: "didit_account_device_login_start",
742
+ description: "Sign in WITHOUT a password or local browser (OAuth device code): returns a short user_code and a URL the " +
743
+ "person opens on any device to approve this connection. Works for passkey and SSO accounts. Then call " +
744
+ "didit_account_device_login_poll. Credentials are stored locally and used automatically afterwards.",
745
+ inputSchema: { type: "object", properties: {} },
746
+ },
747
+ {
748
+ name: "didit_account_device_login_poll",
749
+ description: "Wait (up to about 45 seconds) for the person to approve the sign-in started with " +
750
+ "didit_account_device_login_start. Returns status pending (call again) or connected with the granted scope.",
751
+ inputSchema: { type: "object", properties: {} },
752
+ },
705
753
  {
706
754
  name: "didit_account_verify_2fa",
707
755
  description: "Finish logging in to an account with two-factor authentication, using the temp_token from didit_account_login " +
@@ -894,7 +942,7 @@ function createServer(options = {}) {
894
942
  },
895
943
  {
896
944
  name: "didit_session_list",
897
- description: `List verification sessions for ONE app. If you have multiple apps (or pass no scope) this automatically spans every app, newest first — but didit_session_search is the canonical cross-app tool and what to reach for to answer "my last N sessions". status accepts session-level values: ${SESSION_STATUSES}.`,
945
+ description: `List verification sessions for ONE app. If you have multiple apps (or pass no scope) this automatically spans every app, newest first - but didit_session_search is the canonical cross-app tool and what to reach for to answer "my last N sessions". status accepts session-level values: ${SESSION_STATUSES}. HOW MANY: \`count\` stops at 100 (100 means "100 or more"); when it does, the result adds \`total_count\` (the exact number, from the console's own tab counts) or \`count_is_lower_bound: true\`. Answer "how many" from total_count, never report 100 as the number; limit:1 is enough to count.`,
898
946
  inputSchema: {
899
947
  type: "object",
900
948
  properties: {
@@ -922,6 +970,38 @@ function createServer(options = {}) {
922
970
  required: ["session_id"],
923
971
  },
924
972
  },
973
+ {
974
+ name: "didit_session_get_location_evidence",
975
+ description: "Precise Location (GEOLOCATION) evidence of ONE session, per Location node: `config` (what judged it, every action resolved through the preset), `result` (the decision's verdict), EVERY attempt incl. retired ones (`retired:true`), `reference_points` (device, IP, address; `area_reading` is the earlier attempt a carried area verdict stands on), `distances`, `areas` (inside / blocked / undetermined area ids, `nearest_allowed_km`, `allowed_result`), `anonymizers` (vpn, proxy, tor, spoofing, emulator; null = cannot tell) and `history`: the same person's earlier checks (same vendor_data) that LOCATION_CONSECUTIVE_MISMATCHES and travel tolerance are judged from. The decision keeps only the accepted attempt: use this for 'which attempt was outside', 'why consecutive mismatches' or 'why was the distance excused'. Holds precise coordinates: quote only what the question needs. `nodes: []` means no Location attempt was recorded; a 404 'Precise Location is not available.' means the feature is off on this deployment.",
976
+ inputSchema: {
977
+ type: "object",
978
+ properties: {
979
+ session_id: { type: "string", description: "Session UUID" },
980
+ },
981
+ required: ["session_id"],
982
+ },
983
+ },
984
+ {
985
+ name: "didit_session_simulate",
986
+ description: "SANDBOX ONLY: finish a session of a sandbox application (mode 'sandbox' in didit_context_get) with the " +
987
+ "outcome you pick, without anyone going through the verification flow, then read it with " +
988
+ "didit_session_get_decision and its webhooks with didit_session_webhooks. Never billed. Pass new_status " +
989
+ "('Approved', 'Declined', 'In Review', 'Expired', 'Abandoned'), a scenario slug ('approve', 'decline_aml_hit', " +
990
+ "'decline_document_expired', 'review_aml_possible_match', ...) or a risk. A live session answers not found.",
991
+ inputSchema: {
992
+ type: "object",
993
+ properties: {
994
+ ...orgapp_1.ORG_APP_PROPS,
995
+ session_id: { type: "string", description: "REQUIRED. A session of a sandbox application." },
996
+ new_status: { type: "string", enum: ["Approved", "Declined", "In Review", "Expired", "Abandoned"] },
997
+ scenario: { type: "string", description: "Sandbox scenario slug whose outcome to reproduce." },
998
+ risk: { type: "string", description: "A risk case to add as a warning." },
999
+ comment: { type: "string", description: "Note on the activity entry." },
1000
+ send_webhooks: { type: "boolean", description: "Send the webhooks a real status change sends (default true)." },
1001
+ },
1002
+ required: ["session_id"],
1003
+ },
1004
+ },
925
1005
  {
926
1006
  name: "didit_session_update_status",
927
1007
  description: "Overwrite a session's decision by approving, declining, or requesting resubmission; optionally send a notification email that cannot be recalled. Before calling, obtain explicit user confirmation of the session, new decision, and any email recipient. For resubmission, pass new_status='Resubmitted' and nodes_to_resubmit; already-approved steps are kept.",
@@ -1029,6 +1109,73 @@ function createServer(options = {}) {
1029
1109
  required: ["session_id"],
1030
1110
  },
1031
1111
  },
1112
+ {
1113
+ name: "didit_session_get_signature_evidence",
1114
+ description: "Return download_url, content_type, expires_at and expires_in (300 seconds) for a signer's evidence PDF of an E-signature step: level and format, " +
1115
+ "signer, IP address, each document with its original SHA-256 and field values and the SHA-256 of every signed file, plus, for an Advanced (AES) " +
1116
+ "signature, the verified identity session, the code confirmation, the certificate and the timestamp. Pass the evidence_file path's signer as " +
1117
+ "signature_id; a Business Verification step with several signers needs it, otherwise the route picks one. Fetch the URL to save the PDF; no " +
1118
+ "Authorization header is needed. Treat the URL as sensitive. Requires configured MCP HTTP downloads (see the README).",
1119
+ inputSchema: {
1120
+ type: "object",
1121
+ properties: {
1122
+ ...orgapp_1.ORG_APP_PROPS,
1123
+ session_id: { type: "string", description: "REQUIRED. The User Verification (KYC) or Business Verification (KYB) session." },
1124
+ node_id: { type: "string", description: "REQUIRED. The E-signature step: node_id of the item in the decision's signatures[]." },
1125
+ signature_id: { type: "string", description: "id of the signer's item in signatures[]. Required to pick a signer on a Business Verification step with several." },
1126
+ },
1127
+ required: ["session_id", "node_id"],
1128
+ },
1129
+ },
1130
+ {
1131
+ name: "didit_session_get_signed_document",
1132
+ description: "Return download_url, content_type, expires_at and expires_in (300 seconds) for the signed PDF of one document of an E-signature step: the document the " +
1133
+ "signer was shown with their field values stamped and the evidence page (unless signature_evidence_page is off). An Advanced (AES) PDF also carries the " +
1134
+ "PAdES signature with its timestamp; a Simple PDF has no digital signature, seal or timestamp. Didit checks the file against sha256_signed first (409 on a " +
1135
+ "mismatch, nothing returned). Use the id of the document in signatures[].documents[]. Treat the URL as sensitive. Requires configured MCP HTTP downloads.",
1136
+ inputSchema: {
1137
+ type: "object",
1138
+ properties: {
1139
+ ...orgapp_1.ORG_APP_PROPS,
1140
+ session_id: { type: "string", description: "REQUIRED. The User Verification (KYC) or Business Verification (KYB) session." },
1141
+ node_id: { type: "string", description: "REQUIRED. The E-signature step: node_id of the item in the decision's signatures[]." },
1142
+ document_id: { type: "string", description: "REQUIRED. id of the document in signatures[].documents[]." },
1143
+ },
1144
+ required: ["session_id", "node_id", "document_id"],
1145
+ },
1146
+ },
1147
+ {
1148
+ name: "didit_session_get_signature_field_image",
1149
+ description: "Return download_url, content_type (image/png), expires_at and expires_in (300 seconds) for the signature or initials a signer applied to a field. " +
1150
+ "Use the field id from the image_url of signatures[].documents[].fields[]. Treat the URL as sensitive. Requires configured MCP HTTP downloads.",
1151
+ inputSchema: {
1152
+ type: "object",
1153
+ properties: {
1154
+ ...orgapp_1.ORG_APP_PROPS,
1155
+ session_id: { type: "string", description: "REQUIRED. The User Verification (KYC) or Business Verification (KYB) session." },
1156
+ node_id: { type: "string", description: "REQUIRED. The E-signature step: node_id of the item in the decision's signatures[]." },
1157
+ field_id: { type: "string", description: "REQUIRED. The field on this signer's copy, as in the field's image_url." },
1158
+ },
1159
+ required: ["session_id", "node_id", "field_id"],
1160
+ },
1161
+ },
1162
+ {
1163
+ name: "didit_session_validate_signatures",
1164
+ description: "Re-check the signed documents of an E-signature step and save the result in each signer's validation. Didit re-reads every signed PDF, checks its " +
1165
+ "SHA-256 and, for an Advanced (AES) signature, validates the PAdES signature, the certificate, the revocation data and the timestamp (a Simple signature " +
1166
+ "has no digital signature, so only file integrity is checked). Nothing is signed again. Without signature_id every signer of the step is checked and the " +
1167
+ "call fails with 409 if any has not signed; 400 means a stored signed PDF no longer matches its recorded SHA-256. Returns the checked signers.",
1168
+ inputSchema: {
1169
+ type: "object",
1170
+ properties: {
1171
+ ...orgapp_1.ORG_APP_PROPS,
1172
+ session_id: { type: "string", description: "REQUIRED. The User Verification (KYC) or Business Verification (KYB) session." },
1173
+ node_id: { type: "string", description: "REQUIRED. The E-signature step: node_id of the item in the decision's signatures[]." },
1174
+ signature_id: { type: "string", description: "id of one signer's item in signatures[]; omit to check every signer of the step." },
1175
+ },
1176
+ required: ["session_id", "node_id"],
1177
+ },
1178
+ },
1032
1179
  {
1033
1180
  name: "didit_session_list_reviews",
1034
1181
  description: "List the review history and activity log for a session.",
@@ -1120,18 +1267,80 @@ function createServer(options = {}) {
1120
1267
  // ── Session Imports (bulk migration) ────────────────────────────────
1121
1268
  {
1122
1269
  name: "didit_session_create_import",
1123
- description: "Create a bulk import job from a hosted CSV/NDJSON file (e.g. migrating historical verifications into Didit). Pass source_file_url. All imports use Didit's canonical schema. To label a record's source, include the optional per-row `provider` column in the file itself (defaults to generic) — there is no provider request field.",
1270
+ description: "Create a bulk import job: a hosted CSV/NDJSON file (source_file_url) of historical verifications, or (source=provider) a migration from another " +
1271
+ "identity verification provider. File imports use Didit's canonical schema; label a record's source with the optional per-row `provider` column in the " +
1272
+ "file. A provider migration reads Sumsub, Onfido, Persona and ComplyCube with the customer's READ-ONLY key (`credentials`, named as that provider's " +
1273
+ "credential_fields from didit_session_list_import_providers); Veriff, iDenfy and MetaMap are read by the record IDs in source_file_url, and the others import " +
1274
+ "an export file. The key is secret: ask the user for a read-only key, never log or repeat it, and never reuse it. Didit encrypts it, never returns it and " +
1275
+ "erases it when the import ends. Prefer dry_run:true first: it counts what would import and writes nothing, ends READY, and didit_session_manage_import " +
1276
+ "action=start then imports for real. Record IDs are namespaced by provider, so re-runs and moving between a file and a provider migration never import a " +
1277
+ "record twice. An application runs at most 4 active import jobs at once (a fifth answers 429); a job a deploy interrupted resumes by itself. Imports must be " +
1278
+ "enabled for the organization by Didit and are refused on a sandbox application (403).",
1124
1279
  inputSchema: {
1125
1280
  type: "object",
1126
1281
  properties: {
1127
- source_file_url: { type: "string", description: "REQUIRED. Publicly fetchable URL of the CSV/NDJSON file to import." },
1282
+ source_file_url: { type: "string", description: "Publicly fetchable HTTPS URL of the CSV/NDJSON file (or, for providers read by record IDs, of the ID list) to import." },
1128
1283
  import_type: { type: "string", enum: ["user_verification", "business_verification", "status_rules", "transactions"], description: "What the rows represent (default user_verification)" },
1129
- source_format: { type: "string", enum: ["csv", "ndjson"], description: "File format (default csv)" },
1284
+ source_format: { type: "string", enum: ["csv", "ndjson"], description: "File format (default: inferred from the URL)" },
1130
1285
  workflow_id: { type: "string", description: "Workflow to associate imported sessions with" },
1286
+ source: { type: "string", enum: ["file", "provider"], description: "provider makes this a migration from another provider. Omit for a file import." },
1287
+ provider: { type: "string", description: "Migration source id from didit_session_list_import_providers (for example sumsub, onfido, persona). Required when source is provider." },
1288
+ credentials: {
1289
+ type: "object",
1290
+ additionalProperties: { type: "string" },
1291
+ description: "SECRET. The provider's read-only key, with the field names its credential_fields list. Never echo it back to the user or into logs.",
1292
+ },
1293
+ options: { type: "object", description: "Provider options, for example { region } (Onfido: eu, us, ca)." },
1294
+ status_mapping: {
1295
+ type: "object",
1296
+ additionalProperties: { type: "string", enum: ["Approved", "Declined", "In Review", "Expired", "Not Finished", "Abandoned"] },
1297
+ description: "Edits to the provider's default status mapping: source status to Didit status. Not Finished and Abandoned are skipped and counted, never imported.",
1298
+ },
1299
+ dry_run: { type: "boolean", description: "Count what a provider migration would import and write nothing; the job ends READY and is started with didit_session_manage_import." },
1300
+ face_templates: { type: "boolean", description: "Build face templates from imported selfies and search them against the application's faces and blocklist (flags for review only). Requires lawful_basis_confirmed." },
1301
+ lawful_basis_confirmed: { type: "boolean", description: "Confirms the customer has a lawful basis to share these selfies with Didit as processor. Only set it after the user states so." },
1131
1302
  },
1132
1303
  required: ["source_file_url"],
1133
1304
  },
1134
1305
  },
1306
+ {
1307
+ name: "didit_session_list_import_providers",
1308
+ description: "List the 15 providers verifications can be migrated from: what each needs to connect (credential_fields, regions), whether its API can list records, the permissions its read-only key needs and its default status mapping.",
1309
+ inputSchema: { type: "object", properties: {} },
1310
+ },
1311
+ {
1312
+ name: "didit_session_check_import_provider",
1313
+ description: "Read a provider with the customer's read-only key before creating a migration. Nothing is stored. For providers read by record IDs, pass record_ids " +
1314
+ "(the first record ID of the export). The key is secret: never log or repeat it.",
1315
+ inputSchema: {
1316
+ type: "object",
1317
+ properties: {
1318
+ provider: { type: "string", description: "REQUIRED. Provider id from didit_session_list_import_providers." },
1319
+ credentials: { type: "object", additionalProperties: { type: "string" }, description: "REQUIRED. SECRET. The provider's read-only key, named as its credential_fields." },
1320
+ options: { type: "object", description: "Provider options, for example { region }." },
1321
+ record_ids: { type: "array", items: { type: "string" }, description: "For providers read by record IDs: the first record ID of the export." },
1322
+ },
1323
+ required: ["provider", "credentials"],
1324
+ },
1325
+ },
1326
+ {
1327
+ name: "didit_session_manage_import",
1328
+ description: "Act on an import job: start (a dry run that ended READY imports for real, with the status_mapping, face_templates and lawful_basis_confirmed sent now), " +
1329
+ "pause, resume, cancel (what was imported stays; the uploaded file and the key are erased) or retry (runs an ended migration again as a NEW job with a new key " +
1330
+ "in credentials, since the old one was erased; everything already in Didit is skipped).",
1331
+ inputSchema: {
1332
+ type: "object",
1333
+ properties: {
1334
+ import_id: { type: "string", description: "REQUIRED. Import job ID." },
1335
+ action: { type: "string", enum: ["start", "pause", "resume", "cancel", "retry"], description: "REQUIRED." },
1336
+ data: {
1337
+ type: "object",
1338
+ description: "start: { status_mapping, face_templates, lawful_basis_confirmed }. retry: { credentials } (SECRET, never echo it). Other actions take none.",
1339
+ },
1340
+ },
1341
+ required: ["import_id", "action"],
1342
+ },
1343
+ },
1135
1344
  {
1136
1345
  name: "didit_session_get_import_template",
1137
1346
  description: "Download the canonical import template (column headers and format) used by didit_session_create_import.",
@@ -1607,7 +1816,7 @@ function createServer(options = {}) {
1607
1816
  },
1608
1817
  {
1609
1818
  name: "didit_vendor_user_delete",
1610
- description: "Batch delete users by vendor_data list, or delete all users.",
1819
+ description: "Batch delete users by vendor_data list, or delete all users. Deletion is permanent. If the API answers 409 (in_filed_report: a selected person is in a finalized regulatory report; subject_deletion_in_progress: another request is still deleting one of them), nothing is deleted: repeat the request once that deletion has finished.",
1611
1820
  inputSchema: {
1612
1821
  type: "object",
1613
1822
  properties: {
@@ -1700,7 +1909,7 @@ function createServer(options = {}) {
1700
1909
  },
1701
1910
  {
1702
1911
  name: "didit_vendor_business_delete",
1703
- description: "Batch delete businesses by vendor_data list and/or didit_internal_id list, or delete all businesses.",
1912
+ description: "Batch delete businesses by vendor_data list and/or didit_internal_id list, or delete all businesses. Deletion is permanent. If the API answers 409 (in_filed_report or subject_deletion_in_progress), nothing is deleted: repeat the request once the other deletion has finished.",
1704
1913
  inputSchema: {
1705
1914
  type: "object",
1706
1915
  properties: {
@@ -1832,7 +2041,9 @@ function createServer(options = {}) {
1832
2041
  "aggregation or actions to a created rule. Prefer mode:'TEST', backtest the exact saved config, then switch " +
1833
2042
  "to ACTIVE only after confirming the hit rate. title is unique among non-deleted rules in the app. " +
1834
2043
  "actions is REQUIRED: every outcome the user named (review, decline, approve, score, case) must appear " +
1835
- "there; pass [] ONLY when the user explicitly wants a monitor-only rule that does nothing on match.",
2044
+ "there; pass [] ONLY when the user explicitly wants a monitor-only rule that does nothing on match. " +
2045
+ "To change a library (PRESET) rule, send its definition as a copy with metadata.based_on (the library key) " +
2046
+ "and metadata.based_on_rule_uuid.",
1836
2047
  inputSchema: {
1837
2048
  type: "object",
1838
2049
  properties: {
@@ -1858,7 +2069,10 @@ function createServer(options = {}) {
1858
2069
  {
1859
2070
  name: "didit_transaction_rule_update",
1860
2071
  description: "Partially update a transaction-monitoring rule. Send every changed persisted field in this PATCH. PRESET " +
1861
- "rules only allow mode changes. Before raising impact, backtest the exact candidate config and keep the rule " +
2072
+ "rules only allow mode changes: to change a PRESET rule's conditions, create a CUSTOM copy with " +
2073
+ "didit_transaction_rule_create (the library rule's definition plus metadata.based_on = its library key and " +
2074
+ "metadata.based_on_rule_uuid), then set the library rule's mode to DISABLED so a transaction does not alert " +
2075
+ "twice. Before raising impact, backtest the exact candidate config and keep the rule " +
1862
2076
  "in TEST until the result is acceptable.",
1863
2077
  inputSchema: {
1864
2078
  type: "object",
@@ -1973,34 +2187,144 @@ function createServer(options = {}) {
1973
2187
  // ── Billing ─────────────────────────────────────────────────────────
1974
2188
  {
1975
2189
  name: "didit_org_get_balance",
1976
- description: "Get current credit balance and auto-refill settings. A `0.00` balance does NOT by itself " +
1977
- "block verifications, so never answer a \"not enough credits\" report with \"top up\" from this " +
1978
- "result alone: a workflow whose features are all free-tier (ID verification, passive liveness, " +
1979
- "face match 1:1, device/IP analysis — 500 free each per month) runs fine on a zero balance. " +
1980
- "Read the failing workflow with didit_workflow_list first — `is_white_label_enabled: true` adds " +
1981
- "$0.20/session AND drops the workflow out of the free tier entirely, which is the single most " +
1982
- "common cause. This result also carries `allow_free_usage` (false = the free tier is off for " +
1983
- "this organization) and `usage_summary.white_label_sessions`. Only a NEGATIVE balance stops " +
1984
- "free-tier work; zero does not.",
2190
+ description: "Get current credit balance and auto-refill settings. Every check is billed from the first one: " +
2191
+ "from 1 Nov 2026 an eligible Free organization gets $10 of monthly credit usable on any feature, paid " +
2192
+ "plans carry their monthly plan credit (Growth $115, Scale $350), and no workflow is free of charge. " +
2193
+ "The Free credit is decided per organization: `free_credit.receives` says whether this one gets it, " +
2194
+ "and `free_credit.this_month` holds this month's credit, also once used up. `free_credit.eligibility` " +
2195
+ "says why an organization does NOT get it, because the credit needs a work email: personal_email " +
2196
+ "means it signed up with a personal email, temporary_email with a temporary one, company_exists " +
2197
+ "that its company already has an organization, api_created that it was created through the API. " +
2198
+ "Such an organization never had the credit, so it was not used up. Answer from these fields, never " +
2199
+ "from the plan alone; when `free_credit` is absent, say you could not read it. Never answer " +
2200
+ "a \"not enough credits\" report from this result alone: read the failing workflow with " +
2201
+ "didit_workflow_list first - `is_white_label_enabled: true` adds $0.20/session, which is a common " +
2202
+ "cause of credit running out faster than expected. This result also carries `allow_free_usage` " +
2203
+ "(organizations on negotiated terms keep the monthly free allowance they were sold until renewal; " +
2204
+ "false means that allowance is off for this organization) and `usage_summary.white_label_sessions`. " +
2205
+ "When the balance cannot cover what the person wants to run, give them `next_steps.top_up_url` (the console " +
2206
+ "top-up dialog with the amount filled in; replace the number to change it) or `next_steps.automatic_top_up_url` " +
2207
+ "(save a card and turn on automatic top-up so the balance never runs out). Didit tools never charge a card. " +
2208
+ "Meanwhile keep building in the organization's sandbox application (`mode: sandbox` in didit_context_get), " +
2209
+ "which is never billed.",
1985
2210
  inputSchema: { type: "object", properties: { organization_id: orgapp_1.ORG_APP_PROPS.organization_id } },
1986
2211
  },
1987
2212
  {
1988
2213
  name: "didit_org_top_up",
1989
- description: "Create a Stripe checkout session to top up credits. Returns a checkout URL.",
2214
+ description: "Top up credits ($50 to $20,000 per top-up). payment_method \"checkout\" (default) creates a Stripe Checkout " +
2215
+ "page and returns checkout_session_url for the person to pay; it never charges a card by itself. " +
2216
+ "payment_method \"saved_card\" charges the organization's saved primary card off-session, now, when a person " +
2217
+ "turned on \"Connected AI agents can top up with your saved card\" in the Didit console (Billing > Payment " +
2218
+ "methods; off by default; didit_org_get_balance shows it as agent_top_up.enabled where this tool is offered). " +
2219
+ "It needs idempotency_key: choose ONE unique key per intended top-up (for example a UUID) and reuse that same " +
2220
+ "key on any retry of that same top-up, so a retry can never charge twice; never reuse a key for another " +
2221
+ "amount and never retry with a new key. A refusal carries `code`, `detail` and `next_step` {action, url, " +
2222
+ "description}: agent_top_up_not_enabled (the switch is off), authentication_required (the card's bank asks the " +
2223
+ "cardholder to approve), payment_method_required (no saved card) and card_declined are finished by the " +
2224
+ "person: give them next_step.url (a Top up dialog link that says which agent asked, with the amount filled in).",
1990
2225
  inputSchema: {
1991
2226
  type: "object",
1992
2227
  properties: {
1993
- amount_in_dollars: { type: "number", description: "Amount in USD (minimum $50)" },
1994
- success_url: { type: "string", description: "Optional redirect after successful payment" },
1995
- cancel_url: { type: "string", description: "Optional redirect if payment is cancelled" },
2228
+ organization_id: orgapp_1.ORG_APP_PROPS.organization_id,
2229
+ amount_in_dollars: { type: "number", description: "Amount in USD (minimum $50, maximum $20,000 per self-serve top-up)" },
2230
+ payment_method: {
2231
+ type: "string",
2232
+ enum: ["checkout", "saved_card"],
2233
+ description: "checkout (default): a Stripe Checkout page for the person to pay. saved_card: charge the organization's saved primary card now, only while a person has turned on the agent top-up switch in the console; requires idempotency_key.",
2234
+ },
2235
+ idempotency_key: {
2236
+ type: "string",
2237
+ minLength: 1,
2238
+ maxLength: 255,
2239
+ description: "REQUIRED for payment_method saved_card (1 to 255 characters). One unique key per intended top-up; reuse the same key on any retry of that same top-up so the card is never charged twice. Ignored for checkout.",
2240
+ },
1996
2241
  confirm: {
1997
2242
  type: "boolean",
1998
- description: "REQUIRED. Must be true - creates a Stripe checkout that moves money (it never auto-charges). Only set after explicit user confirmation of this exact action.",
2243
+ description: "REQUIRED. Must be true. Only set after explicit user confirmation of this exact action: checkout creates a payment page, saved_card charges the saved card immediately.",
1999
2244
  },
2000
2245
  },
2001
2246
  required: ["amount_in_dollars"],
2002
2247
  },
2003
2248
  },
2249
+ {
2250
+ name: "didit_billing_get_plan",
2251
+ description: "Get the organization's plan: the plan and its status, monthly fee and credit, the next charge, the last " +
2252
+ "payment, any unpaid invoice and any scheduled plan change. `next_steps.plans_url` is the console page where " +
2253
+ "the person changes the plan.",
2254
+ inputSchema: { type: "object", properties: { organization_id: orgapp_1.ORG_APP_PROPS.organization_id } },
2255
+ },
2256
+ {
2257
+ name: "didit_billing_quote_plan",
2258
+ description: "Quote a plan change without making it: what it charges today (`amount_due`), the credit it adds " +
2259
+ "(`credit_added`) and the billing period. Plans: free, growth ($99/month, $115 of credit a month, 4% off every " +
2260
+ "price), scale ($299/month, $350 of credit a month, 10% off); yearly billing is cheaper. Show the person the " +
2261
+ "quote; they confirm and pay on `next_steps.plans_url` (Didit tools never buy a plan).",
2262
+ inputSchema: {
2263
+ type: "object",
2264
+ properties: {
2265
+ organization_id: orgapp_1.ORG_APP_PROPS.organization_id,
2266
+ plan: { type: "string", enum: ["free", "growth", "scale"], description: "The plan to quote." },
2267
+ billing_interval: { type: "string", enum: ["monthly", "yearly"], description: "Defaults to monthly." },
2268
+ },
2269
+ required: ["plan"],
2270
+ },
2271
+ },
2272
+ {
2273
+ name: "didit_billing_list_payment_methods",
2274
+ description: "List the organization's saved cards (brand, last 4 digits, expiry) in the order automatic charges try them, " +
2275
+ "card 1 being the primary. An empty list means no card is saved: top-ups then go through Checkout or the " +
2276
+ "console. `next_steps.add_card_url` is where the person adds a card or turns on automatic top-up.",
2277
+ inputSchema: { type: "object", properties: { organization_id: orgapp_1.ORG_APP_PROPS.organization_id } },
2278
+ },
2279
+ {
2280
+ name: "didit_billing_list_receipts",
2281
+ description: "List the organization's payment receipts (top-ups and plan charges), newest first.",
2282
+ inputSchema: {
2283
+ type: "object",
2284
+ properties: {
2285
+ organization_id: orgapp_1.ORG_APP_PROPS.organization_id,
2286
+ limit: { type: "number", description: "Page size (default set by the server)." },
2287
+ offset: { type: "number", description: "Rows to skip." },
2288
+ },
2289
+ },
2290
+ },
2291
+ {
2292
+ name: "didit_billing_get_details",
2293
+ description: "Get the billing details printed on every receipt and invoice: legal name, tax ID, address, billing emails " +
2294
+ "and PO number.",
2295
+ inputSchema: { type: "object", properties: { organization_id: orgapp_1.ORG_APP_PROPS.organization_id } },
2296
+ },
2297
+ {
2298
+ name: "didit_billing_update_details",
2299
+ description: "Change the billing details printed on receipts and invoices. Pass only the fields to change; the rest " +
2300
+ "keep their saved values. Before calling, show the person each change and get their confirmation. When " +
2301
+ "the organization confirms billing changes with an authenticator code, the change is refused and the " +
2302
+ "person saves it in the console instead (the error names the page).",
2303
+ inputSchema: {
2304
+ type: "object",
2305
+ properties: {
2306
+ organization_id: orgapp_1.ORG_APP_PROPS.organization_id,
2307
+ legal_name: { type: "string", description: "The company's legal name." },
2308
+ tax_id_type: { type: "string", description: "Stripe tax ID type, e.g. eu_vat, gb_vat, us_ein. Needs tax_id." },
2309
+ tax_id: { type: "string", description: "The tax ID number. Needs tax_id_type." },
2310
+ address: {
2311
+ type: "object",
2312
+ description: "Billing address; only the lines passed change.",
2313
+ properties: {
2314
+ line1: { type: "string" },
2315
+ line2: { type: "string" },
2316
+ city: { type: "string" },
2317
+ state: { type: "string" },
2318
+ postal_code: { type: "string" },
2319
+ country: { type: "string", description: "ISO 3166-1 alpha-2, e.g. ES, US." },
2320
+ },
2321
+ additionalProperties: false,
2322
+ },
2323
+ billing_emails: { type: "array", items: { type: "string" }, description: "Addresses that receive receipts and invoices (replaces the list)." },
2324
+ po_number: { type: "string", description: "Purchase order number printed on invoices." },
2325
+ },
2326
+ },
2327
+ },
2004
2328
  // ── Customization (verification UI branding) ────────────────────────
2005
2329
  {
2006
2330
  name: "didit_branding_get",
@@ -2264,6 +2588,44 @@ function createServer(options = {}) {
2264
2588
  },
2265
2589
  },
2266
2590
  },
2591
+ {
2592
+ name: "didit_verify_account_check",
2593
+ description: "Check that a bank account belongs to the person or company you name, before sending money to it. No session: send the name and the account, read the result. " +
2594
+ "result is match, close_match, no_match or cannot_verify; on a close_match, holder_name is the name the bank holds the account under (when returned); account " +
2595
+ "comes back masked to its last 4 characters. Billed once per check the bank answers at the account's country price, whatever the result (no_match and " +
2596
+ "cannot_verify too); an error is never billed. Every call is a NEW billed check (no idempotency key, no read-back): do not retry blindly and store the response. " +
2597
+ "Errors: 400 names the field and reason (consent required: in countries whose check needs the account holder's explicit consent, ask for it and send " +
2598
+ "consent:true; nothing is billed); 402 top up; 404 country_not_covered or bank_not_covered; 503 the bank could not answer, send again later. " +
2599
+ "Where Bank Verification is not switched on (production at the moment) it answers 404 bank_verification_not_available. A sandbox application calls no bank " +
2600
+ "and charges nothing: the last 4 characters of the IBAN, else the account number, choose the answer (0001 close_match with holder_name, 0002 close_match " +
2601
+ "without, 0003 and 0006 no_match, 0004 cannot_verify, 0005 a 503, 0009 a 400, anything else match).",
2602
+ inputSchema: {
2603
+ type: "object",
2604
+ properties: {
2605
+ ...orgapp_1.ORG_APP_PROPS,
2606
+ country: { type: "string", description: "REQUIRED. The account's country, ISO 3166-1 alpha-3 (for example GBR, NGA)." },
2607
+ account: {
2608
+ type: "object",
2609
+ description: "REQUIRED. The account the way its country writes it: an iban, or an account_number with the bank or branch code the country needs (sort_code, routing_number, " +
2610
+ "transit_institution, bsb, ifsc, bank_code, bic). Mexico takes a clabe and Argentina a cbu_cvu. A business account adds registration_id where the country asks. " +
2611
+ "Spaces, dashes and dots are ignored; a key the country needs and does not get is a 400 that names it.",
2612
+ properties: {
2613
+ iban: { type: "string" }, account_number: { type: "string" }, sort_code: { type: "string" }, routing_number: { type: "string" },
2614
+ transit_institution: { type: "string" }, bsb: { type: "string" }, ifsc: { type: "string" }, bank_code: { type: "string" },
2615
+ bic: { type: "string" }, clabe: { type: "string" }, cbu_cvu: { type: "string" }, registration_id: { type: "string" },
2616
+ },
2617
+ },
2618
+ holder: {
2619
+ type: "object",
2620
+ description: "REQUIRED. The name to check: full_name for a person, or business_name for a company (a business name checks a business account).",
2621
+ properties: { full_name: { type: "string" }, business_name: { type: "string" } },
2622
+ },
2623
+ vendor_data: { type: "string", description: "Your own reference for this check, returned unchanged." },
2624
+ consent: { type: "boolean", description: "true when the account holder explicitly consented to this check. Required where the country's check needs it; only set it after the user states the holder consented." },
2625
+ },
2626
+ required: ["country", "account", "holder"],
2627
+ },
2628
+ },
2267
2629
  {
2268
2630
  name: "didit_verify_database",
2269
2631
  description: "Validate identity data against national and global authoritative data sources. issuing_state (ISO 3166-1 alpha-3) is required and selects which sources run.",
@@ -2313,7 +2675,7 @@ function createServer(options = {}) {
2313
2675
  },
2314
2676
  {
2315
2677
  name: "didit_verify_kyb_select",
2316
- description: "Resolve a candidate from didit_verify_kyb_search into a full company registry record. kyb_response_id is the per-search candidate handle returned by the search.",
2678
+ description: "Resolve a candidate from didit_verify_kyb_search into a full company registry record. kyb_response_id is the per-search candidate handle returned by the search. A resolved record carries registry_status and verification_status (verified, failed or unknown).",
2317
2679
  inputSchema: {
2318
2680
  type: "object",
2319
2681
  properties: {
@@ -2430,7 +2792,7 @@ function createServer(options = {}) {
2430
2792
  },
2431
2793
  {
2432
2794
  name: "didit_verify_phone_send",
2433
- description: "Send a one-time verification code to a phone number via SMS. Code valid for 5 minutes.",
2795
+ description: "Send a one-time verification code to a phone number. Delivered on WhatsApp by default, falling back to SMS where WhatsApp cannot reach that country or number. The code is valid for 5 minutes. Returns request_id plus status: Success (a new code was sent), Retry (resent while an earlier code for that number is still pending) or Blocked (the number was refused; see reason). Paid from the organization's balance, so a live application really delivers a message, and answers 403 until the organization's first top-up or when the balance is short; a sandbox application mocks the send for free. Repeated sends to one number can answer 429 with code PHONE_RATE_LIMITED. Sends with the application's API key, so the caller's role needs create:sessions (Owner, Admin or Developer; an organization owner or admin with a local didit_account_login token), and an MCP sign-in needs the didit:management scope to read that key.",
2434
2796
  inputSchema: {
2435
2797
  type: "object",
2436
2798
  properties: {
@@ -2442,13 +2804,13 @@ function createServer(options = {}) {
2442
2804
  },
2443
2805
  {
2444
2806
  name: "didit_verify_phone_check",
2445
- description: "Verify the OTP code sent to a phone number. Max 3 attempts per code.",
2807
+ description: "Check the one-time code sent to a phone number and return what Didit knows about that number. Maximum 3 attempts per code, and the code expires 5 minutes after it was sent. Returns status Approved, Failed (with the attempts remaining), Declined, or 'Expired or Not Found' when that number has no code pending. A sandbox application mocks the check and approves any code. Sends with the application's API key, so the caller's role needs create:sessions (Owner, Admin or Developer; an organization owner or admin with a local didit_account_login token), and an MCP sign-in needs the didit:management scope to read that key.",
2446
2808
  inputSchema: {
2447
2809
  type: "object",
2448
2810
  properties: {
2449
2811
  ...orgapp_1.ORG_APP_PROPS,
2450
2812
  phone_number: { type: "string" },
2451
- code: { type: "string", description: "Verification code from SMS" },
2813
+ code: { type: "string", description: "Verification code from the WhatsApp or SMS message" },
2452
2814
  },
2453
2815
  required: ["phone_number", "code"],
2454
2816
  },
@@ -2513,6 +2875,8 @@ function createServer(options = {}) {
2513
2875
  required: ["case_id", "action"],
2514
2876
  },
2515
2877
  },
2878
+ // ── Investigator (AI case reviewer; decisions need human approval) ──
2879
+ ...investigator_1.INVESTIGATOR_TOOL_DEFS,
2516
2880
  // ── Reports (async exports) ─────────────────────────────────────────
2517
2881
  {
2518
2882
  name: "didit_report_list",
@@ -2541,8 +2905,29 @@ function createServer(options = {}) {
2541
2905
  // ── Audit logs + alerts ─────────────────────────────────────────────
2542
2906
  {
2543
2907
  name: "didit_audit_log_list",
2544
- description: "List audit-log entries for the application (who changed what).",
2545
- inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS, cursor: { type: "string" } } },
2908
+ description: "List the organization's audit log, newest first: who did what in the organization (members, API keys, " +
2909
+ "Didit itself, the Didit assistant and the Investigator). Each entry has actor {type, name, email}, action, " +
2910
+ "description, target {type, id, label} and changes. Decisions the Investigator took on its own are entries " +
2911
+ "with actor_type 'investigator' and changes.investigator {run_id, outcome, recommendation, confidence, policy}. " +
2912
+ "A person's decision on an Investigator report is that member's entry with changes.investigator.outcome " +
2913
+ "'accepted' or 'overridden'. To answer \"who approved session 20458\", pass search='20458' (or target_id=<the " +
2914
+ "record's uuid>) and read the actor of the decision entry.",
2915
+ inputSchema: {
2916
+ type: "object",
2917
+ properties: {
2918
+ organization_id: orgapp_1.ORG_APP_PROPS.organization_id,
2919
+ application_id: { type: "string", description: "Only this application's entries (application UUID). Omit for the whole organization." },
2920
+ actor_type: { type: "string", enum: ["member", "api_key", "system", "assistant_delegated", "investigator"], description: "Only this kind of actor." },
2921
+ action_category: { type: "string", description: "e.g. sessions, transactions, cases, api-keys, members; comma-separated for several." },
2922
+ target_type: { type: "string", description: "The kind of record acted on, e.g. session, transaction, case." },
2923
+ target_id: { type: "string", description: "The UUID of the record acted on." },
2924
+ search: { type: "string", description: "A session number, event id (evt_...), email, IP, path or record label." },
2925
+ created_at_start: { type: "string", description: "ISO date-time, inclusive." },
2926
+ created_at_end: { type: "string", description: "ISO date-time, inclusive." },
2927
+ page: { type: "integer", minimum: 1, description: "1-based page (default 1)." },
2928
+ page_size: { type: "integer", minimum: 1, maximum: 100, description: "Entries per page (default 25, max 100)." },
2929
+ },
2930
+ },
2546
2931
  },
2547
2932
  {
2548
2933
  name: "didit_alert_list",
@@ -2606,10 +2991,41 @@ function createServer(options = {}) {
2606
2991
  description: "List the roles available in the organization.",
2607
2992
  inputSchema: { type: "object", properties: { organization_id: orgapp_1.ORG_APP_PROPS.organization_id } },
2608
2993
  },
2994
+ {
2995
+ name: "didit_org_create_api_key",
2996
+ description: "Create the API key the integration you are building needs (sent as x-api-key to the verification API), " +
2997
+ "for one application. Didit allows ONE live key per connected app and application, scoped to what the " +
2998
+ "signed-in person can do (never full access, never API key management), rate-limited and audit-logged; " +
2999
+ "the person sees it with this connected app in the console and can revoke it there. The secret is returned " +
3000
+ "ONCE: write it straight to the project's secret store or .env and never repeat it in the chat. Pick the " +
3001
+ "application by its mode in didit_context_get: a sandbox key to build and test for free, a live key to go " +
3002
+ "live. Requires confirm:true after the person agreed.",
3003
+ inputSchema: {
3004
+ type: "object",
3005
+ properties: {
3006
+ organization_id: { type: "string", description: "REQUIRED. The organization (from didit_context_get)." },
3007
+ application_id: { type: "string", description: "REQUIRED. The application the key is for (from didit_context_get)." },
3008
+ label: { type: "string", description: "Name shown in the console, e.g. 'Acme backend (Codex)'." },
3009
+ scopes: {
3010
+ type: "object",
3011
+ description: "Optional narrower access: resource -> 'read' | 'write' (sessions, decisions, media, users, businesses, " +
3012
+ "transactions, workflows, webhooks, applications, analytics). Omit it for everything the person can do.",
3013
+ additionalProperties: { type: "string", enum: ["read", "write"] },
3014
+ },
3015
+ workflow_ids: { type: "array", items: { type: "string" }, description: "Optional: only these workflows' sessions (needs scopes)." },
3016
+ expires_at: { type: "string", description: "Optional ISO 8601 expiry." },
3017
+ confirm: {
3018
+ type: "boolean",
3019
+ description: "REQUIRED. Must be true - issues a credential shown once. Only set after explicit user confirmation of this exact action.",
3020
+ },
3021
+ },
3022
+ required: ["organization_id", "application_id", "confirm"],
3023
+ },
3024
+ },
2609
3025
  {
2610
3026
  name: "didit_org_list_api_keys",
2611
- description: "List API key metadata with raw key values redacted (pass application_id for an app's keys).",
2612
- inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS } },
3027
+ description: "List one application's API key metadata with raw key values redacted. API keys belong to an application, so application_id is required: read it from didit_context_get.",
3028
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS }, required: ["application_id"] },
2613
3029
  },
2614
3030
  // ── Compliance ──────────────────────────────────────────────────────
2615
3031
  ...(0, internal_tools_1.internalToolDefs)("compliance"),
@@ -2632,11 +3048,14 @@ function createServer(options = {}) {
2632
3048
  features: {
2633
3049
  type: "array",
2634
3050
  items: { type: "string" },
2635
- description: "ONLY the verification steps the user NAMED, by feature code (OCR, LIVENESS, FACE_MATCH, NFC, " +
3051
+ description: "The TRUNK: the steps EVERY session runs, by feature code (OCR, LIVENESS, FACE_MATCH, NFC, " +
2636
3052
  "PROOF_OF_ADDRESS, QUESTIONNAIRE, PHONE_VERIFICATION, EMAIL_VERIFICATION, AGE_ESTIMATION, " +
2637
3053
  "IP_ANALYSIS, AML, DATABASE_VALIDATION, DOCUMENT_AI; KYB: KYB_REGISTRY, KYB_DOCUMENTS, " +
2638
- "KYB_KEY_PEOPLE). NEVER add 'standard' steps uninvited ('only id verification' means OCR and " +
2639
- "nothing else); the builder itself adds true dependencies and orders the chain.",
3054
+ "KYB_KEY_PEOPLE). ONLY steps the user NAMED: NEVER add 'standard' steps uninvited ('only id " +
3055
+ "verification' means OCR and nothing else); the builder itself adds true dependencies and orders " +
3056
+ "the chain. A step only SOME countries take goes in that branch's features ONLY, never here too " +
3057
+ "('ID verification, then liveness and AML for UAE IDs, otherwise finish' = features [OCR] + " +
3058
+ "branches [{countries: ['UAE'], features: ['LIVENESS', 'AML']}]).",
2640
3059
  },
2641
3060
  countries: {
2642
3061
  type: "object",
@@ -2698,7 +3117,11 @@ function createServer(options = {}) {
2698
3117
  items: { type: "string" },
2699
3118
  description: "Countries exactly as the user named them (a name or ISO3 code per entry).",
2700
3119
  },
2701
- features: { type: "array", items: { type: "string" } },
3120
+ features: {
3121
+ type: "array",
3122
+ items: { type: "string" },
3123
+ description: "The steps ONLY these countries take, after the trunk's routing step. Never repeat a trunk step here.",
3124
+ },
2702
3125
  },
2703
3126
  required: ["countries", "features"],
2704
3127
  additionalProperties: false,
@@ -2725,8 +3148,13 @@ function createServer(options = {}) {
2725
3148
  // checkout / secret-reveal tools — the public app catalog must stay free of
2726
3149
  // credential-collection, checkout, and secret-reveal flows. Privileged (staff)
2727
3150
  // callers and local stdio setups keep the full catalog.
2728
- const hasUserBearer = Boolean(extra?.authInfo?.token || process.env.DIDIT_ACCESS_TOKEN);
2729
- let catalog = hasUserBearer && !isPrivileged ? tools.filter((t) => !HOSTED_APP_EXCLUDED_TOOLS.has(t.name)) : tools;
3151
+ // Only a remote (HTTP) request carries authInfo. A local stdio server started with
3152
+ // DIDIT_ACCESS_TOKEN is a local setup and keeps the full catalog, as documented; counting
3153
+ // that env token as a remote Bearer hid didit_org_top_up and the key reveal from it.
3154
+ const remoteBearer = Boolean(extra?.authInfo?.token);
3155
+ let catalog = remoteBearer && !isPrivileged
3156
+ ? tools.filter((t) => !HOSTED_APP_EXCLUDED_TOOLS.has(t.name) || (moneyTools && t.name === MONEY_TOOL))
3157
+ : tools;
2730
3158
  // Remote connectors authenticate with OAuth, so account credentials must never travel
2731
3159
  // through the conversation: hosted servers drop the bootstrap tools for EVERY caller
2732
3160
  // (staff included), regardless of Bearer state. They remain available on stdio.
@@ -2791,17 +3219,23 @@ function createServer(options = {}) {
2791
3219
  targetOrg: argOrg || tokenOrg,
2792
3220
  });
2793
3221
  const permissionCheck = permission === "would_deny" ? permission : undefined;
3222
+ // Local sign-in (device code): only a stdio server with no Bearer of its own reads the stored
3223
+ // credentials, so hosted mode and DIDIT_ACCESS_TOKEN setups are untouched.
3224
+ const storedToken = !authInfo?.token && !hosted && !process.env.DIDIT_ACCESS_TOKEN && !ACCOUNT_BOOTSTRAP_TOOLS.has(request.params.name)
3225
+ ? await storedDeviceLoginToken()
3226
+ : undefined;
2794
3227
  return config_1.requestContext.run({
2795
3228
  // Hosted mode: per-request Bearer from OAuth introspection. Stdio mode (tests/eval):
2796
3229
  // fall back to DIDIT_ACCESS_TOKEN + MCP_DEFAULT_ORG/APP env so the console-path tools
2797
3230
  // authenticate as that Bearer without the hosted layer.
2798
- accessToken: authInfo?.token || process.env.DIDIT_ACCESS_TOKEN || undefined,
3231
+ accessToken: authInfo?.token || process.env.DIDIT_ACCESS_TOKEN || storedToken || undefined,
2799
3232
  organizationId: argOrg ||
2800
3233
  authInfo?.extra?.organization_id ||
2801
3234
  process.env.MCP_DEFAULT_ORG ||
2802
3235
  undefined,
2803
3236
  applicationId: argApp || process.env.MCP_DEFAULT_APP || undefined,
2804
3237
  toolName: request.params.name,
3238
+ actorVia: (0, investigator_1.actorViaFromHeaders)(extra?.requestInfo?.headers),
2805
3239
  }, () => (0, audit_log_1.auditToolCall)({ tool: request.params.name, args: callArgs, authInfo, hosted, permissionCheck }, async () => {
2806
3240
  const { name } = request.params;
2807
3241
  // organization_id / application_id are ROUTING, consumed above into
@@ -2821,8 +3255,10 @@ function createServer(options = {}) {
2821
3255
  // ...but a handful of handlers take the routing ids as EXPLICIT PARAMETERS rather than
2822
3256
  // resolving them from requestContext, and the strip above hands them `undefined`:
2823
3257
  // the auth-service tools build their URL path from the argument (and the reveal tool
2824
- // deliberately refuses every context/env fallback), and the *_search tools use the ids to
2825
- // NARROW their fan-out. Re-attach only what the caller actually sent, and only for those.
3258
+ // deliberately refuses every context/env fallback), the *_search tools use the ids to
3259
+ // NARROW their fan-out, and the staff tools either build a URL path from organization_id
3260
+ // (the staff organization read) or filter by it (the staff warnings search and siblings).
3261
+ // Re-attach only what the caller actually sent, and only for those.
2826
3262
  const withRoutingIds = (a) => ({
2827
3263
  ...(a ?? {}),
2828
3264
  ...(argOrg ? { organization_id: argOrg } : {}),
@@ -2842,6 +3278,22 @@ function createServer(options = {}) {
2842
3278
  isError: true,
2843
3279
  };
2844
3280
  }
3281
+ // Mirror of the tools/list exclusion for the one money tool: a remote connector never creates
3282
+ // a payment page itself, even when a client calls the unlisted name. The person pays in the
3283
+ // console, through the link didit_org_get_balance returns.
3284
+ // saved_card moves money with no person present, so not even a staff caller gets it on an endpoint
3285
+ // that is not the payments one; staff keep the Checkout page they always had.
3286
+ if (hostedMoneyBlocked &&
3287
+ name === MONEY_TOOL &&
3288
+ (!(0, privileged_tools_1.isPrivilegedCaller)(authInfo, { hosted }) || callArgs?.payment_method === "saved_card")) {
3289
+ // A signed request link creates no payment and moves no money, so it is allowed here; best
3290
+ // effort, the static text below is the fallback.
3291
+ const signedUrl = await billing.signedTopUpLink(callArgs?.amount_in_dollars ?? callArgs?.amount, callArgs?.organization_id);
3292
+ const text = signedUrl
3293
+ ? `Top-ups are paid by the person in the Didit console. Give them this link: ${signedUrl} (it opens the top-up dialog with the amount filled in and says which agent asked; nothing is charged until they pay), or next_steps.automatic_top_up_url from didit_org_get_balance.`
3294
+ : "Top-ups are paid by the person in the Didit console. Call didit_org_get_balance and give them next_steps.top_up_url (the top-up dialog with the amount filled in) or next_steps.automatic_top_up_url.";
3295
+ return { content: [{ type: "text", text }], isError: true };
3296
+ }
2845
3297
  // Mirror of the tools/list catalog profile: a tool (or an input property) the endpoint does
2846
3298
  // not offer is refused even if the client memorised it from the full catalog.
2847
3299
  const profileRefusal = (0, chatgpt_app_1.catalogProfileRefusal)(profile, name, callArgs);
@@ -2866,11 +3318,16 @@ function createServer(options = {}) {
2866
3318
  // (same shape as the *_search sibling) instead of throwing, so the first call succeeds.
2867
3319
  const aggregate = aggregateFallbackFor(name);
2868
3320
  if ((0, privileged_tools_1.isPrivilegedToolName)(name)) {
2869
- result = await (0, privileged_tools_1.dispatchPrivilegedTool)(name, args);
3321
+ // Same re-attachment as the auth-service/*_search branches: the staff organization read builds
3322
+ // its URL path from organization_id, so the stripped args would always be undefined.
3323
+ result = await (0, privileged_tools_1.dispatchPrivilegedTool)(name, withRoutingIds(args));
2870
3324
  }
2871
3325
  else if ((0, internal_tools_1.isInternalToolName)(name)) {
2872
3326
  result = await (0, internal_tools_1.dispatchInternalTool)(name, args);
2873
3327
  }
3328
+ else if ((0, investigator_1.isInvestigatorToolName)(name)) {
3329
+ result = await (0, investigator_1.dispatchInvestigatorTool)(name, args);
3330
+ }
2874
3331
  else if (aggregate) {
2875
3332
  // Scope survives the fallback: when the org resolved but the app did not, span only
2876
3333
  // that org's apps rather than every org the caller can reach.
@@ -2895,6 +3352,12 @@ function createServer(options = {}) {
2895
3352
  case "didit_account_login":
2896
3353
  result = await auth.login(args.email, args.password);
2897
3354
  break;
3355
+ case "didit_account_device_login_start":
3356
+ result = await auth.deviceLoginStart();
3357
+ break;
3358
+ case "didit_account_device_login_poll":
3359
+ result = await auth.deviceLoginPoll();
3360
+ break;
2898
3361
  case "didit_account_verify_2fa":
2899
3362
  result = await auth.verify2fa(args.temp_token, args.code);
2900
3363
  break;
@@ -2943,6 +3406,14 @@ function createServer(options = {}) {
2943
3406
  case "didit_session_get_decision":
2944
3407
  result = await sessions.getSessionDecision(args.session_id);
2945
3408
  break;
3409
+ case "didit_session_get_location_evidence":
3410
+ result = await sessions.getSessionLocationEvidence(args.session_id);
3411
+ break;
3412
+ case "didit_session_simulate": {
3413
+ const { session_id, ...data } = args;
3414
+ result = await sessions.simulateSandboxSession(session_id, data);
3415
+ break;
3416
+ }
2946
3417
  case "didit_session_update_status": {
2947
3418
  const { session_id, ...data } = args;
2948
3419
  result = await sessions.updateSessionStatus(session_id, data);
@@ -2967,6 +3438,18 @@ function createServer(options = {}) {
2967
3438
  case "didit_session_generate_pdf":
2968
3439
  result = await sessions.generateSessionPdf(args.session_id);
2969
3440
  break;
3441
+ case "didit_session_get_signature_evidence":
3442
+ result = await sessions.getSignatureEvidence(args.session_id, args.node_id, args?.signature_id);
3443
+ break;
3444
+ case "didit_session_get_signed_document":
3445
+ result = await sessions.getSignedDocument(args.session_id, args.node_id, args.document_id);
3446
+ break;
3447
+ case "didit_session_get_signature_field_image":
3448
+ result = await sessions.getSignatureFieldImage(args.session_id, args.node_id, args.field_id);
3449
+ break;
3450
+ case "didit_session_validate_signatures":
3451
+ result = await sessions.validateSignatures(args.session_id, args.node_id, args?.signature_id);
3452
+ break;
2970
3453
  case "didit_session_list_reviews":
2971
3454
  result = await sessions.listSessionReviews(args.session_id);
2972
3455
  break;
@@ -2994,6 +3477,15 @@ function createServer(options = {}) {
2994
3477
  case "didit_session_create_import":
2995
3478
  result = await sessions.createImport(args);
2996
3479
  break;
3480
+ case "didit_session_list_import_providers":
3481
+ result = await sessions.listImportProviders();
3482
+ break;
3483
+ case "didit_session_check_import_provider":
3484
+ result = await sessions.checkImportProvider(args);
3485
+ break;
3486
+ case "didit_session_manage_import":
3487
+ result = await sessions.manageImport(args.import_id, args.action, args?.data);
3488
+ break;
2997
3489
  case "didit_session_get_import_template":
2998
3490
  result = await sessions.getImportTemplate();
2999
3491
  break;
@@ -3181,11 +3673,38 @@ function createServer(options = {}) {
3181
3673
  break;
3182
3674
  // Billing
3183
3675
  case "didit_org_get_balance":
3184
- result = await billing.getBalance(args?.organization_id);
3676
+ // The ChatGPT catalog carries no credit-purchase flow (app review), so no top-up links there.
3677
+ result = await billing.getBalance(args?.organization_id, {
3678
+ links: profile !== "chatgpt",
3679
+ // The agent top-up switch only where an agent may top up: /mcp/payments and stdio.
3680
+ agentTopUp: profile === "full" && !hostedMoneyBlocked,
3681
+ });
3185
3682
  break;
3186
3683
  case "didit_org_top_up":
3187
- result = await billing.topUp((args?.amount_in_dollars ?? args?.amount), args?.confirm, args?.success_url, args?.cancel_url);
3684
+ result = await billing.topUp((args?.amount_in_dollars ?? args?.amount), args?.confirm, args?.organization_id, { payment_method: args?.payment_method, idempotency_key: args?.idempotency_key });
3685
+ break;
3686
+ case "didit_billing_get_plan":
3687
+ result = await billing.getPlan(args?.organization_id);
3688
+ break;
3689
+ case "didit_billing_quote_plan":
3690
+ result = await billing.quotePlan(args?.plan, args?.billing_interval, args?.organization_id);
3691
+ break;
3692
+ case "didit_billing_list_payment_methods":
3693
+ result = await billing.listPaymentMethods(args?.organization_id);
3694
+ break;
3695
+ case "didit_billing_list_receipts":
3696
+ result = await billing.listReceipts(args?.organization_id, args?.limit, args?.offset);
3697
+ break;
3698
+ case "didit_billing_get_details":
3699
+ result = await billing.getBillingDetails(args?.organization_id);
3700
+ break;
3701
+ case "didit_billing_update_details": {
3702
+ // The dispatcher already moved organization_id into the request context (stripRoutingIds);
3703
+ // dropping it here too keeps the handler correct if that ever changes.
3704
+ const { organization_id: _org, application_id: _app, ...changes } = (args ?? {});
3705
+ result = await billing.updateBillingDetails(changes);
3188
3706
  break;
3707
+ }
3189
3708
  // Customization
3190
3709
  case "didit_branding_get":
3191
3710
  result = await customization.getCustomization();
@@ -3260,6 +3779,11 @@ function createServer(options = {}) {
3260
3779
  result = await standalone.poaVerification({ path: document_image_path, base64: document_image_base64 }, poaOpts);
3261
3780
  break;
3262
3781
  }
3782
+ case "didit_verify_account_check": {
3783
+ const { organization_id: _o, application_id: _a, ...body } = args;
3784
+ result = await standalone.accountCheck(body);
3785
+ break;
3786
+ }
3263
3787
  case "didit_verify_database":
3264
3788
  result = await standalone.databaseValidation(args);
3265
3789
  break;
@@ -3352,7 +3876,8 @@ function createServer(options = {}) {
3352
3876
  break;
3353
3877
  // Audit logs + alerts
3354
3878
  case "didit_audit_log_list":
3355
- result = await observability.listAuditLogs(args);
3879
+ // application_id is a filter of the organization's audit log, not routing.
3880
+ result = await observability.listAuditLogs(withRoutingIds(args));
3356
3881
  break;
3357
3882
  case "didit_alert_list":
3358
3883
  result = await observability.listAlerts(args);
@@ -3377,7 +3902,11 @@ function createServer(options = {}) {
3377
3902
  result = await members.listRoles(args?.organization_id);
3378
3903
  break;
3379
3904
  case "didit_org_list_api_keys":
3380
- result = await members.listApiKeys(args?.organization_id, args?.application_id);
3905
+ // Routing ids are stripped from args above; the ones the caller sent are argOrg / argApp.
3906
+ result = await members.listApiKeys(argOrg, argApp);
3907
+ break;
3908
+ case "didit_org_create_api_key":
3909
+ result = await members.createApiKey(argOrg, argApp, (args ?? {}));
3381
3910
  break;
3382
3911
  // Compliance
3383
3912
  case "didit_workflow_build_graph":
@@ -3412,8 +3941,10 @@ function createServer(options = {}) {
3412
3941
  const fieldLine = shape.field ? `\nField: ${shape.field}` : "";
3413
3942
  const hintLine = shape.hint ? `\nHint: ${shape.hint}` : "";
3414
3943
  const allowedLine = shape.allowed && shape.allowed.length ? `\nAllowed: ${shape.allowed.join(", ")}` : "";
3944
+ // A backend refusal that names where a person finishes the action (agent top-ups) passes it on unchanged.
3945
+ const nextStepLine = shape.next_step ? `\nNext step: ${JSON.stringify(shape.next_step)}` : "";
3415
3946
  return {
3416
- content: [{ type: "text", text: `Error [${shape.code}]: ${shape.message}${fieldLine}${hintLine}${allowedLine}` }],
3947
+ content: [{ type: "text", text: `Error [${shape.code}]: ${shape.message}${fieldLine}${hintLine}${allowedLine}${nextStepLine}` }],
3417
3948
  isError: true,
3418
3949
  };
3419
3950
  }
@@ -3421,7 +3952,24 @@ function createServer(options = {}) {
3421
3952
  });
3422
3953
  return server;
3423
3954
  }
3955
+ // Never throws: a revoked grant is reported once on stderr and the tool then fails like any
3956
+ // unauthenticated call. The message carries no token.
3957
+ async function storedDeviceLoginToken() {
3958
+ try {
3959
+ return await (0, device_login_1.getStoredAccessToken)();
3960
+ }
3961
+ catch (err) {
3962
+ if (err instanceof device_login_1.DeviceLoginError)
3963
+ console.error(`Didit: ${err.message}`);
3964
+ return undefined;
3965
+ }
3966
+ }
3424
3967
  async function main() {
3968
+ const cliCommand = (0, login_cli_1.loginCliCommand)(process.argv.slice(2));
3969
+ if (cliCommand) {
3970
+ process.exitCode = await (0, login_cli_1.runLoginCli)(cliCommand);
3971
+ return;
3972
+ }
3425
3973
  const transport = new stdio_js_1.StdioServerTransport();
3426
3974
  const server = createServer({ profile: (0, chatgpt_app_1.stdioCatalogProfile)() });
3427
3975
  await server.connect(transport);