@didit-protocol/mcp-server 4.0.0 → 5.1.33

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