@didit-protocol/mcp-server 4.0.0 → 5.1.34

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 (170) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +583 -227
  3. package/dist/audit-log.d.ts +22 -0
  4. package/dist/audit-log.d.ts.map +1 -0
  5. package/dist/audit-log.js +77 -0
  6. package/dist/audit-log.js.map +1 -0
  7. package/dist/auth/introspection-verifier.d.ts +16 -0
  8. package/dist/auth/introspection-verifier.d.ts.map +1 -0
  9. package/dist/auth/introspection-verifier.js +77 -0
  10. package/dist/auth/introspection-verifier.js.map +1 -0
  11. package/dist/auth/verifier.d.ts +19 -0
  12. package/dist/auth/verifier.d.ts.map +1 -0
  13. package/dist/auth/verifier.js +88 -0
  14. package/dist/auth/verifier.js.map +1 -0
  15. package/dist/blank-args.d.ts +10 -0
  16. package/dist/blank-args.d.ts.map +1 -0
  17. package/dist/blank-args.js +34 -0
  18. package/dist/blank-args.js.map +1 -0
  19. package/dist/chatgpt-app.d.ts +44 -0
  20. package/dist/chatgpt-app.d.ts.map +1 -0
  21. package/dist/chatgpt-app.js +52 -0
  22. package/dist/chatgpt-app.js.map +1 -0
  23. package/dist/config.d.ts +93 -5
  24. package/dist/config.d.ts.map +1 -1
  25. package/dist/config.js +198 -27
  26. package/dist/config.js.map +1 -1
  27. package/dist/dates.d.ts +2 -0
  28. package/dist/dates.d.ts.map +1 -0
  29. package/dist/dates.js +23 -0
  30. package/dist/dates.js.map +1 -0
  31. package/dist/feature-config-schema.d.ts +66 -0
  32. package/dist/feature-config-schema.d.ts.map +1 -0
  33. package/dist/feature-config-schema.js +192 -0
  34. package/dist/feature-config-schema.js.map +1 -0
  35. package/dist/http.d.ts +4 -0
  36. package/dist/http.d.ts.map +1 -0
  37. package/dist/http.js +230 -0
  38. package/dist/http.js.map +1 -0
  39. package/dist/index.d.ts +20 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +2397 -510
  42. package/dist/index.js.map +1 -1
  43. package/dist/internal-tools.d.ts +17 -0
  44. package/dist/internal-tools.d.ts.map +1 -0
  45. package/dist/internal-tools.js +26 -0
  46. package/dist/internal-tools.js.map +1 -0
  47. package/dist/mcp-modern.d.ts +36 -0
  48. package/dist/mcp-modern.d.ts.map +1 -0
  49. package/dist/mcp-modern.js +152 -0
  50. package/dist/mcp-modern.js.map +1 -0
  51. package/dist/orgapp.d.ts +34 -0
  52. package/dist/orgapp.d.ts.map +1 -0
  53. package/dist/orgapp.js +93 -0
  54. package/dist/orgapp.js.map +1 -0
  55. package/dist/permissions.d.ts +24 -0
  56. package/dist/permissions.d.ts.map +1 -0
  57. package/dist/permissions.js +210 -0
  58. package/dist/permissions.js.map +1 -0
  59. package/dist/privileged-tools.d.ts +14 -0
  60. package/dist/privileged-tools.d.ts.map +1 -0
  61. package/dist/privileged-tools.js +21 -0
  62. package/dist/privileged-tools.js.map +1 -0
  63. package/dist/schema/feature-config-schema.json +4446 -0
  64. package/dist/security.d.ts +168 -0
  65. package/dist/security.d.ts.map +1 -0
  66. package/dist/security.js +858 -0
  67. package/dist/security.js.map +1 -0
  68. package/dist/session-pdf-download.d.ts +8 -0
  69. package/dist/session-pdf-download.d.ts.map +1 -0
  70. package/dist/session-pdf-download.js +91 -0
  71. package/dist/session-pdf-download.js.map +1 -0
  72. package/dist/tools/analytics.d.ts +13 -0
  73. package/dist/tools/analytics.d.ts.map +1 -0
  74. package/dist/tools/analytics.js +171 -0
  75. package/dist/tools/analytics.js.map +1 -0
  76. package/dist/tools/auth.d.ts +10 -3
  77. package/dist/tools/auth.d.ts.map +1 -1
  78. package/dist/tools/auth.js +68 -11
  79. package/dist/tools/auth.js.map +1 -1
  80. package/dist/tools/billing.d.ts +2 -2
  81. package/dist/tools/billing.d.ts.map +1 -1
  82. package/dist/tools/billing.js +37 -4
  83. package/dist/tools/billing.js.map +1 -1
  84. package/dist/tools/blocklist.d.ts +5 -0
  85. package/dist/tools/blocklist.d.ts.map +1 -0
  86. package/dist/tools/blocklist.js +21 -0
  87. package/dist/tools/blocklist.js.map +1 -0
  88. package/dist/tools/businesses.d.ts +1 -1
  89. package/dist/tools/businesses.d.ts.map +1 -1
  90. package/dist/tools/businesses.js +31 -9
  91. package/dist/tools/businesses.js.map +1 -1
  92. package/dist/tools/cases.d.ts +6 -0
  93. package/dist/tools/cases.d.ts.map +1 -0
  94. package/dist/tools/cases.js +63 -0
  95. package/dist/tools/cases.js.map +1 -0
  96. package/dist/tools/compliance.d.ts +8 -0
  97. package/dist/tools/compliance.d.ts.map +1 -0
  98. package/dist/tools/compliance.js +95 -0
  99. package/dist/tools/compliance.js.map +1 -0
  100. package/dist/tools/context.d.ts +2 -0
  101. package/dist/tools/context.d.ts.map +1 -0
  102. package/dist/tools/context.js +37 -0
  103. package/dist/tools/context.js.map +1 -0
  104. package/dist/tools/customization.d.ts +10 -4
  105. package/dist/tools/customization.d.ts.map +1 -1
  106. package/dist/tools/customization.js +21 -11
  107. package/dist/tools/customization.js.map +1 -1
  108. package/dist/tools/feature-config.d.ts +53 -0
  109. package/dist/tools/feature-config.d.ts.map +1 -0
  110. package/dist/tools/feature-config.js +432 -0
  111. package/dist/tools/feature-config.js.map +1 -0
  112. package/dist/tools/lists.d.ts.map +1 -1
  113. package/dist/tools/lists.js +17 -16
  114. package/dist/tools/lists.js.map +1 -1
  115. package/dist/tools/members.d.ts +7 -0
  116. package/dist/tools/members.d.ts.map +1 -0
  117. package/dist/tools/members.js +60 -0
  118. package/dist/tools/members.js.map +1 -0
  119. package/dist/tools/observability.d.ts +4 -0
  120. package/dist/tools/observability.d.ts.map +1 -0
  121. package/dist/tools/observability.js +17 -0
  122. package/dist/tools/observability.js.map +1 -0
  123. package/dist/tools/questionnaires.d.ts +62 -3
  124. package/dist/tools/questionnaires.d.ts.map +1 -1
  125. package/dist/tools/questionnaires.js +131 -6
  126. package/dist/tools/questionnaires.js.map +1 -1
  127. package/dist/tools/reports.d.ts +5 -0
  128. package/dist/tools/reports.d.ts.map +1 -0
  129. package/dist/tools/reports.js +89 -0
  130. package/dist/tools/reports.js.map +1 -0
  131. package/dist/tools/search.d.ts +30 -0
  132. package/dist/tools/search.d.ts.map +1 -0
  133. package/dist/tools/search.js +317 -0
  134. package/dist/tools/search.js.map +1 -0
  135. package/dist/tools/session-explain-levers.d.ts +17 -0
  136. package/dist/tools/session-explain-levers.d.ts.map +1 -0
  137. package/dist/tools/session-explain-levers.js +139 -0
  138. package/dist/tools/session-explain-levers.js.map +1 -0
  139. package/dist/tools/session-explain.d.ts +3 -0
  140. package/dist/tools/session-explain.d.ts.map +1 -0
  141. package/dist/tools/session-explain.js +180 -0
  142. package/dist/tools/session-explain.js.map +1 -0
  143. package/dist/tools/sessions.d.ts +9 -2
  144. package/dist/tools/sessions.d.ts.map +1 -1
  145. package/dist/tools/sessions.js +131 -22
  146. package/dist/tools/sessions.js.map +1 -1
  147. package/dist/tools/settings.d.ts +15 -1
  148. package/dist/tools/settings.d.ts.map +1 -1
  149. package/dist/tools/settings.js +143 -6
  150. package/dist/tools/settings.js.map +1 -1
  151. package/dist/tools/standalone.d.ts +7 -6
  152. package/dist/tools/standalone.d.ts.map +1 -1
  153. package/dist/tools/standalone.js +41 -26
  154. package/dist/tools/standalone.js.map +1 -1
  155. package/dist/tools/transactions.d.ts +9 -0
  156. package/dist/tools/transactions.d.ts.map +1 -1
  157. package/dist/tools/transactions.js +77 -4
  158. package/dist/tools/transactions.js.map +1 -1
  159. package/dist/tools/users.d.ts +1 -1
  160. package/dist/tools/users.d.ts.map +1 -1
  161. package/dist/tools/users.js +30 -9
  162. package/dist/tools/users.js.map +1 -1
  163. package/dist/tools/webhooks.d.ts.map +1 -1
  164. package/dist/tools/webhooks.js +22 -5
  165. package/dist/tools/webhooks.js.map +1 -1
  166. package/dist/tools/workflow-graph.d.ts +65 -0
  167. package/dist/tools/workflow-graph.d.ts.map +1 -0
  168. package/dist/tools/workflow-graph.js +686 -0
  169. package/dist/tools/workflow-graph.js.map +1 -0
  170. package/package.json +23 -6
package/dist/index.js CHANGED
@@ -34,11 +34,13 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  };
35
35
  })();
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.createServer = createServer;
37
38
  const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
38
39
  const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
39
40
  const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
40
41
  const auth = __importStar(require("./tools/auth"));
41
42
  const sessions = __importStar(require("./tools/sessions"));
43
+ const session_explain_1 = require("./tools/session-explain");
42
44
  const settings = __importStar(require("./tools/settings"));
43
45
  const billing = __importStar(require("./tools/billing"));
44
46
  const users = __importStar(require("./tools/users"));
@@ -49,15 +51,26 @@ const webhooks = __importStar(require("./tools/webhooks"));
49
51
  const questionnaires = __importStar(require("./tools/questionnaires"));
50
52
  const lists = __importStar(require("./tools/lists"));
51
53
  const standalone = __importStar(require("./tools/standalone"));
52
- // Single source of truth for the version: package.json (falls back if unreadable).
53
- let SERVER_VERSION = "4.0.0";
54
- try {
55
- // eslint-disable-next-line @typescript-eslint/no-var-requires
56
- SERVER_VERSION = require("../package.json").version || SERVER_VERSION;
57
- }
58
- catch {
59
- /* keep fallback */
60
- }
54
+ const privileged_tools_1 = require("./privileged-tools");
55
+ const internal_tools_1 = require("./internal-tools");
56
+ const blocklist = __importStar(require("./tools/blocklist"));
57
+ const cases = __importStar(require("./tools/cases"));
58
+ const reports = __importStar(require("./tools/reports"));
59
+ const observability = __importStar(require("./tools/observability"));
60
+ const members = __importStar(require("./tools/members"));
61
+ const context = __importStar(require("./tools/context"));
62
+ const search = __importStar(require("./tools/search"));
63
+ const workflowGraph = __importStar(require("./tools/workflow-graph"));
64
+ const feature_config_schema_1 = require("./feature-config-schema");
65
+ const analytics = __importStar(require("./tools/analytics"));
66
+ const compliance = __importStar(require("./tools/compliance"));
67
+ const config_1 = require("./config");
68
+ const blank_args_1 = require("./blank-args");
69
+ const chatgpt_app_1 = require("./chatgpt-app");
70
+ const orgapp_1 = require("./orgapp");
71
+ const security_1 = require("./security");
72
+ const audit_log_1 = require("./audit-log");
73
+ const permissions_1 = require("./permissions");
61
74
  const SESSION_STATUSES = "Not Started, In Progress, In Review, Approved, Declined, Expired, Abandoned, Kyc Expired, Resubmitted, Awaiting User";
62
75
  const LANGUAGE_CODES = [
63
76
  "en", "ar", "bg", "bn", "bs", "ca", "cnr", "cs", "da", "de", "el", "es", "et",
@@ -72,30 +85,578 @@ const LIST_ENTRY_TYPES = [
72
85
  "face", "document", "phone", "email", "ip_address", "device_fingerprint",
73
86
  "wallet_address", "bank_account", "user", "business", "country", "key",
74
87
  ];
75
- const WORKFLOW_FEATURES = [
76
- "OCR", "NFC", "LIVENESS", "FACE_MATCH", "PROOF_OF_ADDRESS", "QUESTIONNAIRE",
77
- "PHONE_VERIFICATION", "EMAIL_VERIFICATION", "DATABASE_VALIDATION", "AML",
78
- "IP_ANALYSIS", "AGE_ESTIMATION", "KYB_REGISTRY", "KYB_DOCUMENTS", "KYB_KEY_PEOPLE",
88
+ // Real backend FormElementType (questionnaires/config/choices.py) — uppercase.
89
+ const FORM_ELEMENT_TYPES = [
90
+ "SHORT_TEXT", "LONG_TEXT", "PARAGRAPH", "DROPDOWN", "SINGLE_CHOICE", "MULTIPLE_CHOICE",
91
+ "NUMBER", "IMAGE", "FILE_UPLOAD", "TIME", "EMAIL", "ADDRESS", "PHONE", "COUNTRY",
92
+ "DATE_PICKER", "CONSENT", "SECTION_HEADER", "SEPARATOR", "HEADING", "REPEATABLE_GROUP",
79
93
  ];
94
+ const QUESTIONNAIRE_LANG_PROPS = {
95
+ languages: {
96
+ type: "array",
97
+ items: { type: "string" },
98
+ description: "Locales the questionnaire is offered in. Defaults to [\"en\"]; \"en\" must always be included.",
99
+ },
100
+ default_language: { type: "string", description: "Locale shown by default (must be in `languages`). Defaults to the first language." },
101
+ };
102
+ // A create with no status publishes immediately (backend QuestionnaireCreateSerializer.create),
103
+ // while an update with no status edits in place and never publishes — so the two tools must not
104
+ // advertise the same `status` wording.
105
+ const QUESTIONNAIRE_CREATE_STATUS_PROP = {
106
+ status: { type: "string", enum: ["draft", "published"], description: "Omit to publish immediately; 'draft' saves without publishing." },
107
+ };
108
+ const QUESTIONNAIRE_UPDATE_STATUS_PROP = {
109
+ status: {
110
+ type: "string",
111
+ enum: ["draft", "published"],
112
+ description: "Omit to edit in place without changing the published state; 'draft' saves without publishing; 'published' publishes (a draft goes live, a published questionnaire gets a new published version).",
113
+ },
114
+ };
115
+ const FORM_ELEMENTS_PROP = {
116
+ form_elements: {
117
+ type: "array",
118
+ description: "REQUIRED. Array of form-element objects, in the order the user answers them. Each: { element_type (uppercase, one of the allowed types), title (a plain string, or an object of locale→string e.g. {\"en\":\"Your name\"}), is_required (bool), placeholder (hint text), and for choice types a `choices` array }. A per-question hint goes in `placeholder`: `description` is only accepted on HEADING, SECTION_HEADER and PARAGRAPH elements.",
119
+ items: {
120
+ type: "object",
121
+ properties: {
122
+ element_type: { type: "string", enum: FORM_ELEMENT_TYPES, description: "Element type (UPPERCASE)" },
123
+ title: { type: "object", description: "Locale → label, e.g. {\"en\":\"Question text\"}" },
124
+ is_required: { type: "boolean" },
125
+ choices: { type: "array", items: { type: "object" }, description: "Options for DROPDOWN/SINGLE_CHOICE/MULTIPLE_CHOICE. Each: { value, label?, requires_text_input? }" },
126
+ },
127
+ required: ["element_type"],
128
+ },
129
+ },
130
+ };
80
131
  const WORKFLOW_FEATURE_ITEM = {
81
132
  type: "object",
82
133
  properties: {
83
- feature: { type: "string", enum: WORKFLOW_FEATURES, description: "Feature to run (uppercase)" },
84
- config: { type: "object", description: "Feature-specific settings (e.g. face_liveness_method, questionnaire_uuid, documents_allowed)" },
134
+ feature: { type: "string", enum: feature_config_schema_1.WORKFLOW_FEATURES, description: "Feature to run (uppercase)" },
135
+ config: {
136
+ type: "object",
137
+ description: (0, feature_config_schema_1.renderFeatureItemReference)() +
138
+ "\n\nThe MCP normalizes the allow-lists for you before it saves: documents_allowed / " +
139
+ "poa_documents_allowed accept a plain doc-type array ([\"PASSPORT\"] = passport-only, any " +
140
+ "country), doc NAMES (PASSPORT/ID/DRIVER_LICENSE/RESIDENCE_PERMIT) as well as codes " +
141
+ "(P/ID/DL/RP), scalar flags, and an \"ALL\" country key - all of it becomes the canonical " +
142
+ "{ISO3:{CODE:{enabled:1}}}. poa_languages_allowed likewise accepts a language array " +
143
+ "([\"es\"]) or a map ({\"es\":1}). Omit an allow-list to accept everything.",
144
+ },
85
145
  label: { type: "string", description: "Optional internal node label" },
86
146
  },
87
147
  required: ["feature"],
88
148
  };
89
- const server = new index_js_1.Server({ name: "didit", version: SERVER_VERSION }, { capabilities: { tools: {} } });
90
- // ---------------------------------------------------------------------------
91
- // Tool definitions
92
- // ---------------------------------------------------------------------------
93
- server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
94
- tools: [
149
+ // Graph (node/branching) workflows — the real structure the console uses (the flat `features`
150
+ // list above can't express branches, conditions, or Document AI). Enums mirror the backend
151
+ // (workflow_graph_choices.py). A graph is { start_node, nodes: { id: node } }.
152
+ const WORKFLOW_NODE_TYPES = ["feature", "action", "branch", "status", "webhook"];
153
+ const WORKFLOW_OPERATORS = [
154
+ "equals", "not_equals", "greater_than", "greater_than_or_equals", "less_than",
155
+ "less_than_or_equals", "contains", "not_contains", "in", "not_in", "is_empty",
156
+ "is_not_empty", "regex", "fuzzy_match",
157
+ ];
158
+ const WORKFLOW_SESSION_STATUSES = ["Approved", "Declined", "In Review", "Determine"];
159
+ const WORKFLOW_GRAPH_SCHEMA = {
160
+ type: "object",
161
+ description:
162
+ // Graph STRUCTURE - node shapes, branch semantics, ordering. This is MCP and
163
+ // backend behaviour, not the feature-config contract, so it stays prose.
164
+ "Node/branching workflow graph: { start_node, nodes }. `start_node` is the id of the entry " +
165
+ "node (must be a feature node). `nodes` maps nodeId → node. Node shapes: " +
166
+ "feature = {node_type:'feature', feature:<UPPERCASE, e.g. OCR|DOCUMENT_AI>, config?:{}, next?:<id>, branches?:[]}; " +
167
+ "branch = {node_type:'branch', branches:[{id, logic:'and'|'or', rules:[{field, operator, value, score?}], goto:<id>}], next?:<id fallback>}; " +
168
+ "status (TERMINAL) = {node_type:'status', session_status:'Approved'|'Declined'|'In Review'|'Determine'}. " +
169
+ "Branches are evaluated in order, first match wins; an empty rules:[] is the else/catch-all (kept last). " +
170
+ "Operators include `fuzzy_match` (string fields only, needs a `score` 0-100). Reference a feature's outcome " +
171
+ "with e.g. kyc.status / document_ai.status / bank.status, and an extracted value with kyc.extra_fields.profession. " +
172
+ "Each rule's `node_id` (the feature node that produces its field) is auto-filled for you — only set it " +
173
+ "(or use the `field@node_id` form) to disambiguate when the graph has several nodes of the same feature. " +
174
+ // Allow-list NORMALIZATION is something this server does on the way out, so it
175
+ // is not in the backend contract and has to be stated here.
176
+ "Allow-list shorthands the MCP normalizes for you before saving: documents_allowed / poa_documents_allowed " +
177
+ "accept a doc-type array ([\"PASSPORT\"] = passport-only, any country), doc NAMES " +
178
+ "(PASSPORT/ID/DRIVER_LICENSE/RESIDENCE_PERMIT) as well as codes (P/ID/DL/RP), scalar flags, and an \"ALL\" " +
179
+ "country key — every form becomes the canonical {ISO3:{CODE:{enabled:1}}}. poa_languages_allowed accepts a " +
180
+ "language array ([\"es\"]) or a map ({\"es\":1}). Omit an allow-list to accept everything. " +
181
+ // The KYC/KYB rule is a graph-level constraint, not a per-key one.
182
+ "KYC vs KYB: a graph is EITHER a person (KYC) workflow OR a business (KYB) workflow — never both, and the choice follows WHO is verified (a company → KYB, a person → KYC). A graph using any KYB feature (KYB_REGISTRY/KYB_DOCUMENTS/KYB_KEY_PEOPLE) may only also use DOCUMENT_AI, AML, QUESTIONNAIRE, PHONE_VERIFICATION, EMAIL_VERIFICATION, IP_ANALYSIS, BANK_VERIFICATION; it must NOT include person/KYC-only features (OCR, LIVENESS, FACE_MATCH, NFC, PROOF_OF_ADDRESS, DATABASE_VALIDATION, AGE_ESTIMATION). Company paperwork (incorporation, ownership, source of funds, business address) belongs in KYB_DOCUMENTS or DOCUMENT_AI on the KYB graph — never rebuild it as a KYC workflow. To verify the people behind a company (UBOs, officers, shareholders), build a SEPARATE KYC workflow and reference it from the KYB_KEY_PEOPLE node config (kyb_ubo_verification_workflow / kyb_officer_verification_workflow / kyb_shareholder_verification_workflow). Mixing the two is rejected by validation. " +
183
+ "Validate with didit_workflow_validate_graph before didit_workflow_set_graph. Get valid fields/operators from didit_workflow_get_field_definitions.\n\n" +
184
+ // Everything a feature node's `config` accepts, generated from the backend
185
+ // serializers. Never hand-written: that is how DATABASE_VALIDATION came to be
186
+ // documented nowhere while DOCUMENT_AI had four paragraphs.
187
+ (0, feature_config_schema_1.renderToolSchemaReference)(),
188
+ properties: {
189
+ start_node: { type: "string", description: "Entry node id (a feature node)." },
190
+ nodes: { type: "object", description: "Map of nodeId → node object (see the node shapes above)." },
191
+ },
192
+ required: ["start_node", "nodes"],
193
+ };
194
+ // Transaction-monitoring (KYT) rule schemas. These mirror the engine-facing
195
+ // fields in service-didit-verification's TransactionRule serializers. The MCP
196
+ // deliberately requires an explicit aggregation window even though the backend
197
+ // defaults an omitted window to 1d: a silent one-day default is unsafe when an
198
+ // agent is authoring a velocity rule for another period.
199
+ const RULE_CONDITION_OPERATORS = [
200
+ "eq", "ne", "gt", "gte", "lt", "lte", "in", "not_in", "contains", "not_contains",
201
+ "contains_any", "regex", "fuzzy_match", "exists", "is_not_empty", "is_not_null",
202
+ "not_exists", "is_empty", "is_null",
203
+ ];
204
+ const RULE_CONDITION_ITEM = {
205
+ type: "object",
206
+ properties: {
207
+ field: {
208
+ type: "string",
209
+ description: "Field path from the transaction field catalog, e.g. amount, currency, direction, action_type, score, " +
210
+ "transaction_type, subject_country, counterparty_country, subject_vendor_data, subject_device_fingerprint, " +
211
+ "subject_payment_method_type, travel_rule_status, travel_rule_required, tags, " +
212
+ "subject_days_since_previous_transaction, or custom_values.<key> (a key submitted as custom_properties). " +
213
+ "Country codes, travel_rule_status, and payment_method_type are normalized before comparison.",
214
+ },
215
+ operator: {
216
+ type: "string",
217
+ enum: RULE_CONDITION_OPERATORS,
218
+ description: "in/not_in accept a scalar or list; a scalar is treated as a one-item membership set. " +
219
+ "contains/not_contains are case-insensitive substring matches. contains_any requires a list of strings. " +
220
+ "regex safely matches value (the pattern) against the field. fuzzy_match requires score (0-100). " +
221
+ "gt/gte/lt/lte are false when either side is null or not comparable. exists/is_not_empty/is_not_null " +
222
+ "are presence aliases; not_exists/is_empty/is_null are their negation and ignore value.",
223
+ },
224
+ value: {
225
+ description: "Comparison value; its shape depends on operator and value_type. Omit for presence operators.",
226
+ },
227
+ value_type: {
228
+ type: "string",
229
+ enum: ["list", "field", "relative_date"],
230
+ description: "list: value is a List UUID and its entries become the comparison set. field: value is another field path. " +
231
+ "relative_date: value is resolved as a relative date expression. Omit for a literal value.",
232
+ },
233
+ score: {
234
+ type: "number",
235
+ minimum: 0,
236
+ maximum: 100,
237
+ description: "Required match threshold when operator is fuzzy_match.",
238
+ },
239
+ group_index: {
240
+ type: "integer",
241
+ description: "Setting group_index on any condition switches the entire condition list to grouped evaluation.",
242
+ },
243
+ group_logic: {
244
+ type: "string",
245
+ enum: ["AND", "OR"],
246
+ description: "Combines conditions within a group. Default AND.",
247
+ },
248
+ groups_logic: {
249
+ type: "string",
250
+ enum: ["AND", "OR"],
251
+ description: "Combines group outcomes; only the first condition's value is used. Default OR. Grouped evaluation " +
252
+ "overrides evaluation_mode.",
253
+ },
254
+ },
255
+ required: ["field", "operator"],
256
+ };
257
+ const RULE_AGGREGATION_ITEM = {
258
+ type: "object",
259
+ description: "One historical velocity check. Every aggregation entry on a rule must match (AND), regardless of " +
260
+ "evaluation_mode. The window is required by the MCP so it cannot silently fall back to the backend's 1d default.",
261
+ properties: {
262
+ metric: {
263
+ type: "string",
264
+ enum: ["count", "sum", "max", "min", "avg", "distinct_count", "unique_count"],
265
+ description: "unique_count is an alias of distinct_count.",
266
+ },
267
+ field: {
268
+ type: "string",
269
+ description: "Numeric or identity field to aggregate. Defaults to amount; ignored for count.",
270
+ },
271
+ operator: {
272
+ type: "string",
273
+ enum: ["eq", "ne", "gt", "gte", "lt", "lte"],
274
+ description: "Comparison of the computed metric against value.",
275
+ },
276
+ value: { type: "number", description: "Threshold the computed metric is compared against." },
277
+ window: {
278
+ type: "string",
279
+ pattern: "^\\d+[mhd]$",
280
+ description: "REQUIRED. Velocity window: '<N>m' (minutes, not months), '<N>h' (hours), or '<N>d' (days).",
281
+ },
282
+ filters: {
283
+ type: "object",
284
+ description: "Restricts the same-app historical transactions counted inside the window. A value of '__current__' " +
285
+ "resolves to that field's value on the transaction being evaluated, e.g. " +
286
+ "{subject_vendor_data:'__current__'} counts the same subject only. An array means membership.",
287
+ },
288
+ },
289
+ required: ["metric", "operator", "value", "window"],
290
+ };
291
+ const RULE_SCOPE_SCHEMA = {
292
+ type: "object",
293
+ description: "Restricts which transactions are considered. Empty or omitted lists mean no restriction. Transaction type " +
294
+ "aliases such as travelRule are normalized by the engine.",
295
+ properties: {
296
+ transaction_types: {
297
+ type: "array",
298
+ items: { type: "string" },
299
+ description: "Examples: finance, kyc, travel_rule, user_event, audit_trail_event, gambling_bet, " +
300
+ "gambling_limit_change, gambling_bonus_change.",
301
+ },
302
+ directions: { type: "array", items: { type: "string", enum: ["INBOUND", "OUTBOUND"] } },
303
+ action_types: {
304
+ type: "array",
305
+ items: { type: "string" },
306
+ description: "Application-specific action types, e.g. withdrawal or deposit.",
307
+ },
308
+ },
309
+ };
310
+ const RULE_ACTION_ITEM = {
311
+ type: "object",
312
+ description: "One action. All actions on a match run together; TEST-mode rules record the match but skip every action. " +
313
+ "Shapes: add_score {type,value:<integer>}; change_status {type,value:'IN_REVIEW'|'DECLINED'|" +
314
+ "'AWAITING_USER'|'APPROVED',workflow_id?}, where AWAITING_USER requires workflow_id; add_tags " +
315
+ "{type,tag_uuid? or tag_name?,tag_color?}; add_note {type,note}; add_to_list {type,list_id}; open_case " +
316
+ "{type,blueprint?,grouping?,attach_matched_transaction?}. Only the first open_case action is applied.",
317
+ properties: {
318
+ type: {
319
+ type: "string",
320
+ enum: ["add_score", "change_status", "add_tags", "add_note", "add_to_list", "open_case"],
321
+ },
322
+ value: { description: "add_score delta, or change_status target (alias: status)." },
323
+ workflow_id: {
324
+ type: "string",
325
+ description: "change_status only; required when value is AWAITING_USER.",
326
+ },
327
+ tag_uuid: { type: "string", description: "add_tags only." },
328
+ tag_name: { type: "string", description: "add_tags only; the backend uppercases it." },
329
+ tag_color: { type: "string", description: "add_tags only, e.g. #FF0000." },
330
+ note: { type: "string", description: "add_note only (alias: value)." },
331
+ list_id: { type: "string", description: "add_to_list only; UUID of the target List." },
332
+ blueprint: { type: "string", description: "open_case only; case blueprint UUID." },
333
+ grouping: {
334
+ type: "string",
335
+ enum: ["by_applicant", "by_rule_and_applicant"],
336
+ description: "open_case only.",
337
+ },
338
+ attach_matched_transaction: { type: "boolean", description: "open_case only." },
339
+ },
340
+ required: ["type"],
341
+ };
342
+ const RULE_CONDITIONS_PROP = {
343
+ conditions: {
344
+ type: "array",
345
+ items: RULE_CONDITION_ITEM,
346
+ description: "Conditions persisted on the rule, combined by evaluation_mode unless grouped.",
347
+ },
348
+ };
349
+ const RULE_AGGREGATION_PROP = {
350
+ aggregation: {
351
+ type: "array",
352
+ items: RULE_AGGREGATION_ITEM,
353
+ description: "Velocity checks persisted on the rule. Include them on create/update; putting them only in backtest does not save them.",
354
+ },
355
+ };
356
+ const RULE_ACTIONS_PROP = {
357
+ actions: {
358
+ type: "array",
359
+ items: RULE_ACTION_ITEM,
360
+ description: "Actions persisted on the rule. Include every action the user requested on create/update; backtest never saves actions.",
361
+ },
362
+ };
363
+ const RULE_EVALUATION_MODE_PROP = {
364
+ evaluation_mode: {
365
+ type: "string",
366
+ enum: ["ALL", "ANY"],
367
+ description: "How flat conditions combine when no condition has group_index. Default ALL. This is not TEST/ACTIVE mode.",
368
+ },
369
+ };
370
+ const RULE_SCOPE_PROP = { scope: RULE_SCOPE_SCHEMA };
371
+ // Relative time-window shortcut for analytics + search tools — saves the model computing
372
+ // ISO dates. `last_n_days: 15` ⇒ date_from = today−15, date_to = today (explicit dates win).
373
+ const LAST_N_DAYS_PROP = {
374
+ last_n_days: {
375
+ type: "number",
376
+ description: "Relative window: include only the last N days (sets date_from/date_to). Alternative to passing date_from/date_to.",
377
+ },
378
+ };
379
+ // Tool names are domain-first (`didit_<domain>_<action>`) so that Claude's flat
380
+ // "Other tools" connector list sorts every domain's tools into one contiguous block
381
+ // (there is no public API for named sub-groups within a single connector — the
382
+ // alphabetical name sort is the only lever). The group label below is derived from the
383
+ // name prefix and emitted per tool as _meta["anthropic/toolGroup"] (app-facing metadata
384
+ // the model never sees) — harmless today, future-proof if the UI ever renders it.
385
+ const TOOL_GROUP_BY_PREFIX = [
386
+ ...(privileged_tools_1.PRIVILEGED_GROUP_PREFIX ? [privileged_tools_1.PRIVILEGED_GROUP_PREFIX] : []),
387
+ ["account_", "Account Setup"],
388
+ ["context_", "Account & Org"],
389
+ ["org_", "Account & Org"],
390
+ ["session_", "Sessions"],
391
+ ["workflow_", "Workflows & Questionnaires"],
392
+ ["questionnaire_", "Workflows & Questionnaires"],
393
+ ["lists_", "Lists & Blocklist"],
394
+ ["blocklist_", "Lists & Blocklist"],
395
+ ["allowlist_", "Lists & Blocklist"],
396
+ ["vendor_", "Vendor Users & Businesses"],
397
+ ["transaction_", "Transactions (AML)"],
398
+ ["case_", "Cases"],
399
+ ["webhook_", "Webhooks & Alerts"],
400
+ ["alert_", "Webhooks & Alerts"],
401
+ ["report_", "Reports & Audit"],
402
+ ["audit_", "Reports & Audit"],
403
+ ["analytics", "Reports & Audit"],
404
+ ["branding_", "Branding"],
405
+ ...internal_tools_1.INTERNAL_GROUP_PREFIXES,
406
+ ["verify_", "Verification APIs"],
407
+ ];
408
+ function toolGroupOf(name) {
409
+ const rest = name.replace(/^didit_/, "");
410
+ for (const [prefix, group] of TOOL_GROUP_BY_PREFIX) {
411
+ if (rest.startsWith(prefix))
412
+ return group;
413
+ }
414
+ return "Other";
415
+ }
416
+ // Tools that don't operate on an org/app scope — never auto-resolve a default for them.
417
+ const SCOPE_AGNOSTIC_TOOLS = new Set([
418
+ "didit_account_register",
419
+ "didit_account_verify_email",
420
+ "didit_account_resend_otp",
421
+ "didit_account_login",
422
+ "didit_account_verify_2fa",
423
+ "didit_org_list",
424
+ "didit_context_get",
425
+ // Public pricing catalog: no org/app scope to resolve.
426
+ "didit_workflow_get_kyb_registry_catalog",
427
+ ]);
428
+ // Account bootstrap tools accept passwords/OTP codes and are only for unauthenticated
429
+ // stdio setup. Hosted (remote) servers exclude them for EVERY caller - a remote connector
430
+ // authenticates with OAuth, so account credentials must never travel through the
431
+ // conversation (Anthropic MCP directory requirement, 2026-07).
432
+ const ACCOUNT_BOOTSTRAP_TOOLS = new Set([
433
+ "didit_account_register",
434
+ "didit_account_verify_email",
435
+ "didit_account_resend_otp",
436
+ "didit_account_login",
437
+ "didit_account_verify_2fa",
438
+ ]);
439
+ // These tools remain available in local/stdio contexts, but should not be part
440
+ // of the authenticated ChatGPT app catalog because public app review disallows
441
+ // digital-credit checkout flows and live credential/secret exposure.
442
+ const HOSTED_APP_EXCLUDED_TOOLS = new Set([
443
+ ...ACCOUNT_BOOTSTRAP_TOOLS,
444
+ "didit_org_reveal_application_api_key",
445
+ "didit_org_top_up",
446
+ ]);
447
+ // When a tool needs an org/app and the caller passed none (and the token carries none),
448
+ // auto-resolve the single org / single app so single-tenant users never have to pass or
449
+ // discover ids. Mutates the live request-context store (same object the resolvers read).
450
+ // Multi-org/app users fall through to the normal resolver error (which points to didit_context).
451
+ async function ensureScopeDefaults(name) {
452
+ if (SCOPE_AGNOSTIC_TOOLS.has(name) || (0, privileged_tools_1.isPrivilegedToolName)(name))
453
+ return;
454
+ const store = config_1.requestContext.getStore();
455
+ if (!store?.accessToken)
456
+ return; // no Bearer (env-default scope) — resolver will surface the error
457
+ if (store.organizationId && store.applicationId)
458
+ return;
459
+ try {
460
+ const map = await (0, orgapp_1.getOrgAppMap)();
461
+ if (!store.organizationId && map.length === 1)
462
+ store.organizationId = map[0].orgId;
463
+ if (!store.applicationId) {
464
+ // Candidates = the applications of the org already pinned in context, or - when no org
465
+ // is pinned - every application the caller owns. ONE candidate is unambiguous even when
466
+ // it is spread over several organizations: an org that holds no application cannot make
467
+ // the choice ambiguous, and didit_context_get already advertises exactly that app as
468
+ // `default_application_id`. Requiring a single ORG here (the earlier rule) is what
469
+ // made didit_lists_list / didit_webhook_list answer "application_id is required" to a
470
+ // caller whose context call had just named the default application.
471
+ const scoped = store.organizationId
472
+ ? map.filter((o) => o.orgId === store.organizationId)
473
+ : map;
474
+ // An org whose applications failed to list is UNKNOWN, not empty - it could hold the
475
+ // second candidate, so never call the count unambiguous while one is blind.
476
+ const blind = scoped.some((o) => o.appsError);
477
+ const candidates = scoped.flatMap((o) => o.apps.map((a) => ({ orgId: o.orgId, appId: a.appId })));
478
+ if (!blind && candidates.length === 1) {
479
+ store.applicationId = candidates[0].appId;
480
+ // The console path needs BOTH ids, and they must be the same pair: adopt the org that
481
+ // actually owns the resolved app rather than leaving the org for the resolver to fail on.
482
+ store.organizationId = candidates[0].orgId;
483
+ }
484
+ }
485
+ }
486
+ catch {
487
+ /* discovery failed — let the normal resolver surface the actionable error */
488
+ }
489
+ }
490
+ // Per-app list tools that have a cross-org/app aggregate sibling. A multi-tenant caller who
491
+ // invokes one of these without a resolvable scope would otherwise hit "organization_id is
492
+ // required". Instead we transparently span every app (identical to the matching *_search tool:
493
+ // newest-first, each row attributed to its org/app), so a general "list my sessions" by a
494
+ // multi-app user succeeds on the FIRST call rather than erroring then recovering.
495
+ const AGGREGATE_FALLBACK = {
496
+ didit_session_list: search.searchSessions,
497
+ didit_transaction_list: search.searchTransactions,
498
+ didit_case_list: search.searchCases,
499
+ didit_vendor_user_list: search.searchVendorUsers,
500
+ didit_vendor_business_list: search.searchVendorBusinesses,
501
+ didit_workflow_list: search.searchWorkflows,
502
+ };
503
+ // The aggregate to run in place of a per-app list when scope is unresolved; undefined when the
504
+ // caller is fully scoped (org+app present) and the real single-app list should run.
505
+ function aggregateFallbackFor(name) {
506
+ const fn = AGGREGATE_FALLBACK[name];
507
+ if (!fn)
508
+ return undefined;
509
+ const store = config_1.requestContext.getStore();
510
+ if (store?.organizationId && store?.applicationId)
511
+ return undefined;
512
+ return fn;
513
+ }
514
+ // MCP tool annotations. Claude's connector "Tool permissions" UI groups tools into
515
+ // "Read-only" / "Write" / "Destructive" categories from readOnlyHint + destructiveHint —
516
+ // WITHOUT them every tool collapses into one undifferentiated "Other tools" bucket (which
517
+ // is exactly what GitHub/Linear/Sentry avoid by annotating their tools). Derived from the
518
+ // domain-first name (whole-token match, so the "lists"/"blocklist" domains don't read as
519
+ // the "list" verb) — maintenance-free as tools are added.
520
+ const READ_VERB_TOKENS = new Set([
521
+ "list", "get", "search", "statistics", "analytics", "export", "pdf", "validate", "backtest",
522
+ ]);
523
+ const DESTRUCTIVE_VERB_TOKENS = new Set(["delete", "remove", "uninstall"]);
524
+ function toolTitle(name) {
525
+ return name
526
+ .replace(/^didit_/, "")
527
+ .split("_")
528
+ .map((w) => w.charAt(0).toUpperCase() + w.slice(1))
529
+ .join(" ");
530
+ }
531
+ // Tools that are destructive/high-impact by SEMANTICS, not by a delete/remove verb in the
532
+ // name: revealing a live secret, moving money, consequential decisions, and overwrites.
533
+ const EXPLICIT_DESTRUCTIVE_TOOLS = new Set([
534
+ "didit_org_reveal_application_api_key",
535
+ "didit_org_top_up",
536
+ "didit_case_manage",
537
+ "didit_session_update_status",
538
+ "didit_questionnaire_update",
539
+ "didit_webhook_update",
540
+ "didit_workflow_update",
541
+ "didit_workflow_edit_graph",
542
+ "didit_workflow_set_graph",
543
+ "didit_workflow_publish",
544
+ ...internal_tools_1.INTERNAL_DESTRUCTIVE_TOOLS,
545
+ ]);
546
+ // Tools that can reach outside the current Didit workspace/account boundary by
547
+ // sending email/SMS, creating third-party checkout, registering webhook delivery
548
+ // endpoints, or sharing verification data with a partner.
549
+ const EXPLICIT_OPEN_WORLD_TOOLS = new Set([
550
+ "didit_account_register",
551
+ "didit_account_resend_otp",
552
+ "didit_org_invite_member",
553
+ "didit_org_top_up",
554
+ "didit_session_share",
555
+ "didit_session_update_status",
556
+ ...internal_tools_1.INTERNAL_OPEN_WORLD_TOOLS,
557
+ "didit_verify_email_send",
558
+ "didit_verify_phone_send",
559
+ "didit_webhook_create",
560
+ "didit_webhook_update",
561
+ ]);
562
+ // These tools have names that include read-like tokens, but their handlers
563
+ // create server-side artifacts/jobs rather than strictly retrieving data.
564
+ const EXPLICIT_WRITE_TOOLS = new Set([
565
+ "didit_report_export",
566
+ "didit_session_generate_pdf",
567
+ "didit_session_webhook_resend",
568
+ ]);
569
+ // The inverse: tools whose names carry no read-like token but whose handlers never
570
+ // change server state (requirements/workflow-check are deterministic reads over the
571
+ // stored profile + knowledge base; interview/next is pure computation; generate_workflow
572
+ // computes and returns a graph WITHOUT persisting anything — the backend view only
573
+ // requires read:workflows, and applying the graph goes through the didit_workflow_* writes).
574
+ const EXPLICIT_READ_TOOLS = new Set([
575
+ ...internal_tools_1.INTERNAL_READ_TOOLS,
576
+ // build_graph computes a graph from a plain feature spec, persisting nothing.
577
+ "didit_workflow_build_graph",
578
+ // The per-session webhook delivery log (its only verb-like token is "webhooks").
579
+ "didit_session_webhooks",
580
+ // Folds a session's decision payload and its workflow graph into the outcome trace.
581
+ "didit_session_explain_decision",
582
+ ]);
583
+ function annotationsFor(name) {
584
+ const tokens = name.replace(/^didit_/, "").split("_");
585
+ const title = toolTitle(name);
586
+ const openWorldHint = EXPLICIT_OPEN_WORLD_TOOLS.has(name);
587
+ if (EXPLICIT_DESTRUCTIVE_TOOLS.has(name) || tokens.some((t) => DESTRUCTIVE_VERB_TOKENS.has(t))) {
588
+ return { title, readOnlyHint: false, openWorldHint, destructiveHint: true };
589
+ }
590
+ if (EXPLICIT_WRITE_TOOLS.has(name)) {
591
+ return { title, readOnlyHint: false, openWorldHint, destructiveHint: false };
592
+ }
593
+ if (EXPLICIT_READ_TOOLS.has(name)) {
594
+ return { title, readOnlyHint: true, openWorldHint, destructiveHint: false };
595
+ }
596
+ // Verification APIs (didit_verify_*) are billable POST actions — keep them as writes even
597
+ // when the action token reads like a query (kyb_search / face_search).
598
+ const isBillableAction = name.startsWith("didit_verify_");
599
+ if (!isBillableAction && tokens.some((t) => READ_VERB_TOKENS.has(t))) {
600
+ return { title, readOnlyHint: true, openWorldHint, destructiveHint: false };
601
+ }
602
+ return { title, readOnlyHint: false, openWorldHint, destructiveHint: false };
603
+ }
604
+ /**
605
+ * Build a fully-wired MCP server (tool list + dispatch). A factory rather than a
606
+ * singleton because the stateless Streamable-HTTP transport needs a fresh server
607
+ * instance per request, while stdio uses exactly one. Both share this definition.
608
+ *
609
+ * `hosted: true` marks a remote (Streamable-HTTP / OAuth) server. Hosted servers never
610
+ * expose the account-bootstrap tools (credentials must not travel through a remote
611
+ * conversation) and never honor the DIDIT_IS_STAFF env override (a deployment-wide env
612
+ * var would grant the staff surface to every remote caller; only per-token introspection
613
+ * can mark a hosted caller privileged). The stdio server keeps both conveniences.
614
+ *
615
+ * `profile` selects the catalog served (see chatgpt-app.ts): `full` (default) or `chatgpt`,
616
+ * the reduced allow-list the hosted server exposes at /mcp/chatgpt for the ChatGPT app store.
617
+ */
618
+ function createServer(options = {}) {
619
+ const hosted = options.hosted === true;
620
+ const profile = options.profile ?? "full";
621
+ // `access_token` on the auth-service discovery tools is a stdio full-profile convenience: it lets
622
+ // someone running the local server hand over the Bearer that didit_account_login returned.
623
+ // A hosted server authenticates with OAuth and reads the caller's Bearer from
624
+ // requestContext, so the property is never needed there - and advertising it would solicit
625
+ // an authentication secret through tool arguments, which the OpenAI Apps guidelines
626
+ // prohibit outright ("do not collect, solicit, or process ... access credentials and
627
+ // authentication secrets"; app review finding policy-review-47fabf436877, 2026-09).
628
+ // Hosted catalogs omit both the property and the sentence that tells the model to fill it,
629
+ // on EVERY profile - the full catalog at /mcp is a public directory listing too. The stdio
630
+ // ChatGPT profile mirrors this omission for local catalog review.
631
+ const stdioOnlyAccessToken = (description) => hosted || profile === "chatgpt" ? {} : { access_token: { type: "string", description } };
632
+ const stdioTokenHint = hosted || profile === "chatgpt" ? "" : " In stdio mode pass access_token from login/verify_email.";
633
+ // Call-time mirror: hosted and ChatGPT calls never process a token handed in as
634
+ // an argument, even if a client crafted one from a memorised stdio schema. Ignoring (rather
635
+ // than refusing) keeps every existing hosted caller working - the header Bearer that already
636
+ // authenticated the request is the identity used either way.
637
+ const stdioAccessTokenArg = (a) => hosted || profile === "chatgpt" ? undefined : a?.access_token;
638
+ // Only a profile that serves MCP Apps UI (chatgpt-app.ts) advertises `resources`; every
639
+ // other profile keeps exactly the capabilities it always had.
640
+ const servesWidgets = (0, chatgpt_app_1.profileServesWidgets)(profile);
641
+ const server = new index_js_1.Server({ name: "didit", version: config_1.SERVER_VERSION }, { capabilities: servesWidgets ? { tools: {}, resources: {} } : { tools: {} } });
642
+ if (servesWidgets) {
643
+ // The UI templates (`ui://` resources) the tools reference. Static, identical for every
644
+ // caller, and behind the same Bearer gate as the rest of the endpoint (http.ts).
645
+ server.setRequestHandler(types_js_1.ListResourcesRequestSchema, async () => ({ resources: (0, chatgpt_app_1.listWidgetResources)() }));
646
+ server.setRequestHandler(types_js_1.ListResourceTemplatesRequestSchema, async () => ({ resourceTemplates: [] }));
647
+ server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async (request) => (0, chatgpt_app_1.readWidgetResource)(request.params.uri));
648
+ }
649
+ // ---------------------------------------------------------------------------
650
+ // Tool definitions
651
+ // ---------------------------------------------------------------------------
652
+ // Built per call of tools/list (the catalog is filtered per caller below) and
653
+ // once for the dispatcher, which reads each tool's `required` list to tell a
654
+ // blank optional argument from a blank required one (blank-args.ts).
655
+ const toolDefinitions = () => [
95
656
  // ── Auth ────────────────────────────────────────────────────────────
96
657
  {
97
- name: "didit_register",
98
- description: "Register a new Didit account. A 6-character verification code is sent to the email. Follow up with didit_verify_email.",
658
+ name: "didit_account_register",
659
+ description: "Register a new Didit account. A 6-character verification code is sent to the email. Follow up with didit_account_verify_email.",
99
660
  inputSchema: {
100
661
  type: "object",
101
662
  properties: {
@@ -106,7 +667,7 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
106
667
  },
107
668
  },
108
669
  {
109
- name: "didit_verify_email",
670
+ name: "didit_account_verify_email",
110
671
  description: "Verify email with the 6-character code. Returns access_token, refresh_token, organization, application (with client_id and api_key).",
111
672
  inputSchema: {
112
673
  type: "object",
@@ -118,7 +679,7 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
118
679
  },
119
680
  },
120
681
  {
121
- name: "didit_resend_otp",
682
+ name: "didit_account_resend_otp",
122
683
  description: "Resend the 6-character email verification code for a pending registration. Codes expire after 10 minutes.",
123
684
  inputSchema: {
124
685
  type: "object",
@@ -129,8 +690,9 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
129
690
  },
130
691
  },
131
692
  {
132
- name: "didit_login",
133
- description: "Login to existing Didit account. Returns access_token and refresh_token.",
693
+ name: "didit_account_login",
694
+ 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.",
134
696
  inputSchema: {
135
697
  type: "object",
136
698
  properties: {
@@ -141,68 +703,203 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
141
703
  },
142
704
  },
143
705
  {
144
- name: "didit_list_organizations",
145
- description: "List all organizations the authenticated user belongs to. Requires access_token from login or verify_email.",
706
+ name: "didit_account_verify_2fa",
707
+ description: "Finish logging in to an account with two-factor authentication, using the temp_token from didit_account_login " +
708
+ "and the current 6-digit authenticator code (or an unused backup code). Returns access_token and refresh_token.",
146
709
  inputSchema: {
147
710
  type: "object",
148
711
  properties: {
149
- access_token: { type: "string", description: "Bearer access token from login/verify_email" },
712
+ temp_token: { type: "string", description: "temp_token returned by didit_account_login (valid for 5 minutes)" },
713
+ code: { type: "string", description: "6-digit code from the authenticator app, or an unused backup code" },
150
714
  },
151
- required: ["access_token"],
715
+ required: ["temp_token", "code"],
152
716
  },
153
717
  },
154
718
  {
155
- name: "didit_list_applications",
156
- description: "List all applications in an organization. Each application has its own client_id and api_key. Requires access_token.",
719
+ name: "didit_org_list",
720
+ description: "List the organizations you belong to (each has an id to pass as organization_id to other tools). In hosted OAuth mode no arguments are needed." +
721
+ stdioTokenHint,
157
722
  inputSchema: {
158
723
  type: "object",
159
724
  properties: {
160
- access_token: { type: "string", description: "Bearer access token" },
161
- organization_id: { type: "string" },
725
+ ...stdioOnlyAccessToken("Only for stdio mode — Bearer access token from login/verify_email. Omit in hosted OAuth mode."),
726
+ },
727
+ },
728
+ },
729
+ {
730
+ name: "didit_org_list_applications",
731
+ description: "List the applications in an organization (each has an id to pass as application_id). In hosted OAuth mode pass only organization_id.",
732
+ inputSchema: {
733
+ type: "object",
734
+ properties: {
735
+ organization_id: { type: "string", description: "Organization UUID (from didit_org_list)" },
736
+ ...stdioOnlyAccessToken("Only for stdio mode. Omit in hosted OAuth mode."),
162
737
  },
163
- required: ["access_token", "organization_id"],
738
+ required: ["organization_id"],
164
739
  },
165
740
  },
166
741
  {
167
- name: "didit_get_application",
168
- description: "Get application details including client_id and api_key. Requires access_token.",
742
+ name: "didit_org_get_application",
743
+ description: "Get application details (client_id etc.). The api_key is REDACTED — a masked preview + api_key_set flag are returned, never the raw secret.",
169
744
  inputSchema: {
170
745
  type: "object",
171
746
  properties: {
172
- access_token: { type: "string", description: "Bearer access token" },
173
747
  organization_id: { type: "string" },
174
748
  application_id: { type: "string" },
749
+ ...stdioOnlyAccessToken("Only for stdio mode. Omit in hosted OAuth mode."),
175
750
  },
176
- required: ["access_token", "organization_id", "application_id"],
751
+ required: ["organization_id", "application_id"],
177
752
  },
178
753
  },
754
+ {
755
+ name: "didit_org_reveal_application_api_key",
756
+ description: "Return the RAW, un-redacted api_key for an application. This exposes a LIVE SECRET — only call when a human explicitly needs the key to integrate; never log or persist it. Requires confirm:true AND an explicit organization_id + application_id (no defaults).",
757
+ inputSchema: {
758
+ type: "object",
759
+ properties: {
760
+ organization_id: { type: "string", description: "REQUIRED. No env/context default for this raw-secret tool." },
761
+ application_id: { type: "string", description: "REQUIRED. No env/context default for this raw-secret tool." },
762
+ confirm: { type: "boolean", description: "REQUIRED. Must be true to expose the raw key. Only set after explicit user confirmation of this exact action." },
763
+ ...stdioOnlyAccessToken("Only for stdio mode."),
764
+ },
765
+ required: ["organization_id", "application_id", "confirm"],
766
+ },
767
+ },
768
+ // ── Context + cross-org/app aggregate search ────────────────────────
769
+ {
770
+ name: "didit_context_get",
771
+ description: "Return ALL organizations you can access with their applications nested, plus the default org/app when unambiguous — in ONE call (replaces didit_org_list + per-org didit_org_list_applications). Call this first to discover ids.",
772
+ inputSchema: { type: "object", properties: {} },
773
+ },
774
+ {
775
+ name: "didit_session_search",
776
+ description: `Search verification sessions ACROSS ALL your apps and organizations in a single call — the efficient way to answer "the last 5 in-review sessions across my apps". Aggregates server-side and returns newest matches first, each tagged with its organization/application. Omit organization_id/application_id to span everything; pass them to narrow scope. status accepts: ${SESSION_STATUSES}.`,
777
+ inputSchema: {
778
+ type: "object",
779
+ properties: {
780
+ status: { type: "string", description: `Filter by session status (${SESSION_STATUSES}). Several statuses separated by commas match any of them, e.g. "Not Started,In Progress".` },
781
+ session_kind: { type: "string", enum: ["user", "business", "all"], description: "KYC (user), KYB (business), or all" },
782
+ workflow_id: { type: "string", description: "Filter by workflow UUID" },
783
+ search: { type: "string", description: "Free-text search" },
784
+ date_from: { type: "string", description: "ISO date lower bound" },
785
+ date_to: { type: "string", description: "ISO date upper bound" },
786
+ ...LAST_N_DAYS_PROP,
787
+ limit: { type: "number", description: "Max results after merging across apps (default 20, max 200)" },
788
+ ...orgapp_1.ORG_APP_PROPS,
789
+ },
790
+ },
791
+ },
792
+ {
793
+ name: "didit_transaction_search",
794
+ description: "Search transaction-monitoring (AML) transactions ACROSS ALL your apps and organizations in one call. Omit organization_id/application_id to span everything; pass them to narrow. Returns newest first, each tagged with its org/app.",
795
+ inputSchema: {
796
+ type: "object",
797
+ properties: {
798
+ status: { type: "string", description: "Filter by transaction status" },
799
+ search: { type: "string", description: "Free-text search" },
800
+ date_from: { type: "string", description: "ISO date lower bound" },
801
+ date_to: { type: "string", description: "ISO date upper bound" },
802
+ ...LAST_N_DAYS_PROP,
803
+ limit: { type: "number", description: "Max results after merging (default 20, max 200)" },
804
+ ...orgapp_1.ORG_APP_PROPS,
805
+ },
806
+ },
807
+ },
808
+ {
809
+ name: "didit_case_search",
810
+ description: "Search case-management cases ACROSS ALL your apps and organizations in one call. Omit organization_id/application_id to span everything; pass them to narrow. Returns newest first, each tagged with its org/app.",
811
+ inputSchema: {
812
+ type: "object",
813
+ properties: {
814
+ status: { type: "string", description: "Filter by case status" },
815
+ search: { type: "string", description: "Free-text search" },
816
+ date_from: { type: "string", description: "ISO date lower bound" },
817
+ date_to: { type: "string", description: "ISO date upper bound" },
818
+ ...LAST_N_DAYS_PROP,
819
+ limit: { type: "number", description: "Max results after merging (default 20, max 200)" },
820
+ ...orgapp_1.ORG_APP_PROPS,
821
+ },
822
+ },
823
+ },
824
+ {
825
+ name: "didit_vendor_user_search",
826
+ description: "Find vendor users (your end customers) ACROSS ALL your apps and organizations in one call — e.g. locate a customer by vendor_data/email/name without knowing which app they're in. Omit organization_id/application_id to span everything; pass them to narrow. Each hit is tagged with its org/app.",
827
+ inputSchema: {
828
+ type: "object",
829
+ properties: {
830
+ search: { type: "string", description: "Free-text search (name, email, vendor_data)" },
831
+ vendor_data: { type: "string", description: "Filter by your customer identifier" },
832
+ status: { type: "string", description: "Filter by vendor-user status" },
833
+ date_from: { type: "string", description: "ISO date lower bound" },
834
+ date_to: { type: "string", description: "ISO date upper bound" },
835
+ ...LAST_N_DAYS_PROP,
836
+ limit: { type: "number", description: "Max results after merging (default 20, max 200)" },
837
+ ...orgapp_1.ORG_APP_PROPS,
838
+ },
839
+ },
840
+ },
841
+ {
842
+ name: "didit_vendor_business_search",
843
+ description: "Find vendor businesses (KYB companies) ACROSS ALL your apps and organizations in one call. Omit organization_id/application_id to span everything; pass them to narrow. Each hit is tagged with its org/app.",
844
+ inputSchema: {
845
+ type: "object",
846
+ properties: {
847
+ search: { type: "string", description: "Free-text search (company name, registration number, vendor_data)" },
848
+ vendor_data: { type: "string", description: "Filter by your business identifier" },
849
+ status: { type: "string", description: "Filter by vendor-business status" },
850
+ date_from: { type: "string", description: "ISO date lower bound" },
851
+ date_to: { type: "string", description: "ISO date upper bound" },
852
+ ...LAST_N_DAYS_PROP,
853
+ limit: { type: "number", description: "Max results after merging (default 20, max 200)" },
854
+ ...orgapp_1.ORG_APP_PROPS,
855
+ },
856
+ },
857
+ },
858
+ {
859
+ name: "didit_analytics",
860
+ description: "Aggregate verification analytics ACROSS ALL your apps and organizations in one call - the efficient way to answer questions like \"how many people tried phone verification but dropped off in the last 15 days?\". Returns summed status counts (request_breakdown), a feature_funnel (how many sessions REACHED each step: OCR, LIVENESS, FACE_MATCH, AML, POA, PHONE, EMAIL, ...), warning_stats by risk code, the previous period's request_breakdown, per-workflow session totals and a recomputed conversion_rate, for a date window. Omit organization_id/application_id to span everything; pass them to narrow.",
861
+ inputSchema: {
862
+ type: "object",
863
+ properties: {
864
+ date_from: { type: "string", description: "ISO date lower bound (YYYY-MM-DD)" },
865
+ date_to: { type: "string", description: "ISO date upper bound (YYYY-MM-DD)" },
866
+ ...LAST_N_DAYS_PROP,
867
+ include_timeseries: { type: "boolean", description: "Also return per-day time series (heavier). Default false." },
868
+ ...orgapp_1.ORG_APP_PROPS,
869
+ },
870
+ },
871
+ },
872
+ ...(0, internal_tools_1.internalToolDefs)("network"),
179
873
  // ── Sessions ────────────────────────────────────────────────────────
180
874
  {
181
- name: "didit_create_session",
875
+ name: "didit_session_create",
182
876
  description: "Create a verification session. Requires workflow_id (created in the Console Workflows page) — the workflow defines which steps run and whether the session is KYC or KYB. Returns session_id, url, and session_token.",
183
877
  inputSchema: {
184
878
  type: "object",
185
879
  properties: {
880
+ ...orgapp_1.ORG_APP_PROPS,
186
881
  workflow_id: { type: "string", description: "REQUIRED. UUID of the workflow that defines the verification steps. Selects KYC vs KYB implicitly." },
187
882
  vendor_data: { type: "string", description: "Your unique identifier for the user (e.g. user ID). Used to group sessions into a user/business." },
188
883
  callback: { type: "string", description: "URL to redirect the user to after verification" },
189
884
  callback_method: { type: "string", enum: ["initiator", "completer", "both"], description: "Which device/flow the callback applies to" },
190
885
  language: { type: "string", enum: LANGUAGE_CODES, description: "Pre-set the verification UI language (ISO code)" },
886
+ sandbox_scenario: { type: "string", description: "SANDBOX ONLY (an application whose mode is 'sandbox' — see didit_context_get): predefine the outcome instead of running real providers, so the session is never billed. Slugs are 'approve', 'decline_*' (e.g. decline_aml_hit, decline_document_expired, decline_kyb_registry_mismatch) and 'review_*' (e.g. review_aml_possible_match). Ignored by a live application, where every session IS billed." },
191
887
  metadata: { type: "object", description: "Arbitrary JSON stored on the session and echoed in webhooks" },
192
888
  contact_details: { type: "object", description: "Pre-fill contact info (e.g. email, phone) for the session" },
193
889
  expected_details: { type: "object", description: "Expected values to validate against (e.g. expected country, IP)" },
194
- portrait_image: { type: "string", description: "Base64 or URL reference portrait used by some workflows" },
890
+ portrait_image: { type: "string", description: "Base64 or URL reference portrait for Biometric Authentication / Face-Match-first workflows. Optional when the vendor_data user already has a stored face (approved liveness face, ePassport photo, document portrait, or enrolled profile face) - the stored face is reused automatically; 400 if neither is available" },
195
891
  },
196
892
  required: ["workflow_id"],
197
893
  },
198
894
  },
199
895
  {
200
- name: "didit_list_sessions",
201
- description: `List verification sessions with filters and pagination. status accepts session-level values: ${SESSION_STATUSES}.`,
896
+ 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}.`,
202
898
  inputSchema: {
203
899
  type: "object",
204
900
  properties: {
205
- status: { type: "string", description: `Filter by session status (${SESSION_STATUSES})` },
901
+ ...orgapp_1.ORG_APP_PROPS,
902
+ status: { type: "string", description: `Filter by session status (${SESSION_STATUSES}). Several statuses separated by commas match any of them, e.g. "Not Started,In Progress".` },
206
903
  session_kind: { type: "string", enum: ["user", "business", "all"], description: "KYC (user), KYB (business), or all" },
207
904
  vendor_data: { type: "string", description: "Filter by vendor_data" },
208
905
  workflow_id: { type: "string", description: "Filter by workflow UUID" },
@@ -215,7 +912,7 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
215
912
  },
216
913
  },
217
914
  {
218
- name: "didit_get_session_decision",
915
+ name: "didit_session_get_decision",
219
916
  description: "Get the full verification decision and all extracted data for a session.",
220
917
  inputSchema: {
221
918
  type: "object",
@@ -226,8 +923,8 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
226
923
  },
227
924
  },
228
925
  {
229
- name: "didit_update_session_status",
230
- description: "Approve, decline, or request resubmission of a session. For resubmission, pass new_status='Resubmitted' and nodes_to_resubmit; already-approved steps are kept.",
926
+ name: "didit_session_update_status",
927
+ 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.",
231
928
  inputSchema: {
232
929
  type: "object",
233
930
  properties: {
@@ -235,15 +932,15 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
235
932
  new_status: { type: "string", enum: ["Approved", "Declined", "Resubmitted"], description: "New decision status" },
236
933
  comment: { type: "string", description: "Reviewer note stored on the audit trail" },
237
934
  nodes_to_resubmit: { type: "array", items: { type: "string" }, description: "Node IDs the user must redo (only for Resubmitted)" },
238
- send_email: { type: "boolean", description: "Email the user about the status change" },
239
- email_address: { type: "string", description: "Override the recipient email" },
935
+ send_email: { type: "boolean", description: "Send a notification email that cannot be recalled. Set true only after explicit user confirmation of the notification and recipient." },
936
+ email_address: { type: "string", description: "Override the notification recipient; confirm this address with the user before sending." },
240
937
  email_language: { type: "string", description: "Language for the notification email" },
241
938
  },
242
939
  required: ["session_id", "new_status"],
243
940
  },
244
941
  },
245
942
  {
246
- name: "didit_update_session_data",
943
+ name: "didit_session_update_data",
247
944
  description: "Correct the KYC data extracted from the ID document on a session (reviewer override). Only send the fields you want to change.",
248
945
  inputSchema: {
249
946
  type: "object",
@@ -271,7 +968,7 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
271
968
  },
272
969
  },
273
970
  {
274
- name: "didit_update_session_poa_data",
971
+ name: "didit_session_update_poa_data",
275
972
  description: "Correct the Proof of Address data extracted from the POA document on a session (reviewer override). Only send the fields you want to change.",
276
973
  inputSchema: {
277
974
  type: "object",
@@ -291,59 +988,66 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
291
988
  },
292
989
  },
293
990
  {
294
- name: "didit_delete_session",
295
- description: "Permanently delete a single verification session and all associated data.",
991
+ name: "didit_session_delete",
992
+ description: "Permanently and irreversibly delete a single verification session (KYC or KYB) - its verification data and stored media. Blocklist entries, issued share tokens, already-queued webhook deliveries, consumed credits, and the parent user/business are not affected. Requires confirm:true - only pass it after the user has explicitly confirmed this exact deletion.",
296
993
  inputSchema: {
297
994
  type: "object",
298
995
  properties: {
299
996
  session_id: { type: "string" },
997
+ confirm: { type: "boolean", description: "REQUIRED. Must be true - deletion is permanent and irreversible. Only set after explicit user confirmation of this exact action." },
300
998
  },
301
- required: ["session_id"],
999
+ required: ["session_id", "confirm"],
302
1000
  },
303
1001
  },
304
1002
  {
305
- name: "didit_batch_delete_sessions",
306
- description: "Delete multiple sessions by session numbers, or delete all sessions.",
1003
+ name: "didit_session_batch_delete",
1004
+ description: "Permanently and irreversibly delete multiple KYC sessions by session number, or EVERY KYC session in the application with delete_all:true (KYB sessions are never touched; delete those individually). Requires confirm:true - only pass it after the user has explicitly confirmed this exact deletion.",
307
1005
  inputSchema: {
308
1006
  type: "object",
309
1007
  properties: {
1008
+ ...orgapp_1.ORG_APP_PROPS,
310
1009
  session_numbers: {
311
1010
  type: "array",
312
1011
  items: { type: "number" },
313
1012
  description: "Array of session numbers to delete",
314
1013
  },
315
1014
  delete_all: { type: "boolean", description: "Set true to delete ALL sessions (ignores session_numbers)" },
1015
+ confirm: { type: "boolean", description: "REQUIRED. Must be true - deletion is permanent and irreversible. Only set after explicit user confirmation of this exact action." },
316
1016
  },
1017
+ required: ["confirm"],
317
1018
  },
318
1019
  },
319
1020
  {
320
- name: "didit_generate_session_pdf",
321
- description: "Generate a PDF verification report for a session.",
1021
+ name: "didit_session_generate_pdf",
1022
+ description: "Return download_url, expires_at and expires_in (300 seconds) for the original Didit session PDF. Fetch the URL to save the PDF; no Authorization header is needed. Treat the URL as sensitive. Requires configured MCP HTTP PDF downloads.",
322
1023
  inputSchema: {
323
1024
  type: "object",
324
1025
  properties: {
1026
+ ...orgapp_1.ORG_APP_PROPS,
325
1027
  session_id: { type: "string" },
326
1028
  },
327
1029
  required: ["session_id"],
328
1030
  },
329
1031
  },
330
1032
  {
331
- name: "didit_list_session_reviews",
1033
+ name: "didit_session_list_reviews",
332
1034
  description: "List the review history and activity log for a session.",
333
1035
  inputSchema: {
334
1036
  type: "object",
335
1037
  properties: {
1038
+ ...orgapp_1.ORG_APP_PROPS,
336
1039
  session_id: { type: "string" },
337
1040
  },
338
1041
  required: ["session_id"],
339
1042
  },
340
1043
  },
341
1044
  {
342
- name: "didit_add_session_review",
1045
+ name: "didit_session_add_review",
343
1046
  description: "Add a review note to a session's audit trail, optionally changing its status.",
344
1047
  inputSchema: {
345
1048
  type: "object",
346
1049
  properties: {
1050
+ ...orgapp_1.ORG_APP_PROPS,
347
1051
  session_id: { type: "string" },
348
1052
  comment: { type: "string", description: "Review comment or note" },
349
1053
  new_status: {
@@ -356,7 +1060,7 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
356
1060
  },
357
1061
  },
358
1062
  {
359
- name: "didit_share_session",
1063
+ name: "didit_session_share",
360
1064
  description: "Share a verified session with a trusted partner for reusable KYC (B2B session sharing).",
361
1065
  inputSchema: {
362
1066
  type: "object",
@@ -368,7 +1072,42 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
368
1072
  },
369
1073
  },
370
1074
  {
371
- name: "didit_import_shared_session",
1075
+ name: "didit_session_explain_decision",
1076
+ description: "WHY a verification session ended Approved / Declined / In Review, as a deterministic trace read from the record: the feature that decided it (strictest wins), each warning that had an effect with its raw value, every triggered status rule (field, operator, configured vs actual value), the human override if a reviewer changed the automatic verdict, and for each cause the workflow config key that governs it (`lever`, with its CURRENT value read from the workflow graph; only keys that exist in the feature-config contract; null means it is not a workflow setting). `workflow.graph_read:false` means the graph could not be read, so no current values. Use this for every 'why was it declined / in review / approved', 'it should have been X' and 'how do I make these go to X' question INSTEAD of reading the whole decision — it never returns images, extracted fields or PII. `informational` lists warnings that changed nothing. `unexplained:true` means a decided session (Declined / In Review) whose record shows no effective cause (e.g. minimized age-assurance logs): say so, never invent one. `lifecycle_status:true` (Expired, Abandoned, Not Started, In Progress, Resub Requested…) means nothing decided it — the status is the whole explanation.",
1077
+ inputSchema: {
1078
+ type: "object",
1079
+ properties: {
1080
+ session_id: { type: "string", description: "REQUIRED. The session uuid (from the page's session-id param, didit_session_search or the user)" },
1081
+ },
1082
+ required: ["session_id"],
1083
+ },
1084
+ },
1085
+ {
1086
+ name: "didit_session_webhooks",
1087
+ description: "Delivery log of the webhooks Didit sent for ONE session (last 30 days): destination URL, HTTP response status, timing, signing headers (X-Signature/X-Timestamp) and a capped copy of the payload. The way to check an integration end to end: create a session on a SANDBOX application with sandbox_scenario 'approve' (unbilled, fires status.updated immediately), then call this with wait_seconds so the call waits for the delivery instead of you polling. A 2xx response_status means the customer's endpoint received it; 401/403 usually means their signature check (must be HMAC-SHA256 hex of the RAW body); an empty list after the wait means the endpoint never got the event (not public, or the destination is disabled).",
1088
+ inputSchema: {
1089
+ type: "object",
1090
+ properties: {
1091
+ session_id: { type: "string", description: "REQUIRED. The session whose deliveries to read" },
1092
+ wait_seconds: { type: "integer", minimum: 0, maximum: 60, description: "Keep polling up to this many seconds until at least one delivery exists (0 = read once). Use 30-45 right after creating a sandbox session." },
1093
+ },
1094
+ required: ["session_id"],
1095
+ },
1096
+ },
1097
+ {
1098
+ name: "didit_session_webhook_resend",
1099
+ description: "Resend one recorded webhook delivery of a session to the configured endpoint (the session page's own Resend). Use after the customer fixed their endpoint so they do not need a new session; returns the new delivery with its response_status.",
1100
+ inputSchema: {
1101
+ type: "object",
1102
+ properties: {
1103
+ session_id: { type: "string", description: "REQUIRED" },
1104
+ webhook_id: { type: "string", description: "REQUIRED. The delivery's uuid from didit_session_webhooks" },
1105
+ },
1106
+ required: ["session_id", "webhook_id"],
1107
+ },
1108
+ },
1109
+ {
1110
+ name: "didit_session_import_shared",
372
1111
  description: "Import a shared verification session from a partner (Reusable KYC).",
373
1112
  inputSchema: {
374
1113
  type: "object",
@@ -380,7 +1119,7 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
380
1119
  },
381
1120
  // ── Session Imports (bulk migration) ────────────────────────────────
382
1121
  {
383
- name: "didit_create_import",
1122
+ name: "didit_session_create_import",
384
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.",
385
1124
  inputSchema: {
386
1125
  type: "object",
@@ -394,23 +1133,23 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
394
1133
  },
395
1134
  },
396
1135
  {
397
- name: "didit_get_import_template",
398
- description: "Download the canonical import template (column headers and format) used by didit_create_import.",
1136
+ name: "didit_session_get_import_template",
1137
+ description: "Download the canonical import template (column headers and format) used by didit_session_create_import.",
399
1138
  inputSchema: { type: "object", properties: {} },
400
1139
  },
401
1140
  {
402
- name: "didit_get_import",
1141
+ name: "didit_session_get_import",
403
1142
  description: "Get the status and summary of a bulk import job.",
404
1143
  inputSchema: {
405
1144
  type: "object",
406
1145
  properties: {
407
- import_id: { type: "string", description: "Import job ID returned by didit_create_import" },
1146
+ import_id: { type: "string", description: "Import job ID returned by didit_session_create_import" },
408
1147
  },
409
1148
  required: ["import_id"],
410
1149
  },
411
1150
  },
412
1151
  {
413
- name: "didit_get_import_errors",
1152
+ name: "didit_session_get_import_errors",
414
1153
  description: "List per-row errors for a bulk import job (rows that failed validation or processing).",
415
1154
  inputSchema: {
416
1155
  type: "object",
@@ -422,16 +1161,26 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
422
1161
  },
423
1162
  // ── Workflows (Verification Settings) ───────────────────────────────
424
1163
  {
425
- name: "didit_list_workflows",
426
- description: "List all verification workflows for your application. Each workflow defines verification steps, thresholds, and accepted documents.",
427
- inputSchema: { type: "object", properties: {} },
1164
+ name: "didit_workflow_list",
1165
+ description: "List verification workflows. With multiple apps (or no scope) it auto-spans every app, each row tagged with its org/app. To find one workflow by id/label across all apps, prefer didit_workflow_search. The `features` on a row do NOT tell you whether a workflow checks age: age assurance done from the DOCUMENT (age restrictions on the OCR step) shows no feature of its own. For any question about which workflows do age assurance, pass `include_age_assurance:true` — it annotates each row with `does_age_assurance`/`methods` server-side, which is the only reliable way to find them.",
1166
+ inputSchema: {
1167
+ type: "object",
1168
+ properties: {
1169
+ ...orgapp_1.ORG_APP_PROPS,
1170
+ include_age_assurance: {
1171
+ type: "boolean",
1172
+ description: "Annotate each non-archived row with whether it does age assurance, and how. Required to find workflows that check age from the document.",
1173
+ },
1174
+ },
1175
+ },
428
1176
  },
429
1177
  {
430
- name: "didit_create_workflow",
431
- description: "Create a verification workflow from an ordered list of features. Send `features` (uppercase feature values, in execution order) — NOT flat is_*_enabled flags or a workflow_type (those are rejected with 400). Put dependency features first (e.g. OCR before FACE_MATCH/NFC/DATABASE_VALIDATION). KYB workflows use KYB_REGISTRY/KYB_DOCUMENTS/KYB_KEY_PEOPLE.",
1178
+ name: "didit_workflow_create",
1179
+ description: "Create a SIMPLE (linear) verification workflow from an ordered list of features. Send `features` in execution order (uppercase values; put dependency features first, e.g. OCR before FACE_MATCH/NFC/DATABASE_VALIDATION). The MCP assembles them into a real workflow graph and publishes it; pass status:'draft' to keep it unpublished. A bad feature order fails validation and leaves a fixable draft. A workflow verifies EITHER a person (KYC) or a business (KYB), never both, and the type follows WHO is verified: KYB workflows use the KYB_* features (company paperwork belongs in KYB_DOCUMENTS or DOCUMENT_AI) and must not mix in person-only features (OCR/LIVENESS/FACE_MATCH/NFC/PROOF_OF_ADDRESS/DATABASE_VALIDATION/AGE_ESTIMATION); to verify the people behind a company, create a separate KYC workflow and link it from the KYB_KEY_PEOPLE node. For BRANCHING or conditional logic, use the graph tools instead: didit_workflow_get_field_definitions, then didit_workflow_validate_graph, then didit_workflow_set_graph.",
432
1180
  inputSchema: {
433
1181
  type: "object",
434
1182
  properties: {
1183
+ ...orgapp_1.ORG_APP_PROPS,
435
1184
  workflow_label: { type: "string", description: "Display name (max 50 chars)" },
436
1185
  features: {
437
1186
  type: "array",
@@ -451,29 +1200,27 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
451
1200
  },
452
1201
  },
453
1202
  {
454
- name: "didit_get_workflow",
455
- description: "Get the full configuration of a specific workflow.",
1203
+ name: "didit_workflow_get",
1204
+ description: "Get the full configuration of a specific workflow, including `response_attributes` " +
1205
+ "(returned data / data minimization): which data points the client receives per feature.",
456
1206
  inputSchema: {
457
1207
  type: "object",
458
1208
  properties: {
1209
+ ...orgapp_1.ORG_APP_PROPS,
459
1210
  workflow_id: { type: "string", description: "Workflow UUID" },
460
1211
  },
461
1212
  required: ["workflow_id"],
462
1213
  },
463
1214
  },
464
1215
  {
465
- name: "didit_update_workflow",
466
- description: "Update a workflow. Send only the fields to change. To change steps, send the full replacement `features` array (same shape as create). Editing features retroactively affects how past sessions' decisions are read, so change deliberately.",
1216
+ name: "didit_workflow_update",
1217
+ description: "Update a workflow's top-level SETTINGS only (workflow_label, is_default, retry/expiration, white-label, etc.). Omitted status preserves the current draft/published state; publication changes only when status is explicitly passed. It does NOT change which features run: to add/remove/reorder features, add a conditional branch, or add a Document-AI step, edit the graph with didit_workflow_edit_graph (small ops, preserves the big allow-lists) or didit_workflow_set_graph (full replace) — those are the only ways feature changes actually persist.",
467
1218
  inputSchema: {
468
1219
  type: "object",
469
1220
  properties: {
1221
+ ...orgapp_1.ORG_APP_PROPS,
470
1222
  workflow_id: { type: "string", description: "Workflow UUID" },
471
1223
  workflow_label: { type: "string" },
472
- features: {
473
- type: "array",
474
- items: WORKFLOW_FEATURE_ITEM,
475
- description: "Replacement feature list in execution order (same shape as create)",
476
- },
477
1224
  is_default: { type: "boolean" },
478
1225
  status: { type: "string", enum: ["draft", "published"] },
479
1226
  is_white_label_enabled: { type: "boolean" },
@@ -486,69 +1233,295 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
486
1233
  },
487
1234
  },
488
1235
  {
489
- name: "didit_delete_workflow",
490
- description: "Delete a verification workflow. Existing sessions using it are not affected.",
1236
+ name: "didit_workflow_delete",
1237
+ description: "Delete a draft verification workflow. If the API forbids deletion (including an only or published version), archive it instead. Existing sessions using it are not affected.",
491
1238
  inputSchema: {
492
1239
  type: "object",
493
1240
  properties: {
1241
+ ...orgapp_1.ORG_APP_PROPS,
494
1242
  workflow_id: { type: "string", description: "Workflow UUID" },
495
1243
  },
496
1244
  required: ["workflow_id"],
497
1245
  },
498
1246
  },
1247
+ {
1248
+ name: "didit_workflow_search",
1249
+ description: "Find verification workflows ACROSS ALL your apps/orgs in one call. Pass `workflow_id` to locate a specific workflow by its version uuid OR stable workflow_id (returns which org/app it lives in), or `search` to match by label. Use this instead of guessing the application when you only have a workflow id. `search` matches the LABEL ONLY: a CAPABILITY (age assurance, AML screening, …) is not searchable by name — for age assurance use didit_workflow_list with `include_age_assurance:true`, which reports what each workflow actually does.",
1250
+ inputSchema: {
1251
+ type: "object",
1252
+ properties: {
1253
+ workflow_id: { type: "string", description: "Match a specific workflow by version uuid or stable workflow_id" },
1254
+ search: { type: "string", description: "Case-insensitive substring match on the workflow label" },
1255
+ limit: { type: "number", description: "Max results after merging (default 50, max 200)" },
1256
+ ...orgapp_1.ORG_APP_PROPS,
1257
+ },
1258
+ },
1259
+ },
1260
+ {
1261
+ name: "didit_workflow_get_graph",
1262
+ description: "Get the node/graph for a workflow (the structure: nodes, branches, conditions, Document-AI steps) + `status`/`version`/`is_editable`. Large feature configs (documents_allowed, poa_documents_allowed, phone countries) are SUMMARIZED by default so the response never overflows — set `include_config:true` for the raw config. Includes `returned_data` (response_attributes): the ONLY source of truth for what data the client/relying party receives in the API response and webhooks — never infer that from which features run. Also includes `age_assurance`: whether the workflow checks age, and by which method (document age restrictions and/or AGE_ESTIMATION) — decide that from this block, never from the workflow's name. Pass just `workflow_id`; the owning org/app is resolved automatically. To MODIFY the graph, prefer didit_workflow_edit_graph (small ops, no need to resend big configs).",
1263
+ inputSchema: {
1264
+ type: "object",
1265
+ properties: {
1266
+ workflow_id: { type: "string", description: "Workflow version uuid or stable workflow_id" },
1267
+ include_config: { type: "boolean", description: "Return full feature configs verbatim (default false → summarized). Can be very large." },
1268
+ ...orgapp_1.ORG_APP_PROPS,
1269
+ },
1270
+ required: ["workflow_id"],
1271
+ },
1272
+ },
1273
+ {
1274
+ name: "didit_workflow_get_field_definitions",
1275
+ description: "List every field you can branch on plus the operators valid for each (e.g. kyc.status, kyc.extra_fields.profession with `fuzzy_match`, document_ai.<key>, aml.risk_score). Call this before building branch rules so the field/operator pairs are valid.",
1276
+ inputSchema: {
1277
+ type: "object",
1278
+ properties: {
1279
+ workflow_id: { type: "string", description: "Any workflow in the target application (used to resolve the app). Its uuid or stable workflow_id from didit_workflow_search/list — NOT a label, slug or node id. An exact label is resolved when it matches exactly one workflow; otherwise the candidates are listed for you to pick." },
1280
+ feature: { type: "string", enum: feature_config_schema_1.WORKFLOW_FEATURES, description: "Return only fields for this feature to keep the response small" },
1281
+ ...orgapp_1.ORG_APP_PROPS,
1282
+ },
1283
+ required: ["workflow_id"],
1284
+ },
1285
+ },
1286
+ {
1287
+ name: "didit_workflow_get_feature_config_schema",
1288
+ description: "The exact `config` object each workflow feature accepts - every key, its type, bounds, " +
1289
+ "default, accepted values and meaning. Generated from the backend serializers that validate " +
1290
+ "a save (contract " + feature_config_schema_1.FEATURE_CONFIG_CHECKSUM + "), so it is never out of date with the API. " +
1291
+ "Call it before configuring a feature you have not configured before, and whenever a config " +
1292
+ "key you set came back missing: a key outside this contract is dropped silently. Pass " +
1293
+ "`feature` for one feature (" + feature_config_schema_1.WORKFLOW_FEATURES.join(", ") + "), or omit it for all of them.",
1294
+ inputSchema: {
1295
+ type: "object",
1296
+ properties: {
1297
+ feature: {
1298
+ type: "string",
1299
+ enum: feature_config_schema_1.WORKFLOW_FEATURES,
1300
+ description: "Restrict the answer to one feature. Omit for the whole contract.",
1301
+ },
1302
+ },
1303
+ },
1304
+ },
1305
+ {
1306
+ name: "didit_workflow_get_id_verification_methods_catalog",
1307
+ description: "The ID Verification methods catalog: per country, whether non-doc lookup (the user types their " +
1308
+ "national ID number and we check the official government database) is offered, which " +
1309
+ "digital-identity wallets (MitID, BankID, itsme, ...) are offered, their availability " +
1310
+ "(`available` can be enabled, `coming_soon` cannot), the plain-language request and response " +
1311
+ "fields, and catalog prices. Read this BEFORE setting `methods` on an OCR node: a method or " +
1312
+ "wallet that is not available for the country is rejected on save. Wallets are an accept-list " +
1313
+ "(no ordering). Every non-document price except the document price is a placeholder until " +
1314
+ "the pricing catalog is published. Pass `country` (ISO3) to get one country's view.",
1315
+ inputSchema: {
1316
+ type: "object",
1317
+ properties: {
1318
+ workflow_id: { type: "string", description: "Any workflow in the target application (used to resolve the app)" },
1319
+ country: { type: "string", description: "ISO 3166-1 alpha-3 code to narrow the catalog to one country (e.g. ZAF, DNK)" },
1320
+ ...orgapp_1.ORG_APP_PROPS,
1321
+ },
1322
+ required: ["workflow_id"],
1323
+ },
1324
+ },
1325
+ {
1326
+ name: "didit_workflow_get_kyb_registry_catalog",
1327
+ description: "The KYB registry catalog: per country (ISO-2, unlike `methods`/`documents_allowed` which are " +
1328
+ "ISO-3), which company-data tiers the registries offer - `basic` (Lite: company profile), " +
1329
+ "`shareholders`, `ubo` (beneficial owners) - with their retail price per company selected, and " +
1330
+ "whether continuous registry monitoring is sold there (per company per year). Read this BEFORE " +
1331
+ "writing `kyb_registry_countries_config` with a tier other than `basic`, or switching " +
1332
+ "`kyb_registry_monitoring_enabled` on: a tier the country does not offer is rejected on save, and " +
1333
+ "monitoring only applies to countries at an ownership tier where it is available. A company the " +
1334
+ "applicant types in by hand is billed a flat fee instead. Without `countries` you get a summary " +
1335
+ "(counts, the countries with no registry, the Lite-only ones); pass `countries` for the exact " +
1336
+ "per-country table. Prices here are the catalog's retail prices, not placeholders.",
1337
+ inputSchema: {
1338
+ type: "object",
1339
+ properties: {
1340
+ countries: {
1341
+ type: "array",
1342
+ items: { type: "string" },
1343
+ description: "ISO 3166-1 alpha-2 codes to narrow the catalog to (e.g. [\"ES\", \"DE\"]). Omit for the summary.",
1344
+ },
1345
+ },
1346
+ },
1347
+ },
1348
+ {
1349
+ name: "didit_workflow_get_branch_fields",
1350
+ description: "Given a candidate graph and a branch node, return the fields actually available at that point (only features that completed on every path reaching the branch, plus dynamically-derived Document-AI/questionnaire fields).",
1351
+ inputSchema: {
1352
+ type: "object",
1353
+ properties: {
1354
+ workflow_id: { type: "string", description: "Workflow version uuid or stable workflow_id" },
1355
+ graph: {
1356
+ ...WORKFLOW_GRAPH_SCHEMA,
1357
+ description: "REQUIRED. The candidate graph to evaluate: the `graph` object returned by didit_workflow_get_graph / ui_workflow_get_graph (start_node + nodes), optionally with your unsaved edits applied.",
1358
+ },
1359
+ branch_node_id: { type: "string", description: "REQUIRED. The id of a branch node in that graph (a key of graph.nodes whose node_type is 'branch') — availability is evaluated at that point." },
1360
+ ...orgapp_1.ORG_APP_PROPS,
1361
+ },
1362
+ required: ["workflow_id", "graph", "branch_node_id"],
1363
+ },
1364
+ },
1365
+ {
1366
+ name: "didit_workflow_validate_graph",
1367
+ description: "Dry-run validate a graph WITHOUT saving. Returns per-node errors (bad field/operator, missing dependency, branching on a field before its feature runs, etc.). Always validate before didit_workflow_set_graph.",
1368
+ inputSchema: {
1369
+ type: "object",
1370
+ properties: {
1371
+ workflow_id: {
1372
+ type: "string",
1373
+ description: "Workflow version uuid or stable workflow_id. OPTIONAL: omit to validate a graph for a workflow " +
1374
+ "that does not exist yet (an unsaved canvas); pass workflow_type instead when KYC/KYB matters.",
1375
+ },
1376
+ workflow_type: { type: "string", enum: ["kyc", "kyb"], description: "Segregation check for a not-yet-created workflow." },
1377
+ graph: WORKFLOW_GRAPH_SCHEMA,
1378
+ include_config: { type: "boolean", description: "Return the validated graph's full feature configs (default false summarizes large values)" },
1379
+ ...orgapp_1.ORG_APP_PROPS,
1380
+ },
1381
+ required: ["graph"],
1382
+ },
1383
+ },
1384
+ {
1385
+ name: "didit_workflow_edit_graph",
1386
+ description: "MODIFY an existing workflow's graph with small OPERATIONS - the right tool for editing a live workflow. You send only the deltas; the MCP fetches the full current graph SERVER-SIDE, applies your ops in order, validates, auto-creates a DRAFT (the live version is never touched), and saves. This means huge feature configs (documents_allowed, poa_documents_allowed, phone countries) are preserved exactly and you NEVER resend them. Validation failures return `applied:false` with the errors (nothing saved). The six op shapes are documented on the `operations` parameter; a typical edit upserts new nodes with set_node and rewires their neighbors with set_next. To branch after a feature node, point its `next` at a new branch node whose `branches` carry the rules (from didit_workflow_get_field_definitions) and whose goto targets are new status or feature nodes.",
1387
+ inputSchema: {
1388
+ type: "object",
1389
+ properties: {
1390
+ workflow_id: { type: "string", description: "Workflow version uuid or stable workflow_id" },
1391
+ operations: {
1392
+ type: "array",
1393
+ minItems: 1,
1394
+ description: "Ordered edits applied to the full server-side graph. Each: one of — {op:'set_node', node_id, node:{…}} upsert a node; {op:'remove_node', node_id}; {op:'set_next', node_id, next:'<id|null>'} rewire a node's unconditional next; {op:'set_branches', node_id, branches:[…]} set conditional branches; {op:'merge_node_config', node_id, config:{…}} shallow-merge config keys (preserves the big allow-lists); {op:'set_start', start_node}.",
1395
+ items: { type: "object", properties: { op: { type: "string", enum: ["set_node", "remove_node", "set_next", "set_branches", "merge_node_config", "set_start"] }, node_id: { type: "string" }, node: { type: "object" }, next: { type: ["string", "null"] }, branches: { type: "array", items: { type: "object" } }, config: { type: "object" }, start_node: { type: "string" } }, required: ["op"] },
1396
+ },
1397
+ publish: { type: "boolean", description: "Publish after saving (default false → leaves a reviewable DRAFT)" },
1398
+ ...orgapp_1.ORG_APP_PROPS,
1399
+ },
1400
+ required: ["workflow_id", "operations"],
1401
+ },
1402
+ },
1403
+ {
1404
+ name: "didit_workflow_set_graph",
1405
+ description: "Replace a workflow's ENTIRE node/graph. Use this only to build a NEW/small workflow from scratch — to modify an EXISTING workflow prefer didit_workflow_edit_graph (you'd otherwise have to resend every node incl. multi-100KB allow-lists). If the workflow is published, a DRAFT is auto-created and the graph applied there (a live version is NEVER mutated); reviewable DRAFT unless `publish:true`. Validate first. Example graph: OCR → branch[ kyc.status==Declined → status(Declined); kyc.extra_fields.profession fuzzy_match 'Software Engineer' score 80 → DOCUMENT_AI(proof of funds) → status(Determine) ; else → status(Determine) ].",
1406
+ inputSchema: {
1407
+ type: "object",
1408
+ properties: {
1409
+ workflow_id: { type: "string", description: "Workflow version uuid or stable workflow_id" },
1410
+ graph: WORKFLOW_GRAPH_SCHEMA,
1411
+ publish: { type: "boolean", description: "Publish the draft after saving (default false → leaves a reviewable DRAFT)" },
1412
+ ...orgapp_1.ORG_APP_PROPS,
1413
+ },
1414
+ required: ["workflow_id", "graph"],
1415
+ },
1416
+ },
1417
+ {
1418
+ name: "didit_workflow_create_draft",
1419
+ description: "Create an editable DRAFT version from a published workflow (graph/config edits require a DRAFT). Returns the new draft's uuid.",
1420
+ inputSchema: {
1421
+ type: "object",
1422
+ properties: {
1423
+ workflow_id: { type: "string", description: "Workflow version uuid or stable workflow_id" },
1424
+ ...orgapp_1.ORG_APP_PROPS,
1425
+ },
1426
+ required: ["workflow_id"],
1427
+ },
1428
+ },
1429
+ {
1430
+ name: "didit_workflow_publish",
1431
+ description: "Publish the workflow version that holds the pending changes — makes it live for NEW sessions. Existing sessions are unaffected. Pass the `version_uuid` that set_graph/edit_graph returned: a published version can never hold an edit, so a stable workflow_id resolves to the version that is ALREADY live. Publishing a live version with no draft is refused instead of reported as done.",
1432
+ inputSchema: {
1433
+ type: "object",
1434
+ properties: {
1435
+ workflow_id: { type: "string", description: "The DRAFT version uuid to publish — the `version_uuid` returned by didit_workflow_set_graph / didit_workflow_edit_graph. A stable workflow_id also resolves, and then the draft holding the changes is published rather than the version already live." },
1436
+ ...orgapp_1.ORG_APP_PROPS,
1437
+ },
1438
+ required: ["workflow_id"],
1439
+ },
1440
+ },
499
1441
  // ── Questionnaires ──────────────────────────────────────────────────
500
1442
  {
501
- name: "didit_list_questionnaires",
1443
+ name: "didit_questionnaire_list",
502
1444
  description: "List all custom questionnaires for your application.",
503
- inputSchema: { type: "object", properties: {} },
1445
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS } },
504
1446
  },
505
1447
  {
506
- name: "didit_create_questionnaire",
507
- description: "Create a custom questionnaire with questions, branching logic, and multi-language support.",
1448
+ name: "didit_questionnaire_create",
1449
+ description: "Create a custom questionnaire from an ordered list of questions. Send `title` + `form_elements` (an array of form-element objects, each with an UPPERCASE element_type) — NOT `questions`. The MCP assembles them into the questionnaire graph the backend stores (node ids and their ordering are derived here), so send the questions in the order the user should answer them and never build a graph yourself. Pass status:'draft' to keep it unpublished. A choice list longer than ~100 options does NOT fit in one call (the call is emitted token by token and gets cut off mid-JSON): create with status:'draft' carrying only the first ~100 choices, then add the rest with didit_questionnaire_append_choices in batches (its publish flag publishes with the final batch — a published questionnaire cannot be edited further).",
508
1450
  inputSchema: {
509
1451
  type: "object",
510
1452
  properties: {
1453
+ ...orgapp_1.ORG_APP_PROPS,
511
1454
  title: { type: "string", description: "Questionnaire title" },
512
1455
  description: { type: "string", description: "Description shown to the user" },
513
- questions: {
1456
+ ...FORM_ELEMENTS_PROP,
1457
+ ...QUESTIONNAIRE_LANG_PROPS,
1458
+ ...QUESTIONNAIRE_CREATE_STATUS_PROP,
1459
+ },
1460
+ required: ["title", "form_elements"],
1461
+ },
1462
+ },
1463
+ {
1464
+ name: "didit_questionnaire_append_choices",
1465
+ description: "Append a batch of answer options to ONE question of an existing DRAFT questionnaire (create it with status:'draft' — a published questionnaire cannot be edited). Use it for long choice lists: create with the first ~100 choices, then append the rest here in batches of ~100 until the source list is exhausted, passing publish:true on the FINAL batch to publish. Choices the question already has (same value) are skipped, so retrying a batch never duplicates. Returns a compact summary whose total_choices is the stored count — verify against it instead of re-fetching the questionnaire.",
1466
+ inputSchema: {
1467
+ type: "object",
1468
+ properties: {
1469
+ ...orgapp_1.ORG_APP_PROPS,
1470
+ questionnaire_id: { type: "string", description: "Questionnaire UUID" },
1471
+ node_id: {
1472
+ type: "string",
1473
+ description: "Graph node id of the question (e.g. 'q1', positional from the create call). Optional when exactly one question has choices.",
1474
+ },
1475
+ choices: {
514
1476
  type: "array",
515
- description: "Array of question objects with type, text, options, and optional branching",
1477
+ items: { type: "object" },
1478
+ description: "Batch of choices to append, ~100 per call maximum. Each: { value, label?, requires_text_input? }",
1479
+ },
1480
+ publish: {
1481
+ type: "boolean",
1482
+ description: "Pass true on the LAST batch to publish the questionnaire; intermediate batches keep it a draft.",
516
1483
  },
517
1484
  },
518
- required: ["title", "questions"],
1485
+ required: ["questionnaire_id", "choices"],
519
1486
  },
520
1487
  },
521
1488
  {
522
- name: "didit_get_questionnaire",
523
- description: "Get full details of a specific questionnaire (questions, options, translations).",
1489
+ name: "didit_questionnaire_get",
1490
+ description: "Get questionnaire questions and options. Translations are summarized to one locale by default to keep the response consumable; pass include_translations:true for every locale.",
524
1491
  inputSchema: {
525
1492
  type: "object",
526
1493
  properties: {
1494
+ ...orgapp_1.ORG_APP_PROPS,
527
1495
  questionnaire_id: { type: "string", description: "Questionnaire UUID" },
1496
+ include_translations: { type: "boolean", description: "Return every locale translation (default false returns English or the first available locale)" },
528
1497
  },
529
1498
  required: ["questionnaire_id"],
530
1499
  },
531
1500
  },
532
1501
  {
533
- name: "didit_update_questionnaire",
534
- description: "Update a questionnaire's title, description, questions, or translations.",
1502
+ name: "didit_questionnaire_update",
1503
+ description: "Overwrite a questionnaire's supplied settings. Sending form_elements REPLACES the entire question list, removing omitted questions; pass every question to keep, in order, with UPPERCASE element_type. Omitted status preserves the current draft/published state; publication changes only when status is explicitly passed. Before calling, show the questionnaire and proposed changes and obtain explicit user confirmation, including the full replacement when form_elements is supplied.",
535
1504
  inputSchema: {
536
1505
  type: "object",
537
1506
  properties: {
1507
+ ...orgapp_1.ORG_APP_PROPS,
538
1508
  questionnaire_id: { type: "string", description: "Questionnaire UUID" },
539
1509
  title: { type: "string" },
540
1510
  description: { type: "string" },
541
- questions: { type: "array" },
1511
+ ...FORM_ELEMENTS_PROP,
1512
+ ...QUESTIONNAIRE_LANG_PROPS,
1513
+ ...QUESTIONNAIRE_UPDATE_STATUS_PROP,
542
1514
  },
543
1515
  required: ["questionnaire_id"],
544
1516
  },
545
1517
  },
546
1518
  {
547
- name: "didit_delete_questionnaire",
1519
+ name: "didit_questionnaire_delete",
548
1520
  description: "Delete a questionnaire.",
549
1521
  inputSchema: {
550
1522
  type: "object",
551
1523
  properties: {
1524
+ ...orgapp_1.ORG_APP_PROPS,
552
1525
  questionnaire_id: { type: "string", description: "Questionnaire UUID" },
553
1526
  },
554
1527
  required: ["questionnaire_id"],
@@ -556,22 +1529,24 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
556
1529
  },
557
1530
  // ── Users (verified individuals / KYC) ──────────────────────────────
558
1531
  {
559
- name: "didit_list_users",
560
- description: "List verified users (grouped by vendor_data). Supports limit/offset pagination.",
1532
+ name: "didit_vendor_user_list",
1533
+ description: "List verified users (grouped by vendor_data) for ONE app; with multiple apps (or no scope) it auto-spans all your apps. For a cross-app customer lookup prefer didit_vendor_user_search. Supports limit/offset pagination.",
561
1534
  inputSchema: {
562
1535
  type: "object",
563
1536
  properties: {
1537
+ ...orgapp_1.ORG_APP_PROPS,
564
1538
  limit: { type: "string" },
565
1539
  offset: { type: "string" },
566
1540
  },
567
1541
  },
568
1542
  },
569
1543
  {
570
- name: "didit_create_user",
1544
+ name: "didit_vendor_user_create",
571
1545
  description: "Create a user record manually (e.g. to pre-register a vendor_data identity or attach allowlisted emails/phones).",
572
1546
  inputSchema: {
573
1547
  type: "object",
574
1548
  properties: {
1549
+ ...orgapp_1.ORG_APP_PROPS,
575
1550
  vendor_data: { type: "string", description: "REQUIRED. Your unique identifier for the user" },
576
1551
  full_name: { type: "string" },
577
1552
  display_name: { type: "string" },
@@ -586,22 +1561,24 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
586
1561
  },
587
1562
  },
588
1563
  {
589
- name: "didit_get_user",
1564
+ name: "didit_vendor_user_get",
590
1565
  description: "Get details of a specific user by their vendor_data identifier.",
591
1566
  inputSchema: {
592
1567
  type: "object",
593
1568
  properties: {
1569
+ ...orgapp_1.ORG_APP_PROPS,
594
1570
  vendor_data: { type: "string", description: "The vendor_data value that identifies the user" },
595
1571
  },
596
1572
  required: ["vendor_data"],
597
1573
  },
598
1574
  },
599
1575
  {
600
- name: "didit_update_user",
601
- description: "Update a user's profile fields. Only send the fields you want to change. To change ONLY the monitoring status, prefer didit_update_user_status.",
1576
+ name: "didit_vendor_user_update",
1577
+ description: "Update a user's profile fields. Only send the fields you want to change. To change ONLY the monitoring status, prefer didit_vendor_user_update_status.",
602
1578
  inputSchema: {
603
1579
  type: "object",
604
1580
  properties: {
1581
+ ...orgapp_1.ORG_APP_PROPS,
605
1582
  vendor_data: { type: "string", description: "The vendor_data value that identifies the user" },
606
1583
  full_name: { type: "string" },
607
1584
  display_name: { type: "string" },
@@ -616,11 +1593,12 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
616
1593
  },
617
1594
  },
618
1595
  {
619
- name: "didit_update_user_status",
1596
+ name: "didit_vendor_user_update_status",
620
1597
  description: "Set a user's monitoring status (ACTIVE, FLAGGED, or BLOCKED).",
621
1598
  inputSchema: {
622
1599
  type: "object",
623
1600
  properties: {
1601
+ ...orgapp_1.ORG_APP_PROPS,
624
1602
  vendor_data: { type: "string", description: "The vendor_data value that identifies the user" },
625
1603
  status: { type: "string", enum: ENTITY_STATUSES, description: "New status" },
626
1604
  },
@@ -628,38 +1606,45 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
628
1606
  },
629
1607
  },
630
1608
  {
631
- name: "didit_delete_users",
1609
+ name: "didit_vendor_user_delete",
632
1610
  description: "Batch delete users by vendor_data list, or delete all users.",
633
1611
  inputSchema: {
634
1612
  type: "object",
635
1613
  properties: {
1614
+ ...orgapp_1.ORG_APP_PROPS,
636
1615
  vendor_data_list: {
637
1616
  type: "array",
638
1617
  items: { type: "string" },
639
1618
  description: "Array of vendor_data values to delete",
640
1619
  },
641
1620
  delete_all: { type: "boolean", description: "Set true to delete ALL users" },
1621
+ confirm: {
1622
+ type: "boolean",
1623
+ description: "REQUIRED when delete_all is true - permanently removes EVERY vendor user. Only set after explicit user confirmation of this exact action.",
1624
+ },
642
1625
  },
643
1626
  },
644
1627
  },
645
1628
  // ── Businesses (KYB) ────────────────────────────────────────────────
646
1629
  {
647
- name: "didit_list_businesses",
648
- description: "List verified businesses (KYB, grouped by vendor_data). Supports limit/offset pagination.",
1630
+ name: "didit_vendor_business_list",
1631
+ description: "List verified businesses (KYB, grouped by vendor_data) for ONE app; with multiple apps (or no scope) it auto-spans all your apps. For a cross-app lookup prefer didit_vendor_business_search. Supports limit/offset pagination.",
649
1632
  inputSchema: {
650
1633
  type: "object",
651
1634
  properties: {
1635
+ ...orgapp_1.ORG_APP_PROPS,
652
1636
  limit: { type: "string" },
653
1637
  offset: { type: "string" },
654
1638
  },
655
1639
  },
656
1640
  },
657
1641
  {
658
- name: "didit_create_business",
1642
+ name: "didit_vendor_business_create",
659
1643
  description: "Create a business record manually (KYB).",
660
1644
  inputSchema: {
661
1645
  type: "object",
662
1646
  properties: {
1647
+ ...orgapp_1.ORG_APP_PROPS,
663
1648
  vendor_data: { type: "string", description: "Your unique identifier for the business" },
664
1649
  display_name: { type: "string" },
665
1650
  legal_name: { type: "string" },
@@ -671,22 +1656,24 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
671
1656
  },
672
1657
  },
673
1658
  {
674
- name: "didit_get_business",
1659
+ name: "didit_vendor_business_get",
675
1660
  description: "Get details of a specific business by its vendor_data identifier.",
676
1661
  inputSchema: {
677
1662
  type: "object",
678
1663
  properties: {
1664
+ ...orgapp_1.ORG_APP_PROPS,
679
1665
  vendor_data: { type: "string", description: "The vendor_data value that identifies the business" },
680
1666
  },
681
1667
  required: ["vendor_data"],
682
1668
  },
683
1669
  },
684
1670
  {
685
- name: "didit_update_business",
1671
+ name: "didit_vendor_business_update",
686
1672
  description: "Update a business's profile fields. Only send the fields you want to change.",
687
1673
  inputSchema: {
688
1674
  type: "object",
689
1675
  properties: {
1676
+ ...orgapp_1.ORG_APP_PROPS,
690
1677
  vendor_data: { type: "string" },
691
1678
  display_name: { type: "string" },
692
1679
  legal_name: { type: "string" },
@@ -699,11 +1686,12 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
699
1686
  },
700
1687
  },
701
1688
  {
702
- name: "didit_update_business_status",
1689
+ name: "didit_vendor_business_update_status",
703
1690
  description: "Set a business's monitoring status (ACTIVE, FLAGGED, or BLOCKED).",
704
1691
  inputSchema: {
705
1692
  type: "object",
706
1693
  properties: {
1694
+ ...orgapp_1.ORG_APP_PROPS,
707
1695
  vendor_data: { type: "string" },
708
1696
  status: { type: "string", enum: ENTITY_STATUSES, description: "New status" },
709
1697
  },
@@ -711,35 +1699,42 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
711
1699
  },
712
1700
  },
713
1701
  {
714
- name: "didit_delete_businesses",
1702
+ name: "didit_vendor_business_delete",
715
1703
  description: "Batch delete businesses by vendor_data list and/or didit_internal_id list, or delete all businesses.",
716
1704
  inputSchema: {
717
1705
  type: "object",
718
1706
  properties: {
1707
+ ...orgapp_1.ORG_APP_PROPS,
719
1708
  vendor_data_list: { type: "array", items: { type: "string" } },
720
1709
  didit_internal_id_list: { type: "array", items: { type: "string" } },
721
1710
  delete_all: { type: "boolean", description: "Set true to delete ALL businesses" },
1711
+ confirm: {
1712
+ type: "boolean",
1713
+ description: "REQUIRED when delete_all is true - permanently removes EVERY vendor business. Only set after explicit user confirmation of this exact action.",
1714
+ },
722
1715
  },
723
1716
  },
724
1717
  },
725
1718
  // ── Transactions (AML transaction monitoring) ───────────────────────
726
1719
  {
727
- name: "didit_list_transactions",
728
- description: "List monitored transactions. Supports limit/offset pagination.",
1720
+ name: "didit_transaction_list",
1721
+ description: "List monitored transactions for ONE app; with multiple apps (or no scope) it auto-spans all your apps. For a cross-app query prefer didit_transaction_search. Supports limit/offset pagination.",
729
1722
  inputSchema: {
730
1723
  type: "object",
731
1724
  properties: {
1725
+ ...orgapp_1.ORG_APP_PROPS,
732
1726
  limit: { type: "string" },
733
1727
  offset: { type: "string" },
734
1728
  },
735
1729
  },
736
1730
  },
737
1731
  {
738
- name: "didit_create_transaction",
1732
+ name: "didit_transaction_create",
739
1733
  description: "Submit a transaction for monitoring and rule evaluation. transaction_details and subject shapes depend on transaction_category.",
740
1734
  inputSchema: {
741
1735
  type: "object",
742
1736
  properties: {
1737
+ ...orgapp_1.ORG_APP_PROPS,
743
1738
  transaction_id: { type: "string", description: "REQUIRED. Your unique transaction identifier" },
744
1739
  transaction_category: {
745
1740
  type: "string",
@@ -760,22 +1755,24 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
760
1755
  },
761
1756
  },
762
1757
  {
763
- name: "didit_get_transaction",
1758
+ name: "didit_transaction_get",
764
1759
  description: "Get a single monitored transaction and its rule-evaluation result.",
765
1760
  inputSchema: {
766
1761
  type: "object",
767
1762
  properties: {
1763
+ ...orgapp_1.ORG_APP_PROPS,
768
1764
  transaction_id: { type: "string", description: "Transaction ID" },
769
1765
  },
770
1766
  required: ["transaction_id"],
771
1767
  },
772
1768
  },
773
1769
  {
774
- name: "didit_screen_wallet",
1770
+ name: "didit_transaction_screen_wallet",
775
1771
  description: "Screen a single crypto wallet address for AML risk WITHOUT creating a transaction. Returns risk_score, severity, sanctions_hit, source/destination of funds. Requires transaction monitoring to be configured (a provider key) or returns 409.",
776
1772
  inputSchema: {
777
1773
  type: "object",
778
1774
  properties: {
1775
+ ...orgapp_1.ORG_APP_PROPS,
779
1776
  wallet_address: { type: "string", description: "REQUIRED. The crypto address to screen (must match the chain's address format)" },
780
1777
  blockchain: {
781
1778
  type: "string",
@@ -791,14 +1788,204 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
791
1788
  required: ["wallet_address", "blockchain"],
792
1789
  },
793
1790
  },
1791
+ ...(0, internal_tools_1.internalToolDefs)("transaction_sdk_token"),
1792
+ {
1793
+ name: "didit_transaction_rule_list",
1794
+ description: "List transaction-monitoring rules for one app. Filter by source (PRESET or CUSTOM), category, mode " +
1795
+ "(ACTIVE evaluates and acts, TEST evaluates and records but skips actions, DISABLED is skipped), bundle, " +
1796
+ "or free-text search. ordering accepts one or more comma-separated fields; prefix a field with '-' to reverse it.",
1797
+ inputSchema: {
1798
+ type: "object",
1799
+ properties: {
1800
+ ...orgapp_1.ORG_APP_PROPS,
1801
+ source: { type: "string", enum: ["PRESET", "CUSTOM"] },
1802
+ category: { type: "string" },
1803
+ mode: { type: "string", enum: ["ACTIVE", "DISABLED", "TEST"] },
1804
+ bundle: { type: "string" },
1805
+ search: { type: "string" },
1806
+ ordering: {
1807
+ type: "string",
1808
+ description: "Comma-separated fields from run_count, approved_pct, reviewed_pct, declined_pct, " +
1809
+ "latest_triggered_at, title, created_at, source. Prefix any field with '-' for descending order.",
1810
+ },
1811
+ limit: { type: "string" },
1812
+ offset: { type: "string" },
1813
+ },
1814
+ },
1815
+ },
1816
+ {
1817
+ name: "didit_transaction_rule_get",
1818
+ description: "Get one transaction-monitoring rule, including its persisted conditions, aggregation, scope, actions, and counters.",
1819
+ inputSchema: {
1820
+ type: "object",
1821
+ properties: {
1822
+ ...orgapp_1.ORG_APP_PROPS,
1823
+ rule_uuid: { type: "string", description: "REQUIRED. Rule UUID from didit_transaction_rule_list." },
1824
+ },
1825
+ required: ["rule_uuid"],
1826
+ },
1827
+ },
1828
+ {
1829
+ name: "didit_transaction_rule_create",
1830
+ description: "Create a CUSTOM transaction-monitoring rule. Include the entire requested persisted rule in this call: " +
1831
+ "conditions, aggregation checks, and actions. Backtest accepts a hypothetical config but never attaches " +
1832
+ "aggregation or actions to a created rule. Prefer mode:'TEST', backtest the exact saved config, then switch " +
1833
+ "to ACTIVE only after confirming the hit rate. title is unique among non-deleted rules in the app. " +
1834
+ "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.",
1836
+ inputSchema: {
1837
+ type: "object",
1838
+ properties: {
1839
+ ...orgapp_1.ORG_APP_PROPS,
1840
+ title: { type: "string", description: "REQUIRED. Unique per application." },
1841
+ category: { type: "string", description: "REQUIRED. Rule category, e.g. finance or aml_ctf." },
1842
+ mode: {
1843
+ type: "string",
1844
+ enum: ["ACTIVE", "DISABLED", "TEST"],
1845
+ description: "REQUIRED. Prefer TEST for a new or materially changed rule.",
1846
+ },
1847
+ description: { type: "string" },
1848
+ ...RULE_EVALUATION_MODE_PROP,
1849
+ ...RULE_SCOPE_PROP,
1850
+ ...RULE_CONDITIONS_PROP,
1851
+ ...RULE_AGGREGATION_PROP,
1852
+ ...RULE_ACTIONS_PROP,
1853
+ metadata: { type: "object", description: "Free-form key/value metadata." },
1854
+ },
1855
+ required: ["title", "category", "mode", "actions"],
1856
+ },
1857
+ },
1858
+ {
1859
+ name: "didit_transaction_rule_update",
1860
+ 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 " +
1862
+ "in TEST until the result is acceptable.",
1863
+ inputSchema: {
1864
+ type: "object",
1865
+ properties: {
1866
+ ...orgapp_1.ORG_APP_PROPS,
1867
+ rule_uuid: { type: "string", description: "REQUIRED. Rule UUID." },
1868
+ title: { type: "string" },
1869
+ category: { type: "string" },
1870
+ mode: { type: "string", enum: ["ACTIVE", "DISABLED", "TEST"] },
1871
+ description: { type: "string" },
1872
+ ...RULE_EVALUATION_MODE_PROP,
1873
+ ...RULE_SCOPE_PROP,
1874
+ ...RULE_CONDITIONS_PROP,
1875
+ ...RULE_AGGREGATION_PROP,
1876
+ ...RULE_ACTIONS_PROP,
1877
+ metadata: { type: "object" },
1878
+ },
1879
+ required: ["rule_uuid"],
1880
+ },
1881
+ },
1882
+ {
1883
+ name: "didit_transaction_rule_delete",
1884
+ description: "Delete a CUSTOM transaction-monitoring rule. PRESET rules must be removed with didit_transaction_rule_uninstall.",
1885
+ inputSchema: {
1886
+ type: "object",
1887
+ properties: {
1888
+ ...orgapp_1.ORG_APP_PROPS,
1889
+ rule_uuid: { type: "string", description: "REQUIRED. Rule UUID." },
1890
+ },
1891
+ required: ["rule_uuid"],
1892
+ },
1893
+ },
1894
+ {
1895
+ name: "didit_transaction_rule_backtest",
1896
+ description: "Dry-run a hypothetical rule config against up to the 10,000 most recent transactions in the app. This " +
1897
+ "writes nothing, accepts no rule_uuid, and never changes or completes a saved rule. To test a saved rule, " +
1898
+ "read it first and pass its exact conditions, aggregation, evaluation_mode, and scope here.",
1899
+ inputSchema: {
1900
+ type: "object",
1901
+ properties: {
1902
+ ...orgapp_1.ORG_APP_PROPS,
1903
+ ...RULE_CONDITIONS_PROP,
1904
+ ...RULE_AGGREGATION_PROP,
1905
+ ...RULE_EVALUATION_MODE_PROP,
1906
+ ...RULE_SCOPE_PROP,
1907
+ period_days: {
1908
+ type: "integer",
1909
+ minimum: 1,
1910
+ maximum: 365,
1911
+ description: "Days of history to evaluate, from 1 through 365. Default 90.",
1912
+ },
1913
+ },
1914
+ },
1915
+ },
1916
+ {
1917
+ name: "didit_transaction_rule_library_list",
1918
+ description: "List Didit's preset rule library. Each entry includes its full config, bundle, tags, industries, and is_installed. " +
1919
+ "Filter by bundle, category, or search; paginated.",
1920
+ inputSchema: {
1921
+ type: "object",
1922
+ properties: {
1923
+ ...orgapp_1.ORG_APP_PROPS,
1924
+ bundle: { type: "string" },
1925
+ category: { type: "string" },
1926
+ search: { type: "string" },
1927
+ limit: { type: "string" },
1928
+ offset: { type: "string" },
1929
+ },
1930
+ },
1931
+ },
1932
+ {
1933
+ name: "didit_transaction_rule_install",
1934
+ description: "Install PRESET rules by library_keys, bundle, or both. If both are supplied, only keys in that bundle are " +
1935
+ "installed. At least one selector is required. Installed rules start ACTIVE when transaction monitoring is " +
1936
+ "enabled for the app, otherwise DISABLED. Set TEST explicitly before relying on a newly installed rule.",
1937
+ inputSchema: {
1938
+ type: "object",
1939
+ properties: {
1940
+ ...orgapp_1.ORG_APP_PROPS,
1941
+ library_keys: {
1942
+ type: "array",
1943
+ items: { type: "string" },
1944
+ description: "Specific preset library_key values to install.",
1945
+ },
1946
+ bundle: { type: "string", description: "Install presets from this bundle." },
1947
+ },
1948
+ anyOf: [{ required: ["library_keys"] }, { required: ["bundle"] }],
1949
+ },
1950
+ },
1951
+ {
1952
+ name: "didit_transaction_rule_uninstall",
1953
+ description: "Remove installed PRESET rules by library_keys, bundle, or both. If both are supplied, only keys in that " +
1954
+ "bundle are removed. At least one selector is required. To pause without removing, update mode to DISABLED.",
1955
+ inputSchema: {
1956
+ type: "object",
1957
+ properties: {
1958
+ ...orgapp_1.ORG_APP_PROPS,
1959
+ library_keys: {
1960
+ type: "array",
1961
+ items: { type: "string" },
1962
+ description: "Specific preset library_key values to uninstall.",
1963
+ },
1964
+ bundle: { type: "string", description: "Uninstall presets from this bundle." },
1965
+ },
1966
+ anyOf: [{ required: ["library_keys"] }, { required: ["bundle"] }],
1967
+ },
1968
+ },
1969
+ // ── Travel Rule (FATF / EU TFR managed exchange) ─────────────────────
1970
+ ...(0, internal_tools_1.internalToolDefs)("travel_rule"),
1971
+ // ── Marketplace (provider catalog & connections) ─────────────────────
1972
+ ...(0, internal_tools_1.internalToolDefs)("marketplace"),
794
1973
  // ── Billing ─────────────────────────────────────────────────────────
795
1974
  {
796
- name: "didit_get_balance",
797
- description: "Get current credit balance and auto-refill settings.",
798
- inputSchema: { type: "object", properties: {} },
1975
+ 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.",
1985
+ inputSchema: { type: "object", properties: { organization_id: orgapp_1.ORG_APP_PROPS.organization_id } },
799
1986
  },
800
1987
  {
801
- name: "didit_top_up",
1988
+ name: "didit_org_top_up",
802
1989
  description: "Create a Stripe checkout session to top up credits. Returns a checkout URL.",
803
1990
  inputSchema: {
804
1991
  type: "object",
@@ -806,40 +1993,54 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
806
1993
  amount_in_dollars: { type: "number", description: "Amount in USD (minimum $50)" },
807
1994
  success_url: { type: "string", description: "Optional redirect after successful payment" },
808
1995
  cancel_url: { type: "string", description: "Optional redirect if payment is cancelled" },
1996
+ confirm: {
1997
+ 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.",
1999
+ },
809
2000
  },
810
2001
  required: ["amount_in_dollars"],
811
2002
  },
812
2003
  },
813
2004
  // ── Customization (verification UI branding) ────────────────────────
814
2005
  {
815
- name: "didit_get_customization",
2006
+ name: "didit_branding_get",
816
2007
  description: "Get the current branding customization (logos, colors) applied to your verification UI.",
817
- inputSchema: { type: "object", properties: {} },
2008
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS } },
818
2009
  },
819
2010
  {
820
- name: "didit_update_customization",
821
- description: "Update verification UI branding images. Provide absolute file paths for the images you want to set.",
2011
+ name: "didit_branding_update",
2012
+ description: "Update verification UI branding images and/or the SMS sender name. Each image is a local absolute *_path (local/stdio runs) or inline *_base64 content (hosted runs).",
822
2013
  inputSchema: {
823
2014
  type: "object",
824
2015
  properties: {
825
- image_square_path: { type: "string", description: "Absolute path to a square logo image" },
826
- image_rectangular_path: { type: "string", description: "Absolute path to a rectangular logo image" },
827
- image_favicon_path: { type: "string", description: "Absolute path to a favicon image" },
2016
+ ...orgapp_1.ORG_APP_PROPS,
2017
+ image_square_path: { type: "string", description: "Absolute path to a square logo image (local/stdio only)" },
2018
+ image_rectangular_path: { type: "string", description: "Absolute path to a rectangular logo image (local/stdio only)" },
2019
+ image_favicon_path: { type: "string", description: "Absolute path to a favicon image (local/stdio only)" },
2020
+ image_square_base64: { type: "string", description: "Square logo as base64 or data URL (or an attachment reference like att_1)" },
2021
+ image_rectangular_base64: { type: "string", description: "Rectangular logo as base64 or data URL (or an attachment reference like att_1)" },
2022
+ image_favicon_base64: { type: "string", description: "Favicon as base64 or data URL (or an attachment reference like att_1)" },
2023
+ sms_sender_name: {
2024
+ type: ["string", "null"],
2025
+ maxLength: 30,
2026
+ description: "The name every SMS verification code of this application carries (\"123456 is your verification code for Acme Bank\"), in every workflow and through the phone verification API. Free. 1 to 30 characters: letters, digits, spaces and ' & - ! only, not only digits, single spaces between words. Empty string or null clears it. WhatsApp codes are not branded.",
2027
+ },
828
2028
  },
829
2029
  },
830
2030
  },
831
2031
  // ── Webhook destinations ────────────────────────────────────────────
832
2032
  {
833
- name: "didit_list_webhook_destinations",
834
- description: "List configured webhook destinations. Each destination has its own URL, version, enabled flag, subscribed events, and signing secret.",
835
- inputSchema: { type: "object", properties: {} },
2033
+ name: "didit_webhook_list",
2034
+ description: "List configured webhook destinations. Each destination has its own URL, version, enabled flag, subscribed events, and redacted signing-secret metadata.",
2035
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS } },
836
2036
  },
837
2037
  {
838
- name: "didit_create_webhook_destination",
839
- description: "Create a webhook destination. The response includes the signing secret used to verify the X-Signature header on delivered events.",
2038
+ name: "didit_webhook_create",
2039
+ description: "Create a webhook destination. The signing secret is redacted in the response.",
840
2040
  inputSchema: {
841
2041
  type: "object",
842
2042
  properties: {
2043
+ ...orgapp_1.ORG_APP_PROPS,
843
2044
  label: { type: "string", description: "REQUIRED. Human-readable name" },
844
2045
  url: { type: "string", description: "REQUIRED. HTTPS endpoint to receive events" },
845
2046
  enabled: { type: "boolean", description: "Whether the destination receives events (default true)" },
@@ -850,22 +2051,24 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
850
2051
  },
851
2052
  },
852
2053
  {
853
- name: "didit_get_webhook_destination",
854
- description: "Get a single webhook destination, including its signing secret.",
2054
+ name: "didit_webhook_get",
2055
+ description: "Get a single webhook destination with redacted signing-secret metadata.",
855
2056
  inputSchema: {
856
2057
  type: "object",
857
2058
  properties: {
2059
+ ...orgapp_1.ORG_APP_PROPS,
858
2060
  destination_uuid: { type: "string", description: "Webhook destination UUID" },
859
2061
  },
860
2062
  required: ["destination_uuid"],
861
2063
  },
862
2064
  },
863
2065
  {
864
- name: "didit_update_webhook_destination",
865
- description: "Update a webhook destination's URL, version, enabled flag, or subscribed events.",
2066
+ name: "didit_webhook_update",
2067
+ description: "Overwrite the supplied settings of an existing webhook destination. Changing its URL redirects future deliveries; disabling it stops deliveries, and subscribed_events replaces its event subscriptions. Before calling, show the destination UUID and each proposed field change and obtain explicit user confirmation.",
866
2068
  inputSchema: {
867
2069
  type: "object",
868
2070
  properties: {
2071
+ ...orgapp_1.ORG_APP_PROPS,
869
2072
  destination_uuid: { type: "string", description: "Webhook destination UUID" },
870
2073
  label: { type: "string" },
871
2074
  url: { type: "string" },
@@ -877,11 +2080,12 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
877
2080
  },
878
2081
  },
879
2082
  {
880
- name: "didit_delete_webhook_destination",
2083
+ name: "didit_webhook_delete",
881
2084
  description: "Delete a webhook destination so it stops receiving events.",
882
2085
  inputSchema: {
883
2086
  type: "object",
884
2087
  properties: {
2088
+ ...orgapp_1.ORG_APP_PROPS,
885
2089
  destination_uuid: { type: "string", description: "Webhook destination UUID" },
886
2090
  },
887
2091
  required: ["destination_uuid"],
@@ -889,11 +2093,12 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
889
2093
  },
890
2094
  // ── Lists (Blocklists, Allowlists & Custom) ─────────────────────────
891
2095
  {
892
- name: "didit_list_lists",
2096
+ name: "didit_lists_list",
893
2097
  description: "List all lists (blocklists, allowlists, custom) for the application. Filter by list_type or entry_type.",
894
2098
  inputSchema: {
895
2099
  type: "object",
896
2100
  properties: {
2101
+ ...orgapp_1.ORG_APP_PROPS,
897
2102
  list_type: { type: "string", description: "Filter: blocklist, allowlist, custom" },
898
2103
  entry_type: { type: "string", description: `Filter: ${LIST_ENTRY_TYPES.join(", ")}` },
899
2104
  limit: { type: "string" },
@@ -902,11 +2107,12 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
902
2107
  },
903
2108
  },
904
2109
  {
905
- name: "didit_create_list",
2110
+ name: "didit_lists_create",
906
2111
  description: "Create an allowlist or custom list. System blocklists are auto-provisioned (one per entry type) and cannot be created. name must be unique per application.",
907
2112
  inputSchema: {
908
2113
  type: "object",
909
2114
  properties: {
2115
+ ...orgapp_1.ORG_APP_PROPS,
910
2116
  name: { type: "string", description: "REQUIRED. Unique list name" },
911
2117
  list_type: { type: "string", enum: ["allowlist", "custom"], description: "REQUIRED. allowlist or custom (blocklists are auto-provisioned)" },
912
2118
  entry_type: { type: "string", enum: LIST_ENTRY_TYPES, description: "REQUIRED. What kind of values the list holds" },
@@ -916,22 +2122,24 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
916
2122
  },
917
2123
  },
918
2124
  {
919
- name: "didit_get_list",
2125
+ name: "didit_lists_get",
920
2126
  description: "Get a single list's details by UUID.",
921
2127
  inputSchema: {
922
2128
  type: "object",
923
2129
  properties: {
2130
+ ...orgapp_1.ORG_APP_PROPS,
924
2131
  list_uuid: { type: "string", description: "UUID of the list" },
925
2132
  },
926
2133
  required: ["list_uuid"],
927
2134
  },
928
2135
  },
929
2136
  {
930
- name: "didit_update_list",
2137
+ name: "didit_lists_update",
931
2138
  description: "Rename or update the description of an allowlist/custom list. System blocklists are immutable.",
932
2139
  inputSchema: {
933
2140
  type: "object",
934
2141
  properties: {
2142
+ ...orgapp_1.ORG_APP_PROPS,
935
2143
  list_uuid: { type: "string", description: "UUID of the list" },
936
2144
  name: { type: "string" },
937
2145
  description: { type: "string" },
@@ -940,24 +2148,27 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
940
2148
  },
941
2149
  },
942
2150
  {
943
- name: "didit_delete_list",
2151
+ name: "didit_lists_delete",
944
2152
  description: "Delete an allowlist/custom list and all its entries. System blocklists cannot be deleted.",
945
2153
  inputSchema: {
946
2154
  type: "object",
947
2155
  properties: {
2156
+ ...orgapp_1.ORG_APP_PROPS,
948
2157
  list_uuid: { type: "string", description: "UUID of the list" },
949
2158
  },
950
2159
  required: ["list_uuid"],
951
2160
  },
952
2161
  },
953
2162
  {
954
- name: "didit_list_entries",
2163
+ name: "didit_lists_entries_list",
955
2164
  description: "List entries in a specific list. Use search to filter by value or label.",
956
2165
  inputSchema: {
957
2166
  type: "object",
958
2167
  properties: {
2168
+ ...orgapp_1.ORG_APP_PROPS,
959
2169
  list_uuid: { type: "string", description: "UUID of the list" },
960
2170
  search: { type: "string", description: "Search by value or display label" },
2171
+ reference_session_id: { type: "string", description: "Only the entries created from this session UUID (e.g. which of its faces are already blocklisted)" },
961
2172
  limit: { type: "string" },
962
2173
  offset: { type: "string" },
963
2174
  },
@@ -965,15 +2176,22 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
965
2176
  },
966
2177
  },
967
2178
  {
968
- name: "didit_create_list_entry",
969
- description: "Add an entry to a blocklist/allowlist/custom list. Pass value directly, or reference_session_id to auto-extract from a session (face, document, phone, email, IP, device). Pass both to disambiguate when a session has multiple values of the same type. For face entries without a session, use didit_upload_face_entry instead.",
2179
+ name: "didit_lists_entry_create",
2180
+ description: "Add an entry to a blocklist/allowlist/custom list. Pass value directly, or reference_session_id to auto-extract from a session (face, document, phone, email, IP, device). Pass both to disambiguate when a session has multiple values of the same type. For the face blocklist, face_image_source picks which of the session's faces to block: the liveness selfie (default) or a selfie the front camera took while the user photographed their document. For face entries without a session, use didit_lists_entry_upload_face instead.",
970
2181
  inputSchema: {
971
2182
  type: "object",
972
2183
  properties: {
2184
+ ...orgapp_1.ORG_APP_PROPS,
973
2185
  list_uuid: { type: "string", description: "UUID of the list to add to" },
974
2186
  value: { type: "string", description: "Value to add (phone, email, IP, etc.). Optional if reference_session_id is provided." },
975
2187
  reference_session_id: { type: "string", description: "Session UUID — backend auto-extracts the value based on the list's entry type" },
976
2188
  reference_object_uuid: { type: "string", description: "UUID of the source entity (transaction, vendor user/business) for traceability" },
2189
+ face_image_source: {
2190
+ type: "string",
2191
+ enum: ["liveness", "front_image_camera_front", "back_image_camera_front"],
2192
+ description: "Face blocklist with reference_session_id only: which of the session's faces to block. liveness (default) is the liveness selfie; front_image_camera_front / back_image_camera_front are the selfies taken while the user photographed the front / back of their document. Leave value empty with a document-capture source.",
2193
+ },
2194
+ reference_node_id: { type: "string", description: "With a document-capture face_image_source: the ID verification node whose selfie to use, for workflows with several ID verification steps" },
977
2195
  display_label: { type: "string", description: "Human-readable label" },
978
2196
  comment: { type: "string", description: "Reason for adding" },
979
2197
  metadata: { type: "object", description: "Additional structured data (e.g. reference_type, full_name)" },
@@ -982,25 +2200,28 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
982
2200
  },
983
2201
  },
984
2202
  {
985
- name: "didit_upload_face_entry",
986
- description: "Add a face entry to a face list by uploading an image directly (no session needed). Use this when you have a photo but no reference_session_id.",
2203
+ name: "didit_lists_entry_upload_face",
2204
+ description: "Add a face entry to a face list by uploading an image directly (no session needed). Use this when you have a photo but no reference_session_id. Provide the image as image_path (local/stdio runs) or image_base64 (hosted runs).",
987
2205
  inputSchema: {
988
2206
  type: "object",
989
2207
  properties: {
2208
+ ...orgapp_1.ORG_APP_PROPS,
990
2209
  list_uuid: { type: "string", description: "UUID of a face-type list" },
991
- image_path: { type: "string", description: "Absolute path to the face image file" },
2210
+ image_path: { type: "string", description: "Absolute path to the face image file (local/stdio only)" },
2211
+ image_base64: { type: "string", description: "Face image as base64 or data URL (or an attachment reference like att_1)" },
992
2212
  display_label: { type: "string" },
993
2213
  comment: { type: "string" },
994
2214
  },
995
- required: ["list_uuid", "image_path"],
2215
+ required: ["list_uuid"],
996
2216
  },
997
2217
  },
998
2218
  {
999
- name: "didit_delete_list_entry",
2219
+ name: "didit_lists_entry_delete",
1000
2220
  description: "Remove an entry from a list. Also unblocks the underlying user/business if applicable.",
1001
2221
  inputSchema: {
1002
2222
  type: "object",
1003
2223
  properties: {
2224
+ ...orgapp_1.ORG_APP_PROPS,
1004
2225
  list_uuid: { type: "string", description: "UUID of the list" },
1005
2226
  entry_uuid: { type: "string", description: "UUID of the entry to remove" },
1006
2227
  },
@@ -1009,44 +2230,48 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
1009
2230
  },
1010
2231
  // ── Standalone: Identity & Documents ────────────────────────────────
1011
2232
  {
1012
- name: "didit_id_verification",
1013
- description: "Verify an identity document by submitting front (and optionally back) images. Returns structured OCR data and authenticity checks.",
2233
+ name: "didit_verify_id",
2234
+ description: "Verify an identity document by submitting front (and optionally back) images. Returns structured OCR data and authenticity checks. Each image is a local absolute *_path (local/stdio runs) or inline *_base64 content (hosted runs).",
1014
2235
  inputSchema: {
1015
2236
  type: "object",
1016
2237
  properties: {
1017
- front_image_path: { type: "string", description: "Absolute path to front image file" },
1018
- back_image_path: { type: "string", description: "Absolute path to back image file (optional)" },
2238
+ ...orgapp_1.ORG_APP_PROPS,
2239
+ front_image_path: { type: "string", description: "Absolute path to front image file (local/stdio only)" },
2240
+ back_image_path: { type: "string", description: "Absolute path to back image file (optional; local/stdio only)" },
2241
+ front_image_base64: { type: "string", description: "Front image as base64 or data URL (or an attachment reference like att_1)" },
2242
+ back_image_base64: { type: "string", description: "Back image as base64 or data URL (optional; or an attachment reference like att_1)" },
1019
2243
  vendor_data: { type: "string", description: "Optional identifier to link the result to a user" },
1020
2244
  perform_document_liveness: { type: "boolean", description: "Run document-presence (anti-screenshot) checks" },
1021
2245
  minimum_age: { type: "number", description: "Decline if the extracted age is below this value" },
1022
2246
  preferred_characters: { type: "string", enum: ["latin", "non_latin"], description: "Preferred OCR script" },
1023
2247
  },
1024
- required: ["front_image_path"],
1025
2248
  },
1026
2249
  },
1027
2250
  {
1028
- name: "didit_poa_verification",
1029
- description: "Proof of Address verification. Submit a single document image to extract and validate address information.",
2251
+ name: "didit_verify_poa",
2252
+ description: "Proof of Address verification. Submit a single document image to extract and validate address information. The image is a local absolute *_path (local/stdio runs) or inline *_base64 content (hosted runs).",
1030
2253
  inputSchema: {
1031
2254
  type: "object",
1032
2255
  properties: {
1033
- document_image_path: { type: "string", description: "Absolute path to the POA document image" },
2256
+ ...orgapp_1.ORG_APP_PROPS,
2257
+ document_image_path: { type: "string", description: "Absolute path to the POA document image (local/stdio only)" },
2258
+ document_image_base64: { type: "string", description: "POA document image as base64 or data URL (or an attachment reference like att_1)" },
1034
2259
  vendor_data: { type: "string", description: "Optional identifier to link the result to a user" },
1035
2260
  expected_address: { type: "string", description: "Address to validate the document against" },
1036
2261
  expected_country: { type: "string", description: "ISO 3166-1 alpha-2 country code to validate against" },
1037
2262
  expected_first_name: { type: "string" },
1038
2263
  expected_last_name: { type: "string" },
1039
2264
  },
1040
- required: ["document_image_path"],
1041
2265
  },
1042
2266
  },
1043
2267
  {
1044
- name: "didit_database_validation",
1045
- description: "Validate identity data against national and global authoritative data sources. issuing_state (ISO 3166-1 alpha-2) is required and selects which sources run.",
2268
+ name: "didit_verify_database",
2269
+ 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.",
1046
2270
  inputSchema: {
1047
2271
  type: "object",
1048
2272
  properties: {
1049
- issuing_state: { type: "string", description: "REQUIRED. ISO 3166-1 alpha-2 country code that selects the data sources to query" },
2273
+ ...orgapp_1.ORG_APP_PROPS,
2274
+ issuing_state: { type: "string", description: "REQUIRED. ISO 3166-1 alpha-3 country code that selects the data sources to query" },
1050
2275
  first_name: { type: "string" },
1051
2276
  last_name: { type: "string" },
1052
2277
  middle_name: { type: "string" },
@@ -1069,11 +2294,12 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
1069
2294
  },
1070
2295
  // ── Standalone: KYB registry ────────────────────────────────────────
1071
2296
  {
1072
- name: "didit_kyb_search",
1073
- description: "Search official company registries for a business by name and/or registration number. Returns candidate matches; pass a candidate's kyb_response_id to didit_kyb_select to pull the full record.",
2297
+ name: "didit_verify_kyb_search",
2298
+ description: "Search official company registries for a business by name and/or registration number. Returns candidate matches; pass a candidate's kyb_response_id to didit_verify_kyb_select to pull the full record.",
1074
2299
  inputSchema: {
1075
2300
  type: "object",
1076
2301
  properties: {
2302
+ ...orgapp_1.ORG_APP_PROPS,
1077
2303
  country_code: { type: "string", description: "REQUIRED. ISO 3166-1 alpha-2 country code" },
1078
2304
  name: { type: "string", description: "Company name to search" },
1079
2305
  registration_number: { type: "string", description: "Registration number to search" },
@@ -1086,12 +2312,13 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
1086
2312
  },
1087
2313
  },
1088
2314
  {
1089
- name: "didit_kyb_select",
1090
- description: "Resolve a candidate from didit_kyb_search into a full company registry record. kyb_response_id is the per-search candidate handle returned by the search.",
2315
+ 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.",
1091
2317
  inputSchema: {
1092
2318
  type: "object",
1093
2319
  properties: {
1094
- kyb_response_id: { type: "string", description: "REQUIRED. Candidate handle from didit_kyb_search" },
2320
+ ...orgapp_1.ORG_APP_PROPS,
2321
+ kyb_response_id: { type: "string", description: "REQUIRED. Candidate handle from didit_verify_kyb_search" },
1095
2322
  vendor_data: { type: "string" },
1096
2323
  metadata: { type: "object" },
1097
2324
  save_api_request: { type: "boolean" },
@@ -1101,61 +2328,67 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
1101
2328
  },
1102
2329
  // ── Standalone: Biometrics & Face ───────────────────────────────────
1103
2330
  {
1104
- name: "didit_passive_liveness",
1105
- description: "Passive liveness detection -- verify a person is physically present from a single image (no interaction required).",
2331
+ name: "didit_verify_passive_liveness",
2332
+ description: "Passive liveness detection -- verify a person is physically present from a single image (no interaction required). The image is a local absolute image_path (local/stdio runs) or inline image_base64 content (hosted runs).",
1106
2333
  inputSchema: {
1107
2334
  type: "object",
1108
2335
  properties: {
1109
- image_path: { type: "string", description: "Absolute path to facial image file" },
2336
+ ...orgapp_1.ORG_APP_PROPS,
2337
+ image_path: { type: "string", description: "Absolute path to facial image file (local/stdio only)" },
2338
+ image_base64: { type: "string", description: "Facial image as base64 or data URL (or an attachment reference like att_1)" },
1110
2339
  vendor_data: { type: "string", description: "Optional identifier to link the result to a user" },
1111
2340
  },
1112
- required: ["image_path"],
1113
2341
  },
1114
2342
  },
1115
2343
  {
1116
- name: "didit_face_match",
1117
- description: "Compare two facial images to determine if they belong to the same person (1:1 face matching). The score is symmetric, so image order does not affect the result.",
2344
+ name: "didit_verify_face_match",
2345
+ description: "Compare two facial images to determine if they belong to the same person (1:1 face matching). The score is symmetric, so image order does not affect the result. Each image is a local absolute *_path (local/stdio runs) or inline *_base64 content (hosted runs).",
1118
2346
  inputSchema: {
1119
2347
  type: "object",
1120
2348
  properties: {
1121
- image_1_path: { type: "string", description: "Absolute path to the first facial image (e.g. the selfie)" },
1122
- image_2_path: { type: "string", description: "Absolute path to the second facial image (e.g. the ID portrait)" },
2349
+ ...orgapp_1.ORG_APP_PROPS,
2350
+ image_1_path: { type: "string", description: "Absolute path to the first facial image, e.g. the selfie (local/stdio only)" },
2351
+ image_2_path: { type: "string", description: "Absolute path to the second facial image, e.g. the ID portrait (local/stdio only)" },
2352
+ image_1_base64: { type: "string", description: "First facial image as base64 or data URL (or an attachment reference like att_1)" },
2353
+ image_2_base64: { type: "string", description: "Second facial image as base64 or data URL (or an attachment reference like att_2)" },
1123
2354
  vendor_data: { type: "string", description: "Optional identifier to link the result to a user" },
1124
2355
  },
1125
- required: ["image_1_path", "image_2_path"],
1126
2356
  },
1127
2357
  },
1128
2358
  {
1129
- name: "didit_face_search",
1130
- description: "Search for a face against a database of previously verified faces (1:N face matching).",
2359
+ name: "didit_verify_face_search",
2360
+ description: "Search for a face against a database of previously verified faces (1:N face matching). The image is a local absolute image_path (local/stdio runs) or inline image_base64 content (hosted runs).",
1131
2361
  inputSchema: {
1132
2362
  type: "object",
1133
2363
  properties: {
1134
- image_path: { type: "string", description: "Absolute path to facial image file" },
2364
+ ...orgapp_1.ORG_APP_PROPS,
2365
+ image_path: { type: "string", description: "Absolute path to facial image file (local/stdio only)" },
2366
+ image_base64: { type: "string", description: "Facial image as base64 or data URL (or an attachment reference like att_1)" },
1135
2367
  vendor_data: { type: "string", description: "Optional identifier to link the result to a user" },
1136
2368
  },
1137
- required: ["image_path"],
1138
2369
  },
1139
2370
  },
1140
2371
  {
1141
- name: "didit_age_estimation",
1142
- description: "Estimate a person's age from a facial image. Also performs passive liveness check.",
2372
+ name: "didit_verify_age",
2373
+ description: "Estimate a person's age from a facial image. Also performs passive liveness check. The image is a local absolute image_path (local/stdio runs) or inline image_base64 content (hosted runs).",
1143
2374
  inputSchema: {
1144
2375
  type: "object",
1145
2376
  properties: {
1146
- image_path: { type: "string", description: "Absolute path to facial image file" },
2377
+ ...orgapp_1.ORG_APP_PROPS,
2378
+ image_path: { type: "string", description: "Absolute path to facial image file (local/stdio only)" },
2379
+ image_base64: { type: "string", description: "Facial image as base64 or data URL (or an attachment reference like att_1)" },
1147
2380
  vendor_data: { type: "string", description: "Optional identifier to link the result to a user" },
1148
2381
  },
1149
- required: ["image_path"],
1150
2382
  },
1151
2383
  },
1152
2384
  // ── Standalone: AML Screening ───────────────────────────────────────
1153
2385
  {
1154
- name: "didit_aml_screening",
2386
+ name: "didit_verify_aml",
1155
2387
  description: "AML screening against global watchlists, PEP lists, sanctions, and (optionally) adverse media. Supports person and company entity types.",
1156
2388
  inputSchema: {
1157
2389
  type: "object",
1158
2390
  properties: {
2391
+ ...orgapp_1.ORG_APP_PROPS,
1159
2392
  full_name: { type: "string", description: "REQUIRED. Full name to screen" },
1160
2393
  entity_type: { type: "string", enum: ["person", "company"], description: "Defaults to person" },
1161
2394
  date_of_birth: { type: "string", description: "YYYY-MM-DD (improves match accuracy)" },
@@ -1171,22 +2404,24 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
1171
2404
  },
1172
2405
  // ── Standalone: Email & Phone Verification ──────────────────────────
1173
2406
  {
1174
- name: "didit_email_send",
2407
+ name: "didit_verify_email_send",
1175
2408
  description: "Send a one-time verification code to an email address. Code valid for 5 minutes.",
1176
2409
  inputSchema: {
1177
2410
  type: "object",
1178
2411
  properties: {
2412
+ ...orgapp_1.ORG_APP_PROPS,
1179
2413
  email: { type: "string", description: "Email address to verify" },
1180
2414
  },
1181
2415
  required: ["email"],
1182
2416
  },
1183
2417
  },
1184
2418
  {
1185
- name: "didit_email_check",
2419
+ name: "didit_verify_email_check",
1186
2420
  description: "Verify the OTP code sent to an email. Max 3 attempts per code.",
1187
2421
  inputSchema: {
1188
2422
  type: "object",
1189
2423
  properties: {
2424
+ ...orgapp_1.ORG_APP_PROPS,
1190
2425
  email: { type: "string" },
1191
2426
  code: { type: "string", description: "Verification code from email" },
1192
2427
  },
@@ -1194,355 +2429,1007 @@ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => ({
1194
2429
  },
1195
2430
  },
1196
2431
  {
1197
- name: "didit_phone_send",
2432
+ name: "didit_verify_phone_send",
1198
2433
  description: "Send a one-time verification code to a phone number via SMS. Code valid for 5 minutes.",
1199
2434
  inputSchema: {
1200
2435
  type: "object",
1201
2436
  properties: {
2437
+ ...orgapp_1.ORG_APP_PROPS,
1202
2438
  phone_number: { type: "string", description: "Phone number with country code (e.g. +1234567890)" },
1203
2439
  },
1204
2440
  required: ["phone_number"],
1205
2441
  },
1206
2442
  },
1207
2443
  {
1208
- name: "didit_phone_check",
2444
+ name: "didit_verify_phone_check",
1209
2445
  description: "Verify the OTP code sent to a phone number. Max 3 attempts per code.",
1210
2446
  inputSchema: {
1211
2447
  type: "object",
1212
2448
  properties: {
2449
+ ...orgapp_1.ORG_APP_PROPS,
1213
2450
  phone_number: { type: "string" },
1214
2451
  code: { type: "string", description: "Verification code from SMS" },
1215
2452
  },
1216
2453
  required: ["phone_number", "code"],
1217
2454
  },
1218
2455
  },
1219
- ],
1220
- }));
1221
- // ---------------------------------------------------------------------------
1222
- // Tool dispatch
1223
- // ---------------------------------------------------------------------------
1224
- server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
1225
- const { name, arguments: args } = request.params;
1226
- try {
1227
- let result;
1228
- switch (name) {
1229
- // Auth
1230
- case "didit_register":
1231
- result = await auth.register(args.email, args.password);
1232
- break;
1233
- case "didit_verify_email":
1234
- result = await auth.verifyEmail(args.email, args.code);
1235
- break;
1236
- case "didit_resend_otp":
1237
- result = await auth.resendOtp(args.email);
1238
- break;
1239
- case "didit_login":
1240
- result = await auth.login(args.email, args.password);
1241
- break;
1242
- case "didit_list_organizations":
1243
- result = await auth.listOrganizations(args.access_token);
1244
- break;
1245
- case "didit_list_applications":
1246
- result = await auth.listApplications(args.access_token, args.organization_id);
1247
- break;
1248
- case "didit_get_application":
1249
- result = await auth.getApplication(args.access_token, args.organization_id, args.application_id);
1250
- break;
1251
- // Sessions
1252
- case "didit_create_session":
1253
- result = await sessions.createSession(args || {});
1254
- break;
1255
- case "didit_list_sessions":
1256
- result = await sessions.listSessions(args);
1257
- break;
1258
- case "didit_get_session_decision":
1259
- result = await sessions.getSessionDecision(args.session_id);
1260
- break;
1261
- case "didit_update_session_status": {
1262
- const { session_id, ...data } = args;
1263
- result = await sessions.updateSessionStatus(session_id, data);
1264
- break;
1265
- }
1266
- case "didit_update_session_data": {
1267
- const { session_id, ...data } = args;
1268
- result = await sessions.updateSessionData(session_id, data);
1269
- break;
1270
- }
1271
- case "didit_update_session_poa_data": {
1272
- const { session_id, ...data } = args;
1273
- result = await sessions.updateSessionPoaData(session_id, data);
1274
- break;
1275
- }
1276
- case "didit_delete_session":
1277
- result = await sessions.deleteSession(args.session_id);
1278
- break;
1279
- case "didit_batch_delete_sessions":
1280
- result = await sessions.batchDeleteSessions(args?.session_numbers, args?.delete_all);
1281
- break;
1282
- case "didit_generate_session_pdf":
1283
- result = await sessions.generateSessionPdf(args.session_id);
1284
- break;
1285
- case "didit_list_session_reviews":
1286
- result = await sessions.listSessionReviews(args.session_id);
1287
- break;
1288
- case "didit_add_session_review": {
1289
- const { session_id, ...data } = args;
1290
- result = await sessions.addSessionReview(session_id, data);
1291
- break;
1292
- }
1293
- case "didit_share_session":
1294
- result = await sessions.shareSession(args.session_id, args);
1295
- break;
1296
- case "didit_import_shared_session":
1297
- result = await sessions.importSharedSession(args);
1298
- break;
1299
- // Session imports
1300
- case "didit_create_import":
1301
- result = await sessions.createImport(args);
1302
- break;
1303
- case "didit_get_import_template":
1304
- result = await sessions.getImportTemplate();
1305
- break;
1306
- case "didit_get_import":
1307
- result = await sessions.getImport(args.import_id);
1308
- break;
1309
- case "didit_get_import_errors":
1310
- result = await sessions.getImportErrors(args.import_id);
1311
- break;
1312
- // Workflows
1313
- case "didit_list_workflows":
1314
- result = await settings.listWorkflows();
1315
- break;
1316
- case "didit_create_workflow":
1317
- result = await settings.createWorkflow(args || {});
1318
- break;
1319
- case "didit_get_workflow":
1320
- result = await settings.getWorkflow(args.workflow_id);
1321
- break;
1322
- case "didit_update_workflow": {
1323
- const { workflow_id, ...data } = args;
1324
- result = await settings.updateWorkflow(workflow_id, data);
1325
- break;
1326
- }
1327
- case "didit_delete_workflow":
1328
- result = await settings.deleteWorkflow(args.workflow_id);
1329
- break;
1330
- // Questionnaires
1331
- case "didit_list_questionnaires":
1332
- result = await questionnaires.listQuestionnaires();
1333
- break;
1334
- case "didit_create_questionnaire":
1335
- result = await questionnaires.createQuestionnaire(args);
1336
- break;
1337
- case "didit_get_questionnaire":
1338
- result = await questionnaires.getQuestionnaire(args.questionnaire_id);
1339
- break;
1340
- case "didit_update_questionnaire": {
1341
- const { questionnaire_id, ...data } = args;
1342
- result = await questionnaires.updateQuestionnaire(questionnaire_id, data);
1343
- break;
1344
- }
1345
- case "didit_delete_questionnaire":
1346
- result = await questionnaires.deleteQuestionnaire(args.questionnaire_id);
1347
- break;
1348
- // Users
1349
- case "didit_list_users":
1350
- result = await users.listUsers(args);
1351
- break;
1352
- case "didit_create_user":
1353
- result = await users.createUser(args);
1354
- break;
1355
- case "didit_get_user":
1356
- result = await users.getUser(args.vendor_data);
1357
- break;
1358
- case "didit_update_user": {
1359
- const { vendor_data, ...data } = args;
1360
- result = await users.updateUser(vendor_data, data);
1361
- break;
1362
- }
1363
- case "didit_update_user_status":
1364
- result = await users.updateUserStatus(args.vendor_data, args.status);
1365
- break;
1366
- case "didit_delete_users":
1367
- result = await users.deleteUsers(args?.vendor_data_list, args?.delete_all);
1368
- break;
1369
- // Businesses
1370
- case "didit_list_businesses":
1371
- result = await businesses.listBusinesses(args);
1372
- break;
1373
- case "didit_create_business":
1374
- result = await businesses.createBusiness(args);
1375
- break;
1376
- case "didit_get_business":
1377
- result = await businesses.getBusiness(args.vendor_data);
1378
- break;
1379
- case "didit_update_business": {
1380
- const { vendor_data, ...data } = args;
1381
- result = await businesses.updateBusiness(vendor_data, data);
1382
- break;
1383
- }
1384
- case "didit_update_business_status":
1385
- result = await businesses.updateBusinessStatus(args.vendor_data, args.status);
1386
- break;
1387
- case "didit_delete_businesses":
1388
- result = await businesses.deleteBusinesses(args?.vendor_data_list, args?.didit_internal_id_list, args?.delete_all);
1389
- break;
1390
- // Transactions
1391
- case "didit_list_transactions":
1392
- result = await transactions.listTransactions(args);
1393
- break;
1394
- case "didit_create_transaction":
1395
- result = await transactions.createTransaction(args);
1396
- break;
1397
- case "didit_get_transaction":
1398
- result = await transactions.getTransaction(args.transaction_id);
1399
- break;
1400
- case "didit_screen_wallet":
1401
- result = await transactions.screenWallet(args);
1402
- break;
1403
- // Billing
1404
- case "didit_get_balance":
1405
- result = await billing.getBalance();
1406
- break;
1407
- case "didit_top_up":
1408
- result = await billing.topUp(args.amount_in_dollars, args?.success_url, args?.cancel_url);
1409
- break;
1410
- // Customization
1411
- case "didit_get_customization":
1412
- result = await customization.getCustomization();
1413
- break;
1414
- case "didit_update_customization":
1415
- result = await customization.updateCustomization(args);
1416
- break;
1417
- // Webhook destinations
1418
- case "didit_list_webhook_destinations":
1419
- result = await webhooks.listDestinations();
1420
- break;
1421
- case "didit_create_webhook_destination":
1422
- result = await webhooks.createDestination(args);
1423
- break;
1424
- case "didit_get_webhook_destination":
1425
- result = await webhooks.getDestination(args.destination_uuid);
1426
- break;
1427
- case "didit_update_webhook_destination": {
1428
- const { destination_uuid, ...data } = args;
1429
- result = await webhooks.updateDestination(destination_uuid, data);
1430
- break;
1431
- }
1432
- case "didit_delete_webhook_destination":
1433
- result = await webhooks.deleteDestination(args.destination_uuid);
1434
- break;
1435
- // Lists
1436
- case "didit_list_lists":
1437
- result = await lists.listLists(args);
1438
- break;
1439
- case "didit_create_list":
1440
- result = await lists.createList(args);
1441
- break;
1442
- case "didit_get_list":
1443
- result = await lists.getListDetail(args.list_uuid);
1444
- break;
1445
- case "didit_update_list": {
1446
- const { list_uuid: ulListUuid, ...ulData } = args;
1447
- result = await lists.updateList(ulListUuid, ulData);
1448
- break;
1449
- }
1450
- case "didit_delete_list":
1451
- result = await lists.deleteList(args.list_uuid);
1452
- break;
1453
- case "didit_list_entries": {
1454
- const { list_uuid: leListUuid, ...leParams } = args;
1455
- result = await lists.listEntries(leListUuid, leParams);
1456
- break;
1457
- }
1458
- case "didit_create_list_entry": {
1459
- const { list_uuid: ceListUuid, ...ceData } = args;
1460
- result = await lists.createEntry(ceListUuid, ceData);
1461
- break;
1462
- }
1463
- case "didit_upload_face_entry": {
1464
- const { list_uuid: ufListUuid, image_path, ...ufData } = args;
1465
- result = await lists.uploadFaceEntry(ufListUuid, { image_path, ...ufData });
1466
- break;
1467
- }
1468
- case "didit_delete_list_entry": {
1469
- const { list_uuid: deListUuid, entry_uuid: deEntryUuid } = args;
1470
- result = await lists.deleteEntry(deListUuid, deEntryUuid);
1471
- break;
1472
- }
1473
- // Standalone: Identity & Documents
1474
- case "didit_id_verification": {
1475
- const { front_image_path, back_image_path, ...idOpts } = args;
1476
- result = await standalone.idVerification(front_image_path, back_image_path, idOpts);
1477
- break;
2456
+ // ── Blocklist / Allowlist ───────────────────────────────────────────
2457
+ {
2458
+ name: "didit_blocklist_get",
2459
+ description: "List blocklist entries (blocked users/identifiers).",
2460
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS } },
2461
+ },
2462
+ {
2463
+ name: "didit_blocklist_add",
2464
+ description: "Add an entry to the blocklist (e.g. by vendor_data, document number, face).",
2465
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS }, required: [] },
2466
+ },
2467
+ {
2468
+ name: "didit_blocklist_remove",
2469
+ description: "Remove an entry from the blocklist.",
2470
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS } },
2471
+ },
2472
+ {
2473
+ name: "didit_allowlist_add",
2474
+ description: "Add an entry to the allowlist (trusted, bypasses some checks).",
2475
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS } },
2476
+ },
2477
+ // ── Case management ─────────────────────────────────────────────────
2478
+ {
2479
+ name: "didit_case_list",
2480
+ description: "List investigation/compliance cases for ONE app; with multiple apps (or no scope) it auto-spans all your apps. For a cross-app query prefer didit_case_search.",
2481
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS, status: { type: "string" }, cursor: { type: "string" } } },
2482
+ },
2483
+ {
2484
+ name: "didit_case_get",
2485
+ description: "Get a case with its details.",
2486
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS, case_id: { type: "string" } }, required: ["case_id"] },
2487
+ },
2488
+ {
2489
+ name: "didit_case_create",
2490
+ description: "Create a case.",
2491
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS } },
2492
+ },
2493
+ {
2494
+ name: "didit_case_statistics",
2495
+ description: "Get case statistics (counts by status, etc.).",
2496
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS } },
2497
+ },
2498
+ {
2499
+ name: "didit_case_manage",
2500
+ description: "Act on a case: assign, resolve, reopen, escalate, comment, or update.",
2501
+ inputSchema: {
2502
+ type: "object",
2503
+ properties: {
2504
+ ...orgapp_1.ORG_APP_PROPS,
2505
+ case_id: { type: "string" },
2506
+ action: { type: "string", enum: ["assign", "resolve", "reopen", "escalate", "comment", "update"] },
2507
+ data: { type: "object", description: "Action payload (e.g. {assignee_id}, {comment}, or fields to update)" },
2508
+ confirm: {
2509
+ type: "boolean",
2510
+ description: "REQUIRED when filing a SAR (action 'sar'/'file_sar', or any action whose data.status is 'SAR_FILED') - a high-impact regulatory action. Only set after explicit user confirmation of this exact action.",
2511
+ },
2512
+ },
2513
+ required: ["case_id", "action"],
2514
+ },
2515
+ },
2516
+ // ── Reports (async exports) ─────────────────────────────────────────
2517
+ {
2518
+ name: "didit_report_list",
2519
+ description: "List generated export reports.",
2520
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS } },
2521
+ },
2522
+ {
2523
+ name: "didit_report_get",
2524
+ description: "Get a report's status/details.",
2525
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS, report_id: { type: "string" } }, required: ["report_id"] },
2526
+ },
2527
+ {
2528
+ name: "didit_report_get_download_url",
2529
+ description: "Get a signed download URL for a finished report.",
2530
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS, report_id: { type: "string" } }, required: ["report_id"] },
2531
+ },
2532
+ {
2533
+ name: "didit_report_export",
2534
+ description: "Start an export report. kind ∈ sessions | transactions | businesses | vendor-users | vendor-businesses. `data.columns` is a kind-specific schema — for sessions/vendor-users/vendor-businesses an unknown column 400s with `Invalid columns`, and that error's `allowed` field carries the full valid-column list for that kind, so retry from the error alone rather than guessing names like `date`/`status`/`total_price`.",
2535
+ inputSchema: {
2536
+ type: "object",
2537
+ properties: { ...orgapp_1.ORG_APP_PROPS, kind: { type: "string" }, data: { type: "object", description: "Filters for the export" } },
2538
+ required: ["kind"],
2539
+ },
2540
+ },
2541
+ // ── Audit logs + alerts ─────────────────────────────────────────────
2542
+ {
2543
+ 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" } } },
2546
+ },
2547
+ {
2548
+ name: "didit_alert_list",
2549
+ description: "List configured alerts.",
2550
+ inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS } },
2551
+ },
2552
+ {
2553
+ name: "didit_alert_configure",
2554
+ description: "Configure an alert by type.",
2555
+ inputSchema: {
2556
+ type: "object",
2557
+ properties: { ...orgapp_1.ORG_APP_PROPS, alert_type: { type: "string" }, data: { type: "object" } },
2558
+ required: ["alert_type"],
2559
+ },
2560
+ },
2561
+ // ── Org members / roles / API keys (apx/auth/v2) ────────────────────
2562
+ {
2563
+ name: "didit_org_list_members",
2564
+ description: "List the organization's members.",
2565
+ inputSchema: { type: "object", properties: { organization_id: orgapp_1.ORG_APP_PROPS.organization_id } },
2566
+ },
2567
+ {
2568
+ name: "didit_org_invite_member",
2569
+ description: "Invite up to 5 members to the organization (emails + role + the applications they may access).",
2570
+ inputSchema: {
2571
+ type: "object",
2572
+ properties: {
2573
+ organization_id: orgapp_1.ORG_APP_PROPS.organization_id,
2574
+ emails: { type: "array", items: { type: "string" }, description: "Email addresses to invite (1-5)." },
2575
+ role: { type: "string", description: "Role UUID (from didit_org_list_roles)." },
2576
+ app_ids: { type: "array", items: { type: "string" }, description: "Application UUIDs the invitee may access (from didit_org_list_applications)." },
2577
+ },
2578
+ required: ["emails", "role", "app_ids"],
2579
+ },
2580
+ },
2581
+ {
2582
+ name: "didit_org_update_member",
2583
+ description: "Update a member's role and the applications they may access.",
2584
+ inputSchema: {
2585
+ type: "object",
2586
+ properties: {
2587
+ organization_id: orgapp_1.ORG_APP_PROPS.organization_id,
2588
+ member_id: { type: "string", description: "Member UUID (from didit_org_list_members)." },
2589
+ role: { type: "string", description: "Role UUID (from didit_org_list_roles)." },
2590
+ accessible_applications: { type: "array", items: { type: "string" }, description: "Application UUIDs the member may access (from didit_org_list_applications)." },
2591
+ },
2592
+ required: ["member_id", "role", "accessible_applications"],
2593
+ },
2594
+ },
2595
+ {
2596
+ name: "didit_org_remove_member",
2597
+ description: "Remove a member from the organization.",
2598
+ inputSchema: {
2599
+ type: "object",
2600
+ properties: { organization_id: orgapp_1.ORG_APP_PROPS.organization_id, member_id: { type: "string" } },
2601
+ required: ["member_id"],
2602
+ },
2603
+ },
2604
+ {
2605
+ name: "didit_org_list_roles",
2606
+ description: "List the roles available in the organization.",
2607
+ inputSchema: { type: "object", properties: { organization_id: orgapp_1.ORG_APP_PROPS.organization_id } },
2608
+ },
2609
+ {
2610
+ 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 } },
2613
+ },
2614
+ // ── Compliance ──────────────────────────────────────────────────────
2615
+ ...(0, internal_tools_1.internalToolDefs)("compliance"),
2616
+ {
2617
+ name: "didit_workflow_build_graph",
2618
+ description: "Build a complete workflow graph from a PLAIN FEATURE SPEC in one deterministic call - regulations are " +
2619
+ "never consulted" + internal_tools_1.REGULATION_GRAPH_HINT + ". Gate-then-commit: " +
2620
+ "the result is either an accepted build (graph_summary + spec: materialize with ui_workflow_apply_graph " +
2621
+ "{spec} on an open editor, or include_graph:true + didit_workflow_set_graph headless), or 'unsupported'/'questions' naming " +
2622
+ "exactly what cannot be built or what to ask the user FIRST - in that case build NOTHING and relay them. " +
2623
+ "Never rebuild the returned graph by hand and never retry with guesses. Read-only: persists nothing. " +
2624
+ "document_rules express per-country/document filtering, including US state-scoped subtypes " +
2625
+ "(e.g. exclude the Nevada driver's license) and the country wildcard 'ALL' (every catalog country: " +
2626
+ "'only passports, from any country' = one rule {country:'ALL', document:'P', action:'only'}).",
2627
+ inputSchema: {
2628
+ type: "object",
2629
+ properties: {
2630
+ ...orgapp_1.ORG_APP_PROPS,
2631
+ subject: { type: "string", enum: ["kyc", "kyb"], description: "kyc verifies a person (default), kyb a company." },
2632
+ features: {
2633
+ type: "array",
2634
+ items: { type: "string" },
2635
+ description: "ONLY the verification steps the user NAMED, by feature code (OCR, LIVENESS, FACE_MATCH, NFC, " +
2636
+ "PROOF_OF_ADDRESS, QUESTIONNAIRE, PHONE_VERIFICATION, EMAIL_VERIFICATION, AGE_ESTIMATION, " +
2637
+ "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.",
2640
+ },
2641
+ countries: {
2642
+ type: "object",
2643
+ description: "Which countries' DOCUMENTS are configured. OMIT ENTIRELY for 'all countries' (the default). " +
2644
+ "NEVER use it to exclude a document or a state — that is document_rules' job: 'all countries " +
2645
+ "except the Nevada driver's license' = countries omitted + one document_rule.",
2646
+ properties: {
2647
+ mode: { type: "string", enum: ["all", "only", "except"] },
2648
+ list: {
2649
+ type: "array",
2650
+ items: { type: "string" },
2651
+ description: "Countries EXACTLY as the user named them (a name or ISO3 code per entry). NEVER substitute the country you think they meant — the builder asks when it does not know a name.",
2652
+ },
2653
+ },
2654
+ additionalProperties: false,
2655
+ },
2656
+ document_rules: {
2657
+ type: "array",
2658
+ description: "Per-country document filtering. 'state' (US state name or USPS code) filters the " +
2659
+ "state-scoped document subtypes (how 'exclude the Nevada driver's license' is expressed). " +
2660
+ "country 'ALL' applies the rule to every catalog country ('only passports everywhere' = " +
2661
+ "{country:'ALL', document:'P', action:'only'}; do NOT enumerate countries for that).",
2662
+ items: {
2663
+ type: "object",
2664
+ properties: {
2665
+ country: {
2666
+ type: "string",
2667
+ description: "The country EXACTLY as the user named it (a name or ISO3 code, e.g. USA); never substitute one. 'ALL' = every catalog country (wildcard for rules that apply everywhere).",
2668
+ },
2669
+ document: {
2670
+ type: "string",
2671
+ enum: ["ID", "P", "DL", "RP", "HIC", "TC", "SSC", "FIREARM"],
2672
+ description: "Catalog document code: ID card, Passport, Driver's License, Residence Permit, ...",
2673
+ },
2674
+ state: { type: "string", description: "US state (full name or USPS code), for state-scoped subtypes." },
2675
+ action: { type: "string", enum: ["exclude", "only"] },
2676
+ },
2677
+ required: ["country", "document"],
2678
+ additionalProperties: false,
2679
+ },
2680
+ },
2681
+ per_feature_config: {
2682
+ type: "object",
2683
+ description: "Optional per-feature config overrides, {FEATURE: {contract keys...}}; validated server-side.",
2684
+ },
2685
+ include_graph: {
2686
+ type: "boolean",
2687
+ description: "Return the full graph (for headless didit_workflow_set_graph). Default false: the result carries a " +
2688
+ "graph_summary + the accepted spec, and the editor applies by reference with ui_workflow_apply_graph {spec}.",
2689
+ },
2690
+ branches: {
2691
+ type: "array",
2692
+ description: "Country branches after the routing step; unmatched countries take the else path to the final decision. The ONLY key that carries branching.",
2693
+ items: {
2694
+ type: "object",
2695
+ properties: {
2696
+ countries: {
2697
+ type: "array",
2698
+ items: { type: "string" },
2699
+ description: "Countries exactly as the user named them (a name or ISO3 code per entry).",
2700
+ },
2701
+ features: { type: "array", items: { type: "string" } },
2702
+ },
2703
+ required: ["countries", "features"],
2704
+ additionalProperties: false,
2705
+ },
2706
+ },
2707
+ },
2708
+ // CLOSED, like every nested object above it. The root was the one level
2709
+ // left open, and a model filled it: `branch_rules` for `branches`
2710
+ // reached the backend's serializer and three console users of one
2711
+ // organization lost their workflow to its 400. Client-side
2712
+ // validation of this is best-effort — buildWorkflow enforces it.
2713
+ additionalProperties: false,
2714
+ },
2715
+ },
2716
+ ...privileged_tools_1.PRIVILEGED_TOOL_DEFS,
2717
+ ];
2718
+ const inputSchemaByTool = new Map(toolDefinitions().map((t) => [t.name, t.inputSchema]));
2719
+ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async (_request, extra) => {
2720
+ // Privileged operational tools are emitted ONLY to privileged connections; everyone else never
2721
+ // sees them in tools/list (and a call is rejected below). In the open-source build there are none.
2722
+ const isPrivileged = (0, privileged_tools_1.isPrivilegedCaller)(extra?.authInfo, { hosted });
2723
+ const tools = toolDefinitions();
2724
+ // Hosted (Bearer-authenticated) catalogs never include the account-bootstrap /
2725
+ // checkout / secret-reveal tools — the public app catalog must stay free of
2726
+ // credential-collection, checkout, and secret-reveal flows. Privileged (staff)
2727
+ // 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;
2730
+ // Remote connectors authenticate with OAuth, so account credentials must never travel
2731
+ // through the conversation: hosted servers drop the bootstrap tools for EVERY caller
2732
+ // (staff included), regardless of Bearer state. They remain available on stdio.
2733
+ if (hosted)
2734
+ catalog = catalog.filter((t) => !ACCOUNT_BOOTSTRAP_TOOLS.has(t.name));
2735
+ // A tool the caller's organization role could never run is not offered (permissions.ts);
2736
+ // only in enforce mode — shadow mode lists everything and just records the verdicts.
2737
+ const tokenOrg = extra?.authInfo?.extra?.organization_id;
2738
+ const query = { scopes: extra?.authInfo?.scopes, mode: (0, config_1.permissionMode)(), tokenOrg, targetOrg: tokenOrg };
2739
+ catalog = catalog.filter((t) => (0, permissions_1.decidePermission)({ ...query, tool: t.name }) !== "deny");
2740
+ const visible = isPrivileged ? catalog : catalog.filter((t) => !(0, privileged_tools_1.isPrivilegedToolName)(t.name));
2741
+ // Endpoint catalog profile (chatgpt-app.ts): the ChatGPT endpoint offers only the
2742
+ // allow-listed tools, with restricted input properties removed from their schemas.
2743
+ const offered = (0, chatgpt_app_1.applyCatalogProfile)(visible, profile);
2744
+ // Annotate each tool so the connector UI splits them into Read-only / Write / Destructive
2745
+ // groups (driven by readOnlyHint + destructiveHint) instead of one flat "Other tools"
2746
+ // bucket; also tag the logical domain group via _meta for future UI use.
2747
+ return {
2748
+ tools: offered.map((t) => ({
2749
+ ...t,
2750
+ outputSchema: t.outputSchema ?? {
2751
+ type: "object",
2752
+ description: "Structured result. Fields vary by tool; see the success payload.",
2753
+ additionalProperties: true,
2754
+ },
2755
+ annotations: {
2756
+ ...(t.annotations ?? {}),
2757
+ ...annotationsFor(t.name),
2758
+ },
2759
+ _meta: {
2760
+ ...(t._meta ?? {}),
2761
+ "anthropic/toolGroup": toolGroupOf(t.name),
2762
+ category: toolGroupOf(t.name),
2763
+ // MCP Apps linkage for the ChatGPT console (chatgpt-app.ts); `{}` on every other
2764
+ // profile, so their descriptors are unchanged.
2765
+ ...(0, chatgpt_app_1.widgetToolMeta)(profile, t.name),
2766
+ },
2767
+ })).concat(
2768
+ // The console's entry tool (ChatGPT sidebar entrypoint), on /mcp/chatgpt only.
2769
+ (0, chatgpt_app_1.widgetTools)(profile)),
2770
+ };
2771
+ });
2772
+ // ---------------------------------------------------------------------------
2773
+ // Tool dispatch
2774
+ // ---------------------------------------------------------------------------
2775
+ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request, extra) => {
2776
+ const authInfo = extra?.authInfo;
2777
+ // Console (management) tools target /organization/{org}/application/{app}/... paths.
2778
+ // An explicit organization_id / application_id in the tool arguments takes precedence
2779
+ // over the token's org context; both flow into requestContext so orgAppPath() resolves.
2780
+ const callArgs = (request.params.arguments ?? {});
2781
+ const argOrg = typeof callArgs.organization_id === "string" ? callArgs.organization_id : undefined;
2782
+ const argApp = typeof callArgs.application_id === "string" ? callArgs.application_id : undefined;
2783
+ // Permission pre-check verdict (permissions.ts): decided once here so the audit line
2784
+ // can record a shadow-mode "would_deny" and the dispatch below can refuse a "deny".
2785
+ const tokenOrg = authInfo?.extra?.organization_id;
2786
+ const permission = (0, permissions_1.decidePermission)({
2787
+ tool: request.params.name,
2788
+ scopes: authInfo?.scopes,
2789
+ mode: (0, config_1.permissionMode)(),
2790
+ tokenOrg,
2791
+ targetOrg: argOrg || tokenOrg,
2792
+ });
2793
+ const permissionCheck = permission === "would_deny" ? permission : undefined;
2794
+ return config_1.requestContext.run({
2795
+ // Hosted mode: per-request Bearer from OAuth introspection. Stdio mode (tests/eval):
2796
+ // fall back to DIDIT_ACCESS_TOKEN + MCP_DEFAULT_ORG/APP env so the console-path tools
2797
+ // authenticate as that Bearer without the hosted layer.
2798
+ accessToken: authInfo?.token || process.env.DIDIT_ACCESS_TOKEN || undefined,
2799
+ organizationId: argOrg ||
2800
+ authInfo?.extra?.organization_id ||
2801
+ process.env.MCP_DEFAULT_ORG ||
2802
+ undefined,
2803
+ applicationId: argApp || process.env.MCP_DEFAULT_APP || undefined,
2804
+ toolName: request.params.name,
2805
+ }, () => (0, audit_log_1.auditToolCall)({ tool: request.params.name, args: callArgs, authInfo, hosted, permissionCheck }, async () => {
2806
+ const { name } = request.params;
2807
+ // organization_id / application_id are ROUTING, consumed above into
2808
+ // requestContext — they are not payload. Removing them here is what makes
2809
+ // declaring them on a tool safe: the handlers that forward their args
2810
+ // verbatim (lists, webhooks, sessions, transactions, vendors…) would
2811
+ // otherwise put them in a query string or a POST body the console API never
2812
+ // asked for. Behaviour-preserving for the handlers that DO read them —
2813
+ // marketplace/travelRule pass them to resolveOrganizationId /
2814
+ // resolveApplicationId, which fall back to the very context set above.
2815
+ // A blank OPTIONAL argument (`""`, or a `null` the schema never admits) is the
2816
+ // model filling every declared argument, not a value: dropped here so the
2817
+ // handlers forward the call a schema-honouring model would have made. READ
2818
+ // tools only — on an update tool a `""` can mean "clear this field", and a
2819
+ // dropped one would PATCH nothing and report success.
2820
+ const args = (0, blank_args_1.dropBlankOptionals)((0, config_1.stripRoutingIds)(request.params.arguments), annotationsFor(name).readOnlyHint ? inputSchemaByTool.get(name) : undefined);
2821
+ // ...but a handful of handlers take the routing ids as EXPLICIT PARAMETERS rather than
2822
+ // resolving them from requestContext, and the strip above hands them `undefined`:
2823
+ // 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.
2826
+ const withRoutingIds = (a) => ({
2827
+ ...(a ?? {}),
2828
+ ...(argOrg ? { organization_id: argOrg } : {}),
2829
+ ...(argApp ? { application_id: argApp } : {}),
2830
+ });
2831
+ // Privileged operational tools require a privileged token (the verification backend's role
2832
+ // permission + 2FA is the authoritative gate; this is defense-in-depth + a clearer error).
2833
+ // There are none in the open-source build (isPrivilegedToolName is always false there).
2834
+ if ((0, privileged_tools_1.isPrivilegedToolName)(name) && !(0, privileged_tools_1.isPrivilegedCaller)(authInfo, { hosted })) {
2835
+ return { content: [{ type: "text", text: `Tool '${name}' requires elevated (privileged) access.` }], isError: true };
1478
2836
  }
1479
- case "didit_poa_verification": {
1480
- const { document_image_path, ...poaOpts } = args;
1481
- result = await standalone.poaVerification(document_image_path, poaOpts);
1482
- break;
2837
+ // Mirror of the tools/list exclusion: a hosted connector authenticates with OAuth, so it
2838
+ // never accepts account credentials/OTP codes as tool arguments, from any caller.
2839
+ if (hosted && ACCOUNT_BOOTSTRAP_TOOLS.has(name)) {
2840
+ return {
2841
+ content: [{ type: "text", text: `Tool '${name}' is not available on the hosted connector - authentication is handled by OAuth. Use the local stdio server (npx @didit-protocol/mcp-server) for account setup.` }],
2842
+ isError: true,
2843
+ };
1483
2844
  }
1484
- case "didit_database_validation":
1485
- result = await standalone.databaseValidation(args);
1486
- break;
1487
- // Standalone: KYB registry
1488
- case "didit_kyb_search":
1489
- result = await standalone.kybSearch(args);
1490
- break;
1491
- case "didit_kyb_select":
1492
- result = await standalone.kybSelect(args);
1493
- break;
1494
- // Standalone: Biometrics
1495
- case "didit_passive_liveness": {
1496
- const { image_path, ...plOpts } = args;
1497
- result = await standalone.passiveLiveness(image_path, plOpts);
1498
- break;
2845
+ // Mirror of the tools/list catalog profile: a tool (or an input property) the endpoint does
2846
+ // not offer is refused even if the client memorised it from the full catalog.
2847
+ const profileRefusal = (0, chatgpt_app_1.catalogProfileRefusal)(profile, name, callArgs);
2848
+ if (profileRefusal) {
2849
+ return { content: [{ type: "text", text: profileRefusal }], isError: true };
1499
2850
  }
1500
- case "didit_face_match": {
1501
- const { image_1_path, image_2_path, ...fmOpts } = args;
1502
- result = await standalone.faceMatch(image_1_path, image_2_path, fmOpts);
1503
- break;
2851
+ // The console's entry tool (chatgpt-app.ts): no Didit call, it names the page to open.
2852
+ if (name === chatgpt_app_1.CONSOLE_OPEN_TOOL) {
2853
+ if (!(0, chatgpt_app_1.profileServesWidgets)(profile))
2854
+ return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true };
2855
+ return (0, chatgpt_app_1.consoleOpenResult)(callArgs);
1504
2856
  }
1505
- case "didit_face_search": {
1506
- const { image_path, ...fsOpts } = args;
1507
- result = await standalone.faceSearch(image_path, fsOpts);
1508
- break;
2857
+ // Single-org/single-app callers: fill the default scope so they needn't pass/discover ids.
2858
+ await ensureScopeDefaults(name);
2859
+ try {
2860
+ // The caller's organization role lacks the permission the backend would demand for
2861
+ // this tool: refuse here with the permission named (the backend would 403 anyway).
2862
+ if (permission === "deny")
2863
+ throw (0, permissions_1.missingPermissionError)(name);
2864
+ let result;
2865
+ // Multi-tenant caller invoked a per-app list tool with no resolvable scope: span all apps
2866
+ // (same shape as the *_search sibling) instead of throwing, so the first call succeeds.
2867
+ const aggregate = aggregateFallbackFor(name);
2868
+ if ((0, privileged_tools_1.isPrivilegedToolName)(name)) {
2869
+ result = await (0, privileged_tools_1.dispatchPrivilegedTool)(name, args);
2870
+ }
2871
+ else if ((0, internal_tools_1.isInternalToolName)(name)) {
2872
+ result = await (0, internal_tools_1.dispatchInternalTool)(name, args);
2873
+ }
2874
+ else if (aggregate) {
2875
+ // Scope survives the fallback: when the org resolved but the app did not, span only
2876
+ // that org's apps rather than every org the caller can reach.
2877
+ const scopedOrg = config_1.requestContext.getStore()?.organizationId;
2878
+ result = await aggregate({
2879
+ ...withRoutingIds(args),
2880
+ ...(scopedOrg ? { organization_id: scopedOrg } : {}),
2881
+ });
2882
+ }
2883
+ else
2884
+ switch (name) {
2885
+ // Auth
2886
+ case "didit_account_register":
2887
+ result = await auth.register(args.email, args.password);
2888
+ break;
2889
+ case "didit_account_verify_email":
2890
+ result = await auth.verifyEmail(args.email, args.code);
2891
+ break;
2892
+ case "didit_account_resend_otp":
2893
+ result = await auth.resendOtp(args.email);
2894
+ break;
2895
+ case "didit_account_login":
2896
+ result = await auth.login(args.email, args.password);
2897
+ break;
2898
+ case "didit_account_verify_2fa":
2899
+ result = await auth.verify2fa(args.temp_token, args.code);
2900
+ break;
2901
+ case "didit_org_list":
2902
+ result = await auth.listOrganizations(stdioAccessTokenArg(args));
2903
+ break;
2904
+ case "didit_org_list_applications":
2905
+ result = await auth.listApplications(argOrg, stdioAccessTokenArg(args));
2906
+ break;
2907
+ case "didit_org_get_application":
2908
+ result = await auth.getApplication(argOrg, argApp, stdioAccessTokenArg(args));
2909
+ break;
2910
+ case "didit_org_reveal_application_api_key":
2911
+ result = await auth.revealApplicationApiKey(argOrg, argApp, args?.confirm, stdioAccessTokenArg(args));
2912
+ break;
2913
+ // Context + cross-org/app aggregate search
2914
+ case "didit_context_get":
2915
+ result = await context.getContext();
2916
+ break;
2917
+ case "didit_session_search":
2918
+ result = await search.searchSessions(withRoutingIds(args));
2919
+ break;
2920
+ case "didit_transaction_search":
2921
+ result = await search.searchTransactions(withRoutingIds(args));
2922
+ break;
2923
+ case "didit_case_search":
2924
+ result = await search.searchCases(withRoutingIds(args));
2925
+ break;
2926
+ case "didit_vendor_user_search":
2927
+ result = await search.searchVendorUsers(withRoutingIds(args));
2928
+ break;
2929
+ case "didit_vendor_business_search":
2930
+ result = await search.searchVendorBusinesses(withRoutingIds(args));
2931
+ break;
2932
+ case "didit_analytics":
2933
+ // Like the *_search tools: the routing ids NARROW the fan-out (one org, or one app).
2934
+ result = await analytics.analytics(withRoutingIds(args));
2935
+ break;
2936
+ // Sessions
2937
+ case "didit_session_create":
2938
+ result = await sessions.createSession(args || {});
2939
+ break;
2940
+ case "didit_session_list":
2941
+ result = await sessions.listSessions(args);
2942
+ break;
2943
+ case "didit_session_get_decision":
2944
+ result = await sessions.getSessionDecision(args.session_id);
2945
+ break;
2946
+ case "didit_session_update_status": {
2947
+ const { session_id, ...data } = args;
2948
+ result = await sessions.updateSessionStatus(session_id, data);
2949
+ break;
2950
+ }
2951
+ case "didit_session_update_data": {
2952
+ const { session_id, ...data } = args;
2953
+ result = await sessions.updateSessionData(session_id, data);
2954
+ break;
2955
+ }
2956
+ case "didit_session_update_poa_data": {
2957
+ const { session_id, ...data } = args;
2958
+ result = await sessions.updateSessionPoaData(session_id, data);
2959
+ break;
2960
+ }
2961
+ case "didit_session_delete":
2962
+ result = await sessions.deleteSession(args.session_id, args?.confirm);
2963
+ break;
2964
+ case "didit_session_batch_delete":
2965
+ result = await sessions.batchDeleteSessions(args?.session_numbers, args?.delete_all, args?.confirm);
2966
+ break;
2967
+ case "didit_session_generate_pdf":
2968
+ result = await sessions.generateSessionPdf(args.session_id);
2969
+ break;
2970
+ case "didit_session_list_reviews":
2971
+ result = await sessions.listSessionReviews(args.session_id);
2972
+ break;
2973
+ case "didit_session_add_review": {
2974
+ const { session_id, ...data } = args;
2975
+ result = await sessions.addSessionReview(session_id, data);
2976
+ break;
2977
+ }
2978
+ case "didit_session_share":
2979
+ result = await sessions.shareSession(args.session_id, args);
2980
+ break;
2981
+ case "didit_session_explain_decision":
2982
+ result = await (0, session_explain_1.explainSessionDecision)(args.session_id);
2983
+ break;
2984
+ case "didit_session_webhooks":
2985
+ result = await sessions.listSessionWebhooks(args.session_id, Number(args.wait_seconds ?? 0));
2986
+ break;
2987
+ case "didit_session_webhook_resend":
2988
+ result = await sessions.resendSessionWebhook(args.session_id, args.webhook_id);
2989
+ break;
2990
+ case "didit_session_import_shared":
2991
+ result = await sessions.importSharedSession(args);
2992
+ break;
2993
+ // Session imports
2994
+ case "didit_session_create_import":
2995
+ result = await sessions.createImport(args);
2996
+ break;
2997
+ case "didit_session_get_import_template":
2998
+ result = await sessions.getImportTemplate();
2999
+ break;
3000
+ case "didit_session_get_import":
3001
+ result = await sessions.getImport(args.import_id);
3002
+ break;
3003
+ case "didit_session_get_import_errors":
3004
+ result = await sessions.getImportErrors(args.import_id);
3005
+ break;
3006
+ // Workflows
3007
+ case "didit_workflow_list":
3008
+ result = await settings.listWorkflows();
3009
+ break;
3010
+ case "didit_workflow_create":
3011
+ result = await settings.createWorkflow(args || {});
3012
+ break;
3013
+ case "didit_workflow_get":
3014
+ result = await settings.getWorkflow(args.workflow_id);
3015
+ break;
3016
+ case "didit_workflow_update": {
3017
+ const { workflow_id, ...data } = args;
3018
+ result = await settings.updateWorkflow(workflow_id, data);
3019
+ break;
3020
+ }
3021
+ case "didit_workflow_delete":
3022
+ result = await settings.deleteWorkflow(args.workflow_id);
3023
+ break;
3024
+ case "didit_workflow_search":
3025
+ result = await search.searchWorkflows(withRoutingIds(args));
3026
+ break;
3027
+ case "didit_workflow_get_graph":
3028
+ result = await workflowGraph.getWorkflowGraph(args.workflow_id, args, Boolean(args?.include_config));
3029
+ break;
3030
+ case "didit_workflow_get_field_definitions":
3031
+ result = await workflowGraph.getWorkflowFieldDefinitions(args.workflow_id, args);
3032
+ break;
3033
+ case "didit_workflow_get_feature_config_schema": {
3034
+ // Answered from the artifact this server ships with - no API call, so it
3035
+ // works before a workflow or an application even exists.
3036
+ const feature = args?.feature;
3037
+ if (feature && !feature_config_schema_1.FEATURE_CONFIG_SCHEMA.features[feature]) {
3038
+ throw new Error(`Unknown feature "${feature}". Known features: ${feature_config_schema_1.WORKFLOW_FEATURES.join(", ")}.`);
3039
+ }
3040
+ result = {
3041
+ schema_version: feature_config_schema_1.FEATURE_CONFIG_SCHEMA.schema_version,
3042
+ checksum: feature_config_schema_1.FEATURE_CONFIG_CHECKSUM,
3043
+ source: feature_config_schema_1.FEATURE_CONFIG_SCHEMA.source,
3044
+ value_kinds: feature_config_schema_1.FEATURE_CONFIG_SCHEMA.value_kinds,
3045
+ features: feature
3046
+ ? { [feature]: feature_config_schema_1.FEATURE_CONFIG_SCHEMA.features[feature] }
3047
+ : feature_config_schema_1.FEATURE_CONFIG_SCHEMA.features,
3048
+ };
3049
+ break;
3050
+ }
3051
+ case "didit_workflow_get_id_verification_methods_catalog":
3052
+ result = await workflowGraph.getIdVerificationMethodsCatalog(args.workflow_id, args);
3053
+ break;
3054
+ case "didit_workflow_get_kyb_registry_catalog":
3055
+ result = await workflowGraph.getKybRegistryCatalog(args?.countries);
3056
+ break;
3057
+ case "didit_workflow_get_branch_fields":
3058
+ result = await workflowGraph.getWorkflowBranchFields(args.workflow_id, args.graph, (args?.branch_node_id ?? args?.node_id), args);
3059
+ break;
3060
+ case "didit_workflow_validate_graph":
3061
+ result = await workflowGraph.validateWorkflowGraph(args?.workflow_id, args.graph, args, Boolean(args?.include_config));
3062
+ break;
3063
+ case "didit_workflow_edit_graph":
3064
+ result = await workflowGraph.editWorkflowGraph(args.workflow_id, args.operations, Boolean(args?.publish), args);
3065
+ break;
3066
+ case "didit_workflow_set_graph":
3067
+ result = await workflowGraph.setWorkflowGraph(args.workflow_id, args.graph, Boolean(args?.publish), args);
3068
+ break;
3069
+ case "didit_workflow_create_draft":
3070
+ result = await workflowGraph.createWorkflowDraft(args.workflow_id, args);
3071
+ break;
3072
+ case "didit_workflow_publish":
3073
+ result = await workflowGraph.publishWorkflow(args.workflow_id, args);
3074
+ break;
3075
+ // Questionnaires
3076
+ case "didit_questionnaire_list":
3077
+ result = await questionnaires.listQuestionnaires();
3078
+ break;
3079
+ case "didit_questionnaire_create":
3080
+ result = await questionnaires.createQuestionnaire(args);
3081
+ break;
3082
+ case "didit_questionnaire_append_choices": {
3083
+ const { questionnaire_id, ...data } = args;
3084
+ result = await questionnaires.appendQuestionnaireChoices(questionnaire_id, data);
3085
+ break;
3086
+ }
3087
+ case "didit_questionnaire_get":
3088
+ result = await questionnaires.getQuestionnaire(args.questionnaire_id, Boolean(args?.include_translations));
3089
+ break;
3090
+ case "didit_questionnaire_update": {
3091
+ const { questionnaire_id, ...data } = args;
3092
+ result = await questionnaires.updateQuestionnaire(questionnaire_id, data);
3093
+ break;
3094
+ }
3095
+ case "didit_questionnaire_delete":
3096
+ result = await questionnaires.deleteQuestionnaire(args.questionnaire_id);
3097
+ break;
3098
+ // Users
3099
+ case "didit_vendor_user_list":
3100
+ result = await users.listUsers(args);
3101
+ break;
3102
+ case "didit_vendor_user_create":
3103
+ result = await users.createUser(args);
3104
+ break;
3105
+ case "didit_vendor_user_get":
3106
+ result = await users.getUser(args.vendor_data);
3107
+ break;
3108
+ case "didit_vendor_user_update": {
3109
+ const { vendor_data, ...data } = args;
3110
+ result = await users.updateUser(vendor_data, data);
3111
+ break;
3112
+ }
3113
+ case "didit_vendor_user_update_status":
3114
+ result = await users.updateUserStatus(args.vendor_data, args.status);
3115
+ break;
3116
+ case "didit_vendor_user_delete":
3117
+ result = await users.deleteUsers(args?.vendor_data_list, args?.delete_all, args?.confirm);
3118
+ break;
3119
+ // Businesses
3120
+ case "didit_vendor_business_list":
3121
+ result = await businesses.listBusinesses(args);
3122
+ break;
3123
+ case "didit_vendor_business_create":
3124
+ result = await businesses.createBusiness(args);
3125
+ break;
3126
+ case "didit_vendor_business_get":
3127
+ result = await businesses.getBusiness(args.vendor_data);
3128
+ break;
3129
+ case "didit_vendor_business_update": {
3130
+ const { vendor_data, ...data } = args;
3131
+ result = await businesses.updateBusiness(vendor_data, data);
3132
+ break;
3133
+ }
3134
+ case "didit_vendor_business_update_status":
3135
+ result = await businesses.updateBusinessStatus(args.vendor_data, args.status);
3136
+ break;
3137
+ case "didit_vendor_business_delete":
3138
+ result = await businesses.deleteBusinesses(args?.vendor_data_list, args?.didit_internal_id_list, args?.delete_all, args?.confirm);
3139
+ break;
3140
+ // Transactions
3141
+ case "didit_transaction_list":
3142
+ result = await transactions.listTransactions(args);
3143
+ break;
3144
+ case "didit_transaction_create":
3145
+ result = await transactions.createTransaction(args);
3146
+ break;
3147
+ case "didit_transaction_get":
3148
+ result = await transactions.getTransaction(args.transaction_id);
3149
+ break;
3150
+ case "didit_transaction_screen_wallet":
3151
+ result = await transactions.screenWallet(args);
3152
+ break;
3153
+ case "didit_transaction_rule_list":
3154
+ result = await transactions.listTransactionRules(args);
3155
+ break;
3156
+ case "didit_transaction_rule_get":
3157
+ result = await transactions.getTransactionRule(args.rule_uuid);
3158
+ break;
3159
+ case "didit_transaction_rule_create":
3160
+ result = await transactions.createTransactionRule(args);
3161
+ break;
3162
+ case "didit_transaction_rule_update": {
3163
+ const { rule_uuid, ...data } = args;
3164
+ result = await transactions.updateTransactionRule(rule_uuid, data);
3165
+ break;
3166
+ }
3167
+ case "didit_transaction_rule_delete":
3168
+ result = await transactions.deleteTransactionRule(args.rule_uuid);
3169
+ break;
3170
+ case "didit_transaction_rule_backtest":
3171
+ result = await transactions.backtestTransactionRule(args);
3172
+ break;
3173
+ case "didit_transaction_rule_library_list":
3174
+ result = await transactions.listTransactionRuleLibrary(args);
3175
+ break;
3176
+ case "didit_transaction_rule_install":
3177
+ result = await transactions.installTransactionRuleLibrary(args);
3178
+ break;
3179
+ case "didit_transaction_rule_uninstall":
3180
+ result = await transactions.uninstallTransactionRuleLibrary(args);
3181
+ break;
3182
+ // Billing
3183
+ case "didit_org_get_balance":
3184
+ result = await billing.getBalance(args?.organization_id);
3185
+ break;
3186
+ case "didit_org_top_up":
3187
+ result = await billing.topUp((args?.amount_in_dollars ?? args?.amount), args?.confirm, args?.success_url, args?.cancel_url);
3188
+ break;
3189
+ // Customization
3190
+ case "didit_branding_get":
3191
+ result = await customization.getCustomization();
3192
+ break;
3193
+ case "didit_branding_update":
3194
+ result = await customization.updateCustomization(args);
3195
+ break;
3196
+ // Webhook destinations
3197
+ case "didit_webhook_list":
3198
+ result = await webhooks.listDestinations();
3199
+ break;
3200
+ case "didit_webhook_create":
3201
+ result = await webhooks.createDestination(args);
3202
+ break;
3203
+ case "didit_webhook_get":
3204
+ result = await webhooks.getDestination(args.destination_uuid);
3205
+ break;
3206
+ case "didit_webhook_update": {
3207
+ const { destination_uuid, ...data } = args;
3208
+ result = await webhooks.updateDestination(destination_uuid, data);
3209
+ break;
3210
+ }
3211
+ case "didit_webhook_delete":
3212
+ result = await webhooks.deleteDestination(args.destination_uuid);
3213
+ break;
3214
+ // Lists
3215
+ case "didit_lists_list":
3216
+ result = await lists.listLists(args);
3217
+ break;
3218
+ case "didit_lists_create":
3219
+ result = await lists.createList(args);
3220
+ break;
3221
+ case "didit_lists_get":
3222
+ result = await lists.getListDetail(args.list_uuid);
3223
+ break;
3224
+ case "didit_lists_update": {
3225
+ const { list_uuid: ulListUuid, ...ulData } = args;
3226
+ result = await lists.updateList(ulListUuid, ulData);
3227
+ break;
3228
+ }
3229
+ case "didit_lists_delete":
3230
+ result = await lists.deleteList(args.list_uuid);
3231
+ break;
3232
+ case "didit_lists_entries_list": {
3233
+ const { list_uuid: leListUuid, ...leParams } = args;
3234
+ result = await lists.listEntries(leListUuid, leParams);
3235
+ break;
3236
+ }
3237
+ case "didit_lists_entry_create": {
3238
+ const { list_uuid: ceListUuid, ...ceData } = args;
3239
+ result = await lists.createEntry(ceListUuid, ceData);
3240
+ break;
3241
+ }
3242
+ case "didit_lists_entry_upload_face": {
3243
+ const { list_uuid: ufListUuid, image_path, image_base64, ...ufData } = args;
3244
+ result = await lists.uploadFaceEntry(ufListUuid, { image_path, image_base64, ...ufData });
3245
+ break;
3246
+ }
3247
+ case "didit_lists_entry_delete": {
3248
+ const { list_uuid: deListUuid, entry_uuid: deEntryUuid } = args;
3249
+ result = await lists.deleteEntry(deListUuid, deEntryUuid);
3250
+ break;
3251
+ }
3252
+ // Standalone: Identity & Documents
3253
+ case "didit_verify_id": {
3254
+ const { front_image_path, back_image_path, front_image_base64, back_image_base64, ...idOpts } = args;
3255
+ result = await standalone.idVerification({ path: front_image_path, base64: front_image_base64 }, back_image_path || back_image_base64 ? { path: back_image_path, base64: back_image_base64 } : undefined, idOpts);
3256
+ break;
3257
+ }
3258
+ case "didit_verify_poa": {
3259
+ const { document_image_path, document_image_base64, ...poaOpts } = args;
3260
+ result = await standalone.poaVerification({ path: document_image_path, base64: document_image_base64 }, poaOpts);
3261
+ break;
3262
+ }
3263
+ case "didit_verify_database":
3264
+ result = await standalone.databaseValidation(args);
3265
+ break;
3266
+ // Standalone: KYB registry
3267
+ case "didit_verify_kyb_search":
3268
+ result = await standalone.kybSearch(args);
3269
+ break;
3270
+ case "didit_verify_kyb_select":
3271
+ result = await standalone.kybSelect(args);
3272
+ break;
3273
+ // Standalone: Biometrics
3274
+ case "didit_verify_passive_liveness": {
3275
+ const { image_path, image_base64, ...plOpts } = args;
3276
+ result = await standalone.passiveLiveness({ path: image_path, base64: image_base64 }, plOpts);
3277
+ break;
3278
+ }
3279
+ case "didit_verify_face_match": {
3280
+ const { image_1_path, image_2_path, image_1_base64, image_2_base64, ...fmOpts } = args;
3281
+ result = await standalone.faceMatch({ path: image_1_path, base64: image_1_base64 }, { path: image_2_path, base64: image_2_base64 }, fmOpts);
3282
+ break;
3283
+ }
3284
+ case "didit_verify_face_search": {
3285
+ const { image_path, image_base64, ...fsOpts } = args;
3286
+ result = await standalone.faceSearch({ path: image_path, base64: image_base64 }, fsOpts);
3287
+ break;
3288
+ }
3289
+ case "didit_verify_age": {
3290
+ const { image_path, image_base64, ...aeOpts } = args;
3291
+ result = await standalone.ageEstimation({ path: image_path, base64: image_base64 }, aeOpts);
3292
+ break;
3293
+ }
3294
+ // Standalone: AML
3295
+ case "didit_verify_aml":
3296
+ result = await standalone.amlScreening(args);
3297
+ break;
3298
+ // Standalone: Email & Phone
3299
+ case "didit_verify_email_send":
3300
+ result = await standalone.emailSend(args);
3301
+ break;
3302
+ case "didit_verify_email_check":
3303
+ result = await standalone.emailCheck(args);
3304
+ break;
3305
+ case "didit_verify_phone_send":
3306
+ result = await standalone.phoneSend(args);
3307
+ break;
3308
+ case "didit_verify_phone_check":
3309
+ result = await standalone.phoneCheck(args);
3310
+ break;
3311
+ // Blocklist / allowlist
3312
+ case "didit_blocklist_get":
3313
+ result = await blocklist.getBlocklist(args);
3314
+ break;
3315
+ case "didit_blocklist_add":
3316
+ result = await blocklist.addToBlocklist(args);
3317
+ break;
3318
+ case "didit_blocklist_remove":
3319
+ result = await blocklist.removeFromBlocklist(args);
3320
+ break;
3321
+ case "didit_allowlist_add":
3322
+ result = await blocklist.addToAllowlist(args);
3323
+ break;
3324
+ // Case management
3325
+ case "didit_case_list":
3326
+ result = await cases.listCases(args);
3327
+ break;
3328
+ case "didit_case_get":
3329
+ result = await cases.getCase(args.case_id);
3330
+ break;
3331
+ case "didit_case_create":
3332
+ result = await cases.createCase(args);
3333
+ break;
3334
+ case "didit_case_statistics":
3335
+ result = await cases.caseStatistics(args);
3336
+ break;
3337
+ case "didit_case_manage":
3338
+ result = await cases.manageCase(args.case_id, args.action, args?.data || {}, args?.confirm);
3339
+ break;
3340
+ // Reports
3341
+ case "didit_report_list":
3342
+ result = await reports.listReports(args);
3343
+ break;
3344
+ case "didit_report_get":
3345
+ result = await reports.getReport(args.report_id);
3346
+ break;
3347
+ case "didit_report_get_download_url":
3348
+ result = await reports.getReportDownloadUrl(args.report_id);
3349
+ break;
3350
+ case "didit_report_export":
3351
+ result = await reports.exportReport(args.kind, args?.data || {});
3352
+ break;
3353
+ // Audit logs + alerts
3354
+ case "didit_audit_log_list":
3355
+ result = await observability.listAuditLogs(args);
3356
+ break;
3357
+ case "didit_alert_list":
3358
+ result = await observability.listAlerts(args);
3359
+ break;
3360
+ case "didit_alert_configure":
3361
+ result = await observability.configureAlert(args.alert_type, args?.data || {});
3362
+ break;
3363
+ // Org members / roles / API keys
3364
+ case "didit_org_list_members":
3365
+ result = await members.listMembers(args?.organization_id, args);
3366
+ break;
3367
+ case "didit_org_invite_member":
3368
+ result = await members.inviteMember(args, args?.organization_id);
3369
+ break;
3370
+ case "didit_org_update_member":
3371
+ result = await members.updateMember(args.member_id, args, args?.organization_id);
3372
+ break;
3373
+ case "didit_org_remove_member":
3374
+ result = await members.removeMember(args.member_id, args?.organization_id);
3375
+ break;
3376
+ case "didit_org_list_roles":
3377
+ result = await members.listRoles(args?.organization_id);
3378
+ break;
3379
+ case "didit_org_list_api_keys":
3380
+ result = await members.listApiKeys(args?.organization_id, args?.application_id);
3381
+ break;
3382
+ // Compliance
3383
+ case "didit_workflow_build_graph":
3384
+ result = await compliance.buildWorkflow(args);
3385
+ break;
3386
+ default:
3387
+ return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true };
3388
+ }
3389
+ // Annotated here, after BOTH paths (the scoped list and the cross-app aggregate
3390
+ // fallback) have produced their rows, so the flag behaves the same either way.
3391
+ if (name === "didit_workflow_list" && args?.include_age_assurance) {
3392
+ result = await workflowGraph.annotateAgeAssurance(result);
3393
+ }
3394
+ // Apply the endpoint's data boundary to BOTH response channels, including modern RPC.
3395
+ result = (0, chatgpt_app_1.applyCatalogResult)(profile, name, result);
3396
+ // `content` is the model-facing channel (a client with an outputSchema hands
3397
+ // THIS text to the model, not structuredContent), so it is COMPACT: the
3398
+ // 2-space pretty print ran ~3× the compact form — seven didit_workflow_get
3399
+ // reads of ~50k chars reached the assistant's model as ~147k chars each and
3400
+ // burst its 1.05M-token window (didit-ai-assistant, Sentry
3401
+ // DIDIT-AI-ASSISTANT-2K, 429 turns 11-15 Sep 2026). Same data, same order.
3402
+ return {
3403
+ content: [{ type: "text", text: JSON.stringify(result) }],
3404
+ structuredContent: result && typeof result === "object" && !Array.isArray(result) ? result : { value: result },
3405
+ };
1509
3406
  }
1510
- case "didit_age_estimation": {
1511
- const { image_path, ...aeOpts } = args;
1512
- result = await standalone.ageEstimation(image_path, aeOpts);
1513
- break;
3407
+ catch (error) {
3408
+ // Structured, sanitized error: code/field/hint/allowed surfaced; backend secrets,
3409
+ // PII and local paths stripped; structuredContent OMITTED so a strict client never
3410
+ // validates an error against the tool's success outputSchema.
3411
+ const shape = (0, security_1.toSafeErrorShape)(error);
3412
+ const fieldLine = shape.field ? `\nField: ${shape.field}` : "";
3413
+ const hintLine = shape.hint ? `\nHint: ${shape.hint}` : "";
3414
+ const allowedLine = shape.allowed && shape.allowed.length ? `\nAllowed: ${shape.allowed.join(", ")}` : "";
3415
+ return {
3416
+ content: [{ type: "text", text: `Error [${shape.code}]: ${shape.message}${fieldLine}${hintLine}${allowedLine}` }],
3417
+ isError: true,
3418
+ };
1514
3419
  }
1515
- // Standalone: AML
1516
- case "didit_aml_screening":
1517
- result = await standalone.amlScreening(args);
1518
- break;
1519
- // Standalone: Email & Phone
1520
- case "didit_email_send":
1521
- result = await standalone.emailSend(args);
1522
- break;
1523
- case "didit_email_check":
1524
- result = await standalone.emailCheck(args);
1525
- break;
1526
- case "didit_phone_send":
1527
- result = await standalone.phoneSend(args);
1528
- break;
1529
- case "didit_phone_check":
1530
- result = await standalone.phoneCheck(args);
1531
- break;
1532
- default:
1533
- return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true };
1534
- }
1535
- return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
1536
- }
1537
- catch (error) {
1538
- const message = error?.message || String(error);
1539
- return { content: [{ type: "text", text: `Error: ${message}` }], isError: true };
1540
- }
1541
- });
3420
+ }));
3421
+ });
3422
+ return server;
3423
+ }
1542
3424
  async function main() {
1543
3425
  const transport = new stdio_js_1.StdioServerTransport();
3426
+ const server = createServer({ profile: (0, chatgpt_app_1.stdioCatalogProfile)() });
1544
3427
  await server.connect(transport);
1545
- console.error(`Didit MCP Server v${SERVER_VERSION} running on stdio`);
3428
+ console.error(`Didit MCP Server v${config_1.SERVER_VERSION} running on stdio`);
3429
+ }
3430
+ // Only auto-start the stdio server when this file is run directly — when the HTTP
3431
+ // entrypoint (src/http.ts) imports createServer(), main() must NOT fire.
3432
+ if (require.main === module) {
3433
+ main().catch(console.error);
1546
3434
  }
1547
- main().catch(console.error);
1548
3435
  //# sourceMappingURL=index.js.map