@didit-protocol/mcp-server 5.1.52 → 5.1.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +156 -14
- package/dist/account-session.d.ts +46 -0
- package/dist/account-session.d.ts.map +1 -0
- package/dist/account-session.js +262 -0
- package/dist/account-session.js.map +1 -0
- package/dist/api-key-connection.d.ts +77 -0
- package/dist/api-key-connection.d.ts.map +1 -0
- package/dist/api-key-connection.js +170 -0
- package/dist/api-key-connection.js.map +1 -0
- package/dist/app-api-key.d.ts.map +1 -1
- package/dist/app-api-key.js +4 -0
- package/dist/app-api-key.js.map +1 -1
- package/dist/audit-log.d.ts +2 -0
- package/dist/audit-log.d.ts.map +1 -1
- package/dist/audit-log.js +13 -0
- package/dist/audit-log.js.map +1 -1
- package/dist/auth/introspection-verifier.d.ts.map +1 -1
- package/dist/auth/introspection-verifier.js +10 -0
- package/dist/auth/introspection-verifier.js.map +1 -1
- package/dist/compress.d.ts +8 -0
- package/dist/compress.d.ts.map +1 -0
- package/dist/compress.js +90 -0
- package/dist/compress.js.map +1 -0
- package/dist/config.d.ts +12 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +33 -6
- package/dist/config.js.map +1 -1
- package/dist/device-login.d.ts +5 -0
- package/dist/device-login.d.ts.map +1 -1
- package/dist/device-login.js +2 -0
- package/dist/device-login.js.map +1 -1
- package/dist/guidance.d.ts +53 -0
- package/dist/guidance.d.ts.map +1 -0
- package/dist/guidance.js +183 -0
- package/dist/guidance.js.map +1 -0
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +43 -5
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +510 -121
- package/dist/index.js.map +1 -1
- package/dist/internal-tools.d.ts +6 -1
- package/dist/internal-tools.d.ts.map +1 -1
- package/dist/internal-tools.js +3 -2
- package/dist/internal-tools.js.map +1 -1
- package/dist/login-cli.d.ts.map +1 -1
- package/dist/login-cli.js +8 -0
- package/dist/login-cli.js.map +1 -1
- package/dist/mcp-modern.d.ts +9 -5
- package/dist/mcp-modern.d.ts.map +1 -1
- package/dist/mcp-modern.js +31 -8
- package/dist/mcp-modern.js.map +1 -1
- package/dist/orgapp.d.ts.map +1 -1
- package/dist/orgapp.js +14 -1
- package/dist/orgapp.js.map +1 -1
- package/dist/paging.d.ts +43 -0
- package/dist/paging.d.ts.map +1 -0
- package/dist/paging.js +98 -0
- package/dist/paging.js.map +1 -0
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +1 -0
- package/dist/permissions.js.map +1 -1
- package/dist/privileged-tools.d.ts +5 -1
- package/dist/privileged-tools.d.ts.map +1 -1
- package/dist/privileged-tools.js +2 -2
- package/dist/privileged-tools.js.map +1 -1
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js +11 -4
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/billing.d.ts.map +1 -1
- package/dist/tools/billing.js +29 -0
- package/dist/tools/billing.js.map +1 -1
- package/dist/tools/blocklist.d.ts.map +1 -1
- package/dist/tools/blocklist.js +21 -0
- package/dist/tools/blocklist.js.map +1 -1
- package/dist/tools/cases.d.ts.map +1 -1
- package/dist/tools/cases.js +12 -0
- package/dist/tools/cases.js.map +1 -1
- package/dist/tools/context.d.ts.map +1 -1
- package/dist/tools/context.js +16 -0
- package/dist/tools/context.js.map +1 -1
- package/dist/tools/discovery.d.ts +50 -0
- package/dist/tools/discovery.d.ts.map +1 -0
- package/dist/tools/discovery.js +522 -0
- package/dist/tools/discovery.js.map +1 -0
- package/dist/tools/docs.d.ts +10 -0
- package/dist/tools/docs.d.ts.map +1 -0
- package/dist/tools/docs.js +137 -0
- package/dist/tools/docs.js.map +1 -0
- package/dist/tools/investigator.d.ts.map +1 -1
- package/dist/tools/investigator.js +4 -3
- package/dist/tools/investigator.js.map +1 -1
- package/dist/tools/questionnaires.d.ts +2 -1
- package/dist/tools/questionnaires.d.ts.map +1 -1
- package/dist/tools/questionnaires.js +3 -2
- package/dist/tools/questionnaires.js.map +1 -1
- package/dist/tools/search.d.ts +3 -1
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +20 -6
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/sessions.d.ts +2 -1
- package/dist/tools/sessions.d.ts.map +1 -1
- package/dist/tools/sessions.js +3 -2
- package/dist/tools/sessions.js.map +1 -1
- package/dist/tools/settings.d.ts +4 -0
- package/dist/tools/settings.d.ts.map +1 -1
- package/dist/tools/settings.js +7 -0
- package/dist/tools/settings.js.map +1 -1
- package/dist/tools/transactions.d.ts.map +1 -1
- package/dist/tools/transactions.js +21 -0
- package/dist/tools/transactions.js.map +1 -1
- package/dist/toolsets.d.ts +87 -0
- package/dist/toolsets.d.ts.map +1 -0
- package/dist/toolsets.js +345 -0
- package/dist/toolsets.js.map +1 -0
- package/package.json +8 -3
package/dist/index.js
CHANGED
|
@@ -34,6 +34,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
};
|
|
35
35
|
})();
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.NAME_KEYED_TABLES = void 0;
|
|
38
|
+
exports.serverDescriptorOf = serverDescriptorOf;
|
|
37
39
|
exports.createServer = createServer;
|
|
38
40
|
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
39
41
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
@@ -66,14 +68,21 @@ const feature_config_schema_1 = require("./feature-config-schema");
|
|
|
66
68
|
const analytics = __importStar(require("./tools/analytics"));
|
|
67
69
|
const compliance = __importStar(require("./tools/compliance"));
|
|
68
70
|
const device_login_1 = require("./device-login");
|
|
71
|
+
const account_session_1 = require("./account-session");
|
|
72
|
+
const api_key_connection_1 = require("./api-key-connection");
|
|
69
73
|
const login_cli_1 = require("./login-cli");
|
|
70
74
|
const config_1 = require("./config");
|
|
71
75
|
const blank_args_1 = require("./blank-args");
|
|
72
76
|
const chatgpt_app_1 = require("./chatgpt-app");
|
|
73
77
|
const orgapp_1 = require("./orgapp");
|
|
78
|
+
const paging_1 = require("./paging");
|
|
74
79
|
const security_1 = require("./security");
|
|
75
80
|
const audit_log_1 = require("./audit-log");
|
|
76
81
|
const permissions_1 = require("./permissions");
|
|
82
|
+
const toolsets_1 = require("./toolsets");
|
|
83
|
+
const discovery_1 = require("./tools/discovery");
|
|
84
|
+
const docs_1 = require("./tools/docs");
|
|
85
|
+
const guidance_1 = require("./guidance");
|
|
77
86
|
const SESSION_STATUSES = "Not Started, In Progress, In Review, Approved, Declined, Expired, Abandoned, Kyc Expired, Resubmitted, Awaiting User";
|
|
78
87
|
const LANGUAGE_CODES = [
|
|
79
88
|
"en", "ar", "bg", "bn", "bs", "ca", "cnr", "cs", "da", "de", "el", "es", "et",
|
|
@@ -379,45 +388,9 @@ const LAST_N_DAYS_PROP = {
|
|
|
379
388
|
description: "Relative window: include only the last N days (sets date_from/date_to). Alternative to passing date_from/date_to.",
|
|
380
389
|
},
|
|
381
390
|
};
|
|
382
|
-
// Tool names are domain-first (`didit_<domain>_<action>`)
|
|
383
|
-
//
|
|
384
|
-
// (
|
|
385
|
-
// alphabetical name sort is the only lever). The group label below is derived from the
|
|
386
|
-
// name prefix and emitted per tool as _meta["anthropic/toolGroup"] (app-facing metadata
|
|
387
|
-
// the model never sees) — harmless today, future-proof if the UI ever renders it.
|
|
388
|
-
const TOOL_GROUP_BY_PREFIX = [
|
|
389
|
-
...(privileged_tools_1.PRIVILEGED_GROUP_PREFIX ? [privileged_tools_1.PRIVILEGED_GROUP_PREFIX] : []),
|
|
390
|
-
["account_", "Account Setup"],
|
|
391
|
-
["context_", "Account & Org"],
|
|
392
|
-
["org_", "Account & Org"],
|
|
393
|
-
["billing_", "Billing"],
|
|
394
|
-
["session_", "Sessions"],
|
|
395
|
-
["workflow_", "Workflows & Questionnaires"],
|
|
396
|
-
["questionnaire_", "Workflows & Questionnaires"],
|
|
397
|
-
["lists_", "Lists & Blocklist"],
|
|
398
|
-
["blocklist_", "Lists & Blocklist"],
|
|
399
|
-
["allowlist_", "Lists & Blocklist"],
|
|
400
|
-
["vendor_", "Vendor Users & Businesses"],
|
|
401
|
-
["transaction_", "Transactions (AML)"],
|
|
402
|
-
["case_", "Cases"],
|
|
403
|
-
["investigator_", "Investigator"],
|
|
404
|
-
["webhook_", "Webhooks & Alerts"],
|
|
405
|
-
["alert_", "Webhooks & Alerts"],
|
|
406
|
-
["report_", "Reports & Audit"],
|
|
407
|
-
["audit_", "Reports & Audit"],
|
|
408
|
-
["analytics", "Reports & Audit"],
|
|
409
|
-
["branding_", "Branding"],
|
|
410
|
-
...internal_tools_1.INTERNAL_GROUP_PREFIXES,
|
|
411
|
-
["verify_", "Verification APIs"],
|
|
412
|
-
];
|
|
413
|
-
function toolGroupOf(name) {
|
|
414
|
-
const rest = name.replace(/^didit_/, "");
|
|
415
|
-
for (const [prefix, group] of TOOL_GROUP_BY_PREFIX) {
|
|
416
|
-
if (rest.startsWith(prefix))
|
|
417
|
-
return group;
|
|
418
|
-
}
|
|
419
|
-
return "Other";
|
|
420
|
-
}
|
|
391
|
+
// Tool names are domain-first (`didit_<domain>_<action>`). The name prefix decides both the
|
|
392
|
+
// toolset a tool loads with and the group a connector's permission screen shows it under
|
|
393
|
+
// (`_meta["anthropic/toolGroup"]`): see toolsets.ts.
|
|
421
394
|
// Tools that don't operate on an org/app scope — never auto-resolve a default for them.
|
|
422
395
|
const SCOPE_AGNOSTIC_TOOLS = new Set([
|
|
423
396
|
"didit_account_register",
|
|
@@ -431,6 +404,10 @@ const SCOPE_AGNOSTIC_TOOLS = new Set([
|
|
|
431
404
|
"didit_context_get",
|
|
432
405
|
// Public pricing catalog: no org/app scope to resolve.
|
|
433
406
|
"didit_workflow_get_kyb_registry_catalog",
|
|
407
|
+
// The catalog and the documentation are the same whatever the organization.
|
|
408
|
+
discovery_1.TOOL_SEARCH,
|
|
409
|
+
discovery_1.TOOL_DESCRIBE,
|
|
410
|
+
docs_1.DOCS_SEARCH_TOOL,
|
|
434
411
|
]);
|
|
435
412
|
// Account bootstrap tools accept passwords/OTP codes and are only for unauthenticated
|
|
436
413
|
// stdio setup. Hosted (remote) servers exclude them for EVERY caller - a remote connector
|
|
@@ -556,6 +533,8 @@ const EXPLICIT_DESTRUCTIVE_TOOLS = new Set([
|
|
|
556
533
|
// Investigator decisions and policy answers: human decisions behind confirm:true.
|
|
557
534
|
...investigator_1.INVESTIGATOR_DECISION_TOOLS,
|
|
558
535
|
...internal_tools_1.INTERNAL_DESTRUCTIVE_TOOLS,
|
|
536
|
+
// Runs any tool that changes data (tools/discovery.ts), so a client asks before each call.
|
|
537
|
+
discovery_1.TOOL_CALL_WRITE,
|
|
559
538
|
]);
|
|
560
539
|
// Tools that can reach outside the current Didit workspace/account boundary by
|
|
561
540
|
// sending email/SMS, creating third-party checkout, registering webhook delivery
|
|
@@ -603,7 +582,29 @@ const EXPLICIT_READ_TOOLS = new Set([
|
|
|
603
582
|
"didit_session_explain_decision",
|
|
604
583
|
// Quotes a plan change (a GET): nothing is bought, the person confirms in the console.
|
|
605
584
|
"didit_billing_quote_plan",
|
|
585
|
+
// Discovery (tools/discovery.ts): describe reads the catalog, call_read refuses anything that writes.
|
|
586
|
+
discovery_1.TOOL_DESCRIBE,
|
|
587
|
+
discovery_1.TOOL_CALL_READ,
|
|
606
588
|
]);
|
|
589
|
+
/**
|
|
590
|
+
* Every table in this file that is keyed by a tool's name, for the one test that holds them to
|
|
591
|
+
* the tool list (test/tables-name-real-tools.test.mjs).
|
|
592
|
+
*
|
|
593
|
+
* A tool is defined in one place and classified in several. Rename it in its definition and not
|
|
594
|
+
* here, and nothing fails: the entry simply stops matching. A destructive tool then reads as an
|
|
595
|
+
* ordinary write and a client no longer asks before running it; a tool kept off the hosted
|
|
596
|
+
* server is listed there again. So an entry that names no tool is an error, not dead weight.
|
|
597
|
+
*/
|
|
598
|
+
exports.NAME_KEYED_TABLES = {
|
|
599
|
+
SCOPE_AGNOSTIC_TOOLS: [...SCOPE_AGNOSTIC_TOOLS],
|
|
600
|
+
ACCOUNT_BOOTSTRAP_TOOLS: [...ACCOUNT_BOOTSTRAP_TOOLS],
|
|
601
|
+
HOSTED_APP_EXCLUDED_TOOLS: [...HOSTED_APP_EXCLUDED_TOOLS],
|
|
602
|
+
AGGREGATE_FALLBACK: Object.keys(AGGREGATE_FALLBACK),
|
|
603
|
+
EXPLICIT_DESTRUCTIVE_TOOLS: [...EXPLICIT_DESTRUCTIVE_TOOLS],
|
|
604
|
+
EXPLICIT_OPEN_WORLD_TOOLS: [...EXPLICIT_OPEN_WORLD_TOOLS],
|
|
605
|
+
EXPLICIT_WRITE_TOOLS: [...EXPLICIT_WRITE_TOOLS],
|
|
606
|
+
EXPLICIT_READ_TOOLS: [...EXPLICIT_READ_TOOLS],
|
|
607
|
+
};
|
|
607
608
|
function annotationsFor(name) {
|
|
608
609
|
const tokens = name.replace(/^didit_/, "").split("_");
|
|
609
610
|
const title = toolTitle(name);
|
|
@@ -625,6 +626,90 @@ function annotationsFor(name) {
|
|
|
625
626
|
}
|
|
626
627
|
return { title, readOnlyHint: false, openWorldHint, destructiveHint: false };
|
|
627
628
|
}
|
|
629
|
+
// ---------------------------------------------------------------------------
|
|
630
|
+
// Listing a tool without what a model does not need repeated
|
|
631
|
+
// ---------------------------------------------------------------------------
|
|
632
|
+
// Nearly every tool takes the two routing ids. A listed tool carries them in one short line
|
|
633
|
+
// each; the server instructions (guidance.ts) explain once how they resolve.
|
|
634
|
+
const ROUTING_ID_SUMMARY = {
|
|
635
|
+
organization_id: "Organization id (didit_context_get).",
|
|
636
|
+
application_id: "Application id (didit_context_get).",
|
|
637
|
+
};
|
|
638
|
+
const ROUTING_ID_OPTIONAL = " Optional if you have only one.";
|
|
639
|
+
function trimDefinition(tool) {
|
|
640
|
+
const properties = tool.inputSchema?.properties;
|
|
641
|
+
if (!properties)
|
|
642
|
+
return tool;
|
|
643
|
+
const required = new Set(tool.inputSchema?.required ?? []);
|
|
644
|
+
const trimmed = { ...properties };
|
|
645
|
+
let changed = false;
|
|
646
|
+
// Identity, not name: a tool that words its own organization_id ("REQUIRED. ...") keeps it.
|
|
647
|
+
for (const key of ["organization_id", "application_id"]) {
|
|
648
|
+
if (properties[key] === orgapp_1.ORG_APP_PROPS[key]) {
|
|
649
|
+
trimmed[key] = { type: "string", description: ROUTING_ID_SUMMARY[key] + (required.has(key) ? "" : ROUTING_ID_OPTIONAL) };
|
|
650
|
+
changed = true;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
return changed ? { ...tool, inputSchema: { ...tool.inputSchema, properties: trimmed } } : tool;
|
|
654
|
+
}
|
|
655
|
+
const ROUTING_IDS = ["organization_id", "application_id"];
|
|
656
|
+
/**
|
|
657
|
+
* An API key connection is one application (api-key-connection.ts): every tool acts on it, and
|
|
658
|
+
* a call that names another one is refused. Its tools therefore do not take the two routing ids
|
|
659
|
+
* at all. A model cannot get them wrong, and about 36 KB of the tool list is not sent.
|
|
660
|
+
*/
|
|
661
|
+
function withoutRoutingIds(tool) {
|
|
662
|
+
const schema = tool.inputSchema;
|
|
663
|
+
const properties = schema?.properties;
|
|
664
|
+
if (!schema || !properties || !ROUTING_IDS.some((key) => key in properties))
|
|
665
|
+
return tool;
|
|
666
|
+
const isRoutingId = (key) => ROUTING_IDS.includes(key);
|
|
667
|
+
const kept = Object.fromEntries(Object.entries(properties).filter(([key]) => !isRoutingId(key)));
|
|
668
|
+
const { required: declared, ...rest } = schema;
|
|
669
|
+
const required = (declared ?? []).filter((key) => !isRoutingId(key));
|
|
670
|
+
return { ...tool, inputSchema: { ...rest, properties: kept, ...(required.length > 0 ? { required } : {}) } };
|
|
671
|
+
}
|
|
672
|
+
/** A tool as one connection is given it, in tools/list and by the discovery tools alike. */
|
|
673
|
+
function definitionFor(tool, connection) {
|
|
674
|
+
return connection.apiKey ? withoutRoutingIds(tool) : trimDefinition(tool);
|
|
675
|
+
}
|
|
676
|
+
// The workflow graph manual (WORKFLOW_GRAPH_SCHEMA: about 26 KB of text, a tenth of the whole
|
|
677
|
+
// list) is the `graph` argument of the tool that saves a graph and of the tool that validates
|
|
678
|
+
// one. A connection that lists both gets the manual once and a pointer to it on the other tool.
|
|
679
|
+
//
|
|
680
|
+
// The manual stays on the tool that SAVES. A graph built without the feature-config contract
|
|
681
|
+
// and saved is the failure this manual exists to prevent (the API drops a config key it does
|
|
682
|
+
// not know, and nothing fails: test/feature-config-contract.test.mjs), so the saving tool never
|
|
683
|
+
// depends on another definition having been read. A graph built without it and only CHECKED
|
|
684
|
+
// comes back with its errors, and the pointer says where the contract is.
|
|
685
|
+
//
|
|
686
|
+
// A tool shown on its own (didit_tool_describe, or a list without the saving tool, such as a
|
|
687
|
+
// read-only connection) always carries the manual itself.
|
|
688
|
+
const GRAPH_MANUAL_TOOL = "didit_workflow_set_graph";
|
|
689
|
+
// Only the text goes: the shape itself (start_node, nodes, both required) costs 250 bytes and is
|
|
690
|
+
// what lets a client check a graph before it makes the call.
|
|
691
|
+
const GRAPH_MANUAL_POINTER = {
|
|
692
|
+
...WORKFLOW_GRAPH_SCHEMA,
|
|
693
|
+
description: `The graph to check, { start_node, nodes }: exactly the object the \`graph\` argument of ${GRAPH_MANUAL_TOOL} ` +
|
|
694
|
+
"describes (node shapes, branches, operators, every feature's config keys, allow-list shorthands). Read that " +
|
|
695
|
+
"description to build the graph, check it here, then save it there.",
|
|
696
|
+
};
|
|
697
|
+
function shareGraphManual(tools) {
|
|
698
|
+
if (!tools.some((tool) => tool.name === GRAPH_MANUAL_TOOL))
|
|
699
|
+
return tools;
|
|
700
|
+
return tools.map((tool) => {
|
|
701
|
+
const properties = tool.inputSchema?.properties;
|
|
702
|
+
// Identity, not name: a tool that words its own `graph` argument keeps it.
|
|
703
|
+
if (tool.name === GRAPH_MANUAL_TOOL || properties?.graph !== WORKFLOW_GRAPH_SCHEMA)
|
|
704
|
+
return tool;
|
|
705
|
+
return { ...tool, inputSchema: { ...tool.inputSchema, properties: { ...properties, graph: GRAPH_MANUAL_POINTER } } };
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
const serverDescriptors = new WeakMap();
|
|
709
|
+
/** The capabilities and instructions `createServer` gave this server. */
|
|
710
|
+
function serverDescriptorOf(server) {
|
|
711
|
+
return serverDescriptors.get(server) ?? { capabilities: { tools: {} } };
|
|
712
|
+
}
|
|
628
713
|
/**
|
|
629
714
|
* Build a fully-wired MCP server (tool list + dispatch). A factory rather than a
|
|
630
715
|
* singleton because the stateless Streamable-HTTP transport needs a fresh server
|
|
@@ -638,10 +723,21 @@ function annotationsFor(name) {
|
|
|
638
723
|
*
|
|
639
724
|
* `profile` selects the catalog served (see chatgpt-app.ts): `full` (default) or `chatgpt`,
|
|
640
725
|
* the reduced allow-list the hosted server exposes at /mcp/chatgpt for the ChatGPT app store.
|
|
726
|
+
*
|
|
727
|
+
* `selection` is what one connection asked to load (toolsets.ts): which toolsets tools/list
|
|
728
|
+
* returns and whether the connection is read-only. Omitted, nothing is narrowed. The entry
|
|
729
|
+
* points pass it: http.ts from the request URL and headers, the stdio main from argv and env.
|
|
641
730
|
*/
|
|
642
731
|
function createServer(options = {}) {
|
|
643
732
|
const hosted = options.hosted === true;
|
|
733
|
+
const describesApiKey = hosted && options.apiKey === true;
|
|
644
734
|
const profile = options.profile ?? "full";
|
|
735
|
+
// The reduced ChatGPT catalog is an allow-list that was reviewed tool by tool, descriptor by
|
|
736
|
+
// descriptor. It is served exactly as it is defined: never narrowed by a selection, never
|
|
737
|
+
// trimmed, with no discovery tools, instructions or prompts. Everything below that is new
|
|
738
|
+
// behaviour is gated on `lean`.
|
|
739
|
+
const lean = profile === "full";
|
|
740
|
+
const selection = lean ? options.selection ?? toolsets_1.FULL_SELECTION : toolsets_1.FULL_SELECTION;
|
|
645
741
|
// THE money gate of the hosted server. Every hosted endpoint hides and refuses didit_org_top_up
|
|
646
742
|
// unless it passes `moneyTools: true`, and only the unlisted /mcp/payments endpoint does (http.ts).
|
|
647
743
|
// It never opens on a reduced catalog profile (the ChatGPT catalog has no credit-purchase flow),
|
|
@@ -660,23 +756,12 @@ function createServer(options = {}) {
|
|
|
660
756
|
// on EVERY profile - the full catalog at /mcp is a public directory listing too. The stdio
|
|
661
757
|
// ChatGPT profile mirrors this omission for local catalog review.
|
|
662
758
|
const stdioOnlyAccessToken = (description) => hosted || profile === "chatgpt" ? {} : { access_token: { type: "string", description } };
|
|
663
|
-
const stdioTokenHint = hosted || profile === "chatgpt" ? "" : " In stdio mode
|
|
759
|
+
const stdioTokenHint = hosted || profile === "chatgpt" ? "" : " In stdio mode the sign-in from login/verify_email is used automatically.";
|
|
664
760
|
// Call-time mirror: hosted and ChatGPT calls never process a token handed in as
|
|
665
761
|
// an argument, even if a client crafted one from a memorised stdio schema. Ignoring (rather
|
|
666
762
|
// than refusing) keeps every existing hosted caller working - the header Bearer that already
|
|
667
763
|
// authenticated the request is the identity used either way.
|
|
668
764
|
const stdioAccessTokenArg = (a) => hosted || profile === "chatgpt" ? undefined : a?.access_token;
|
|
669
|
-
// Only a profile that serves MCP Apps UI (chatgpt-app.ts) advertises `resources`; every
|
|
670
|
-
// other profile keeps exactly the capabilities it always had.
|
|
671
|
-
const servesWidgets = (0, chatgpt_app_1.profileServesWidgets)(profile);
|
|
672
|
-
const server = new index_js_1.Server({ name: "didit", version: config_1.SERVER_VERSION }, { capabilities: servesWidgets ? { tools: {}, resources: {} } : { tools: {} } });
|
|
673
|
-
if (servesWidgets) {
|
|
674
|
-
// The UI templates (`ui://` resources) the tools reference. Static, identical for every
|
|
675
|
-
// caller, and behind the same Bearer gate as the rest of the endpoint (http.ts).
|
|
676
|
-
server.setRequestHandler(types_js_1.ListResourcesRequestSchema, async () => ({ resources: (0, chatgpt_app_1.listWidgetResources)() }));
|
|
677
|
-
server.setRequestHandler(types_js_1.ListResourceTemplatesRequestSchema, async () => ({ resourceTemplates: [] }));
|
|
678
|
-
server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async (request) => (0, chatgpt_app_1.readWidgetResource)(request.params.uri));
|
|
679
|
-
}
|
|
680
765
|
// ---------------------------------------------------------------------------
|
|
681
766
|
// Tool definitions
|
|
682
767
|
// ---------------------------------------------------------------------------
|
|
@@ -699,7 +784,8 @@ function createServer(options = {}) {
|
|
|
699
784
|
},
|
|
700
785
|
{
|
|
701
786
|
name: "didit_account_verify_email",
|
|
702
|
-
description: "Verify email with the 6-character code. Returns
|
|
787
|
+
description: "Verify email with the 6-character code. Returns the new organization with its live application and its sandbox_application (each with client_id and api_key) and an access_token, " +
|
|
788
|
+
"and signs the local server in: the tools that follow are authenticated automatically. " +
|
|
703
789
|
"If the account already has two-factor authentication it returns 2fa_required (and a temp_token when it has an authenticator) instead of tokens: finish with didit_account_verify_2fa. " +
|
|
704
790
|
"If the account's organization enforces SSO it returns sso_required: no token or API key is issued here, so ask the person to sign in through their organization's SSO in the Didit console in a browser; do not retry.",
|
|
705
791
|
inputSchema: {
|
|
@@ -724,7 +810,7 @@ function createServer(options = {}) {
|
|
|
724
810
|
},
|
|
725
811
|
{
|
|
726
812
|
name: "didit_account_login",
|
|
727
|
-
description: "
|
|
813
|
+
description: "Log in to an existing Didit account. Signs the local server in, so the tools that follow are authenticated automatically, and returns access_token. If the account has two-factor " +
|
|
728
814
|
"authentication it returns 2fa_required and a temp_token instead: finish with didit_account_verify_2fa. " +
|
|
729
815
|
"If the account's organization enforces SSO it returns sso_required: no token is issued by password, so ask the person to sign in through SSO in the console, or use didit_account_device_login_start. " +
|
|
730
816
|
"For an account that signs in with a passkey or SSO (no password), use didit_account_device_login_start instead.",
|
|
@@ -753,7 +839,7 @@ function createServer(options = {}) {
|
|
|
753
839
|
{
|
|
754
840
|
name: "didit_account_verify_2fa",
|
|
755
841
|
description: "Finish logging in to an account with two-factor authentication, using the temp_token from didit_account_login " +
|
|
756
|
-
"and the current 6-digit authenticator code (or an unused backup code).
|
|
842
|
+
"and the current 6-digit authenticator code (or an unused backup code). Signs the local server in, like didit_account_login, and returns access_token.",
|
|
757
843
|
inputSchema: {
|
|
758
844
|
type: "object",
|
|
759
845
|
properties: {
|
|
@@ -770,7 +856,7 @@ function createServer(options = {}) {
|
|
|
770
856
|
inputSchema: {
|
|
771
857
|
type: "object",
|
|
772
858
|
properties: {
|
|
773
|
-
...stdioOnlyAccessToken("Only for stdio mode
|
|
859
|
+
...stdioOnlyAccessToken("Only for stdio mode, and only to act as another account than the one signed in: a Bearer access token from login/verify_email."),
|
|
774
860
|
},
|
|
775
861
|
},
|
|
776
862
|
},
|
|
@@ -1178,12 +1264,13 @@ function createServer(options = {}) {
|
|
|
1178
1264
|
},
|
|
1179
1265
|
{
|
|
1180
1266
|
name: "didit_session_list_reviews",
|
|
1181
|
-
description: "List the review history and activity log for a session.",
|
|
1267
|
+
description: "List the review history and activity log for a session, newest first. One page: 50 entries unless `limit` says otherwise, with `count` as the total and `offset` to read the ones after.",
|
|
1182
1268
|
inputSchema: {
|
|
1183
1269
|
type: "object",
|
|
1184
1270
|
properties: {
|
|
1185
1271
|
...orgapp_1.ORG_APP_PROPS,
|
|
1186
1272
|
session_id: { type: "string" },
|
|
1273
|
+
...paging_1.PAGE_PROPS,
|
|
1187
1274
|
},
|
|
1188
1275
|
required: ["session_id"],
|
|
1189
1276
|
},
|
|
@@ -1371,7 +1458,7 @@ function createServer(options = {}) {
|
|
|
1371
1458
|
// ── Workflows (Verification Settings) ───────────────────────────────
|
|
1372
1459
|
{
|
|
1373
1460
|
name: "didit_workflow_list",
|
|
1374
|
-
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.",
|
|
1461
|
+
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. In one application the answer is ONE PAGE, most recently changed first: 20 workflows unless `limit` says otherwise, with `count` as the total and `offset` to read the ones after. Across applications it is the first 50 unless `limit` says otherwise, with `total_matched` as the total and the same `offset`. To count or filter workflows, read until you have them all.",
|
|
1375
1462
|
inputSchema: {
|
|
1376
1463
|
type: "object",
|
|
1377
1464
|
properties: {
|
|
@@ -1380,6 +1467,7 @@ function createServer(options = {}) {
|
|
|
1380
1467
|
type: "boolean",
|
|
1381
1468
|
description: "Annotate each non-archived row with whether it does age assurance, and how. Required to find workflows that check age from the document.",
|
|
1382
1469
|
},
|
|
1470
|
+
...paging_1.PAGE_PROPS,
|
|
1383
1471
|
},
|
|
1384
1472
|
},
|
|
1385
1473
|
},
|
|
@@ -1650,8 +1738,8 @@ function createServer(options = {}) {
|
|
|
1650
1738
|
// ── Questionnaires ──────────────────────────────────────────────────
|
|
1651
1739
|
{
|
|
1652
1740
|
name: "didit_questionnaire_list",
|
|
1653
|
-
description: "List all custom questionnaires for your application.",
|
|
1654
|
-
inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS } },
|
|
1741
|
+
description: "List all custom questionnaires for your application. One page, newest first: 50 unless `limit` says otherwise, with `count` as the total and `offset` to read the ones after.",
|
|
1742
|
+
inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS, ...paging_1.PAGE_PROPS } },
|
|
1655
1743
|
},
|
|
1656
1744
|
{
|
|
1657
1745
|
name: "didit_questionnaire_create",
|
|
@@ -2143,6 +2231,9 @@ function createServer(options = {}) {
|
|
|
2143
2231
|
},
|
|
2144
2232
|
},
|
|
2145
2233
|
},
|
|
2234
|
+
// install / uninstall need library_keys or bundle. That is said in the descriptions and enforced
|
|
2235
|
+
// by the handlers (tools/transactions.ts), never with a top-level anyOf in the input schema:
|
|
2236
|
+
// model APIs refuse a tool list that has one (test/tool-schemas-portable.test.mjs).
|
|
2146
2237
|
{
|
|
2147
2238
|
name: "didit_transaction_rule_install",
|
|
2148
2239
|
description: "Install PRESET rules by library_keys, bundle, or both. If both are supplied, only keys in that bundle are " +
|
|
@@ -2159,7 +2250,6 @@ function createServer(options = {}) {
|
|
|
2159
2250
|
},
|
|
2160
2251
|
bundle: { type: "string", description: "Install presets from this bundle." },
|
|
2161
2252
|
},
|
|
2162
|
-
anyOf: [{ required: ["library_keys"] }, { required: ["bundle"] }],
|
|
2163
2253
|
},
|
|
2164
2254
|
},
|
|
2165
2255
|
{
|
|
@@ -2177,7 +2267,6 @@ function createServer(options = {}) {
|
|
|
2177
2267
|
},
|
|
2178
2268
|
bundle: { type: "string", description: "Uninstall presets from this bundle." },
|
|
2179
2269
|
},
|
|
2180
|
-
anyOf: [{ required: ["library_keys"] }, { required: ["bundle"] }],
|
|
2181
2270
|
},
|
|
2182
2271
|
},
|
|
2183
2272
|
// ── Travel Rule (FATF / EU TFR managed exchange) ─────────────────────
|
|
@@ -2816,25 +2905,73 @@ function createServer(options = {}) {
|
|
|
2816
2905
|
},
|
|
2817
2906
|
},
|
|
2818
2907
|
// ── Blocklist / Allowlist ───────────────────────────────────────────
|
|
2908
|
+
// The blocklist and the allowlist are written from a SESSION: an entry is an item that session
|
|
2909
|
+
// holds (its face, its document, its phone number, its email address), never a free value.
|
|
2819
2910
|
{
|
|
2820
2911
|
name: "didit_blocklist_get",
|
|
2821
|
-
description: "List blocklist
|
|
2822
|
-
|
|
2912
|
+
description: "List the application's blocklist, newest first: the faces, identity documents, phone numbers and email " +
|
|
2913
|
+
"addresses that are blocked, each with the `session_id` it was blocked from (what didit_blocklist_remove " +
|
|
2914
|
+
"takes). One page: 50 entries unless `limit` says otherwise, with `count` as the total and `offset` to read " +
|
|
2915
|
+
"the ones after.",
|
|
2916
|
+
inputSchema: {
|
|
2917
|
+
type: "object",
|
|
2918
|
+
properties: {
|
|
2919
|
+
...orgapp_1.ORG_APP_PROPS,
|
|
2920
|
+
item_type: { type: "string", enum: ["face", "document", "phone", "email"], description: "Only entries of this kind." },
|
|
2921
|
+
...paging_1.PAGE_PROPS,
|
|
2922
|
+
},
|
|
2923
|
+
},
|
|
2823
2924
|
},
|
|
2824
2925
|
{
|
|
2825
2926
|
name: "didit_blocklist_add",
|
|
2826
|
-
description: "
|
|
2827
|
-
|
|
2927
|
+
description: "Block what a verification session holds, so that later sessions of this application with the same item are " +
|
|
2928
|
+
"caught by the blocklist check: its face, its identity document, its phone number or its email address. " +
|
|
2929
|
+
"Name the session and set at least one of the four flags to true. A flag works only when the session has " +
|
|
2930
|
+
"that item. Undo with didit_blocklist_remove.",
|
|
2931
|
+
inputSchema: {
|
|
2932
|
+
type: "object",
|
|
2933
|
+
properties: {
|
|
2934
|
+
...orgapp_1.ORG_APP_PROPS,
|
|
2935
|
+
session_id: { type: "string", description: "The session whose item is blocked." },
|
|
2936
|
+
blocklist_face: { type: "boolean", description: "Block the session's face." },
|
|
2937
|
+
blocklist_document: { type: "boolean", description: "Block the session's identity document." },
|
|
2938
|
+
blocklist_phone: { type: "boolean", description: "Block the session's phone number." },
|
|
2939
|
+
blocklist_email: { type: "boolean", description: "Block the session's email address." },
|
|
2940
|
+
},
|
|
2941
|
+
required: ["session_id"],
|
|
2942
|
+
},
|
|
2828
2943
|
},
|
|
2829
2944
|
{
|
|
2830
2945
|
name: "didit_blocklist_remove",
|
|
2831
|
-
description: "
|
|
2832
|
-
|
|
2946
|
+
description: "Lift a block. Name the session the item was blocked from (the `session_id` of the entry in " +
|
|
2947
|
+
"didit_blocklist_get) and set at least one of the four flags to true.",
|
|
2948
|
+
inputSchema: {
|
|
2949
|
+
type: "object",
|
|
2950
|
+
properties: {
|
|
2951
|
+
...orgapp_1.ORG_APP_PROPS,
|
|
2952
|
+
session_id: { type: "string", description: "The session the item was blocked from." },
|
|
2953
|
+
unblock_face: { type: "boolean", description: "Lift the block on the session's face." },
|
|
2954
|
+
unblock_document: { type: "boolean", description: "Lift the block on the session's identity document." },
|
|
2955
|
+
unblock_phone: { type: "boolean", description: "Lift the block on the session's phone number." },
|
|
2956
|
+
unblock_email: { type: "boolean", description: "Lift the block on the session's email address." },
|
|
2957
|
+
},
|
|
2958
|
+
required: ["session_id"],
|
|
2959
|
+
},
|
|
2833
2960
|
},
|
|
2834
2961
|
{
|
|
2835
2962
|
name: "didit_allowlist_add",
|
|
2836
|
-
description: "
|
|
2837
|
-
|
|
2963
|
+
description: "Mark the phone number of a verification session as trusted in this application, so that phone verification " +
|
|
2964
|
+
"does not turn it away as high risk. A phone number is the only thing that can be allowlisted, and a " +
|
|
2965
|
+
"blocked number stays blocked. Name the session and set allowlist_phone to true.",
|
|
2966
|
+
inputSchema: {
|
|
2967
|
+
type: "object",
|
|
2968
|
+
properties: {
|
|
2969
|
+
...orgapp_1.ORG_APP_PROPS,
|
|
2970
|
+
session_id: { type: "string", description: "The session whose phone number is trusted." },
|
|
2971
|
+
allowlist_phone: { type: "boolean", description: "Must be true: the phone number is what gets allowlisted." },
|
|
2972
|
+
},
|
|
2973
|
+
required: ["session_id", "allowlist_phone"],
|
|
2974
|
+
},
|
|
2838
2975
|
},
|
|
2839
2976
|
// ── Case management ─────────────────────────────────────────────────
|
|
2840
2977
|
{
|
|
@@ -2849,13 +2986,71 @@ function createServer(options = {}) {
|
|
|
2849
2986
|
},
|
|
2850
2987
|
{
|
|
2851
2988
|
name: "didit_case_create",
|
|
2852
|
-
description: "
|
|
2853
|
-
|
|
2989
|
+
description: "Open a case for a compliance review. A case is about a subject (one of your users or businesses) or is " +
|
|
2990
|
+
"linked to at least one session or transaction: pass `subject`, `links` or both. `subject.uuid` is the " +
|
|
2991
|
+
"`didit_internal_id` of the user or the business, as didit_vendor_user_get and didit_vendor_business_get " +
|
|
2992
|
+
"return it; it is not their vendor_data. Returns the case with its `uuid`. With review_duplicates true the API first looks " +
|
|
2993
|
+
"for cases already open about the same subject and answers 409 case_duplicate_review_required when it finds " +
|
|
2994
|
+
"one: show it to the person, and to open a separate case anyway send separate_incident_reason.",
|
|
2995
|
+
inputSchema: {
|
|
2996
|
+
type: "object",
|
|
2997
|
+
properties: {
|
|
2998
|
+
...orgapp_1.ORG_APP_PROPS,
|
|
2999
|
+
title: { type: "string", description: "What the case is about, in one line (255 characters at most)." },
|
|
3000
|
+
subject: {
|
|
3001
|
+
type: "object",
|
|
3002
|
+
description: "Who the case is about. Required unless `links` is given.",
|
|
3003
|
+
properties: {
|
|
3004
|
+
type: { type: "string", enum: ["user", "business"] },
|
|
3005
|
+
uuid: { type: "string", description: "The `didit_internal_id` of that user or business." },
|
|
3006
|
+
},
|
|
3007
|
+
required: ["type", "uuid"],
|
|
3008
|
+
},
|
|
3009
|
+
links: {
|
|
3010
|
+
type: "array",
|
|
3011
|
+
description: "What the case is linked to, 20 at most. Required unless `subject` is given.",
|
|
3012
|
+
items: {
|
|
3013
|
+
type: "object",
|
|
3014
|
+
properties: {
|
|
3015
|
+
entity_type: { type: "string", enum: ["session", "business_session", "transaction"] },
|
|
3016
|
+
entity_uuid: { type: "string", description: "The id of that session or transaction." },
|
|
3017
|
+
},
|
|
3018
|
+
required: ["entity_type", "entity_uuid"],
|
|
3019
|
+
},
|
|
3020
|
+
},
|
|
3021
|
+
priority: { type: "string", enum: ["LOW", "MEDIUM", "HIGH"], description: "MEDIUM when left out." },
|
|
3022
|
+
assigned_to: { type: "string", description: "The reviewer to assign the case to: the `user_id` of a member (didit_org_list_members)." },
|
|
3023
|
+
due_at: { type: "string", description: "The deadline, ISO 8601. Left out, the review policy's own deadline applies when it has one." },
|
|
3024
|
+
tags: { type: "array", items: { type: "string" }, description: "Labels to find the case by." },
|
|
3025
|
+
blueprint: { type: "string", description: "The uuid of the review policy to open the case under. It must be active." },
|
|
3026
|
+
review_duplicates: { type: "boolean", description: "Look for cases already open about the same subject before creating this one." },
|
|
3027
|
+
separate_incident_reason: { type: "string", description: "Why a separate case is wanted although one is already open (1,000 characters at most)." },
|
|
3028
|
+
},
|
|
3029
|
+
required: ["title"],
|
|
3030
|
+
},
|
|
2854
3031
|
},
|
|
2855
3032
|
{
|
|
2856
3033
|
name: "didit_case_statistics",
|
|
2857
|
-
description: "
|
|
2858
|
-
|
|
3034
|
+
description: "Case analytics for a period (totals, series over time, the queue, outcomes and workload): the last 30 days " +
|
|
3035
|
+
"unless both dates are given, two years at most. Every filter narrows the numbers.",
|
|
3036
|
+
inputSchema: {
|
|
3037
|
+
type: "object",
|
|
3038
|
+
properties: {
|
|
3039
|
+
...orgapp_1.ORG_APP_PROPS,
|
|
3040
|
+
date_from: { type: "string", description: "First day, YYYY-MM-DD. Give it together with date_to." },
|
|
3041
|
+
date_to: { type: "string", description: "Last day, YYYY-MM-DD." },
|
|
3042
|
+
status: { type: "string", enum: ["OPEN", "AWAITING_USER", "RESOLVED"] },
|
|
3043
|
+
priority: { type: "string", enum: ["LOW", "MEDIUM", "HIGH"] },
|
|
3044
|
+
source: {
|
|
3045
|
+
type: "string",
|
|
3046
|
+
enum: ["MANUAL", "AML_SCREENING", "TRANSACTION_RULE", "WORKFLOW_BUILDER"],
|
|
3047
|
+
description: "What opened the cases.",
|
|
3048
|
+
},
|
|
3049
|
+
scope: { type: "string", enum: ["identity", "transactions"], description: "Only identity cases, or only the ones a transaction rule opened." },
|
|
3050
|
+
assigned_to: { type: "string", description: "Only cases assigned to this reviewer (a member's `user_id`)." },
|
|
3051
|
+
blueprint: { type: "string", description: "Only cases under this review policy (its uuid)." },
|
|
3052
|
+
},
|
|
3053
|
+
},
|
|
2859
3054
|
},
|
|
2860
3055
|
{
|
|
2861
3056
|
name: "didit_case_manage",
|
|
@@ -2880,8 +3075,20 @@ function createServer(options = {}) {
|
|
|
2880
3075
|
// ── Reports (async exports) ─────────────────────────────────────────
|
|
2881
3076
|
{
|
|
2882
3077
|
name: "didit_report_list",
|
|
2883
|
-
description: "List generated
|
|
2884
|
-
inputSchema: {
|
|
3078
|
+
description: "List the application's generated reports, newest first, with how many there are of each status (`counts`). One page: 50 unless `limit` says otherwise, with `count` as the total and `offset` to read the ones after.",
|
|
3079
|
+
inputSchema: {
|
|
3080
|
+
type: "object",
|
|
3081
|
+
properties: {
|
|
3082
|
+
...orgapp_1.ORG_APP_PROPS,
|
|
3083
|
+
status: { type: "string", description: "Only these statuses, comma separated: PENDING, PROCESSING, READY, FAILED." },
|
|
3084
|
+
report_type: {
|
|
3085
|
+
type: "string",
|
|
3086
|
+
description: "Only these report types, comma separated, for example SESSION_EXPORT, TRANSACTION_EXPORT, CASE_EXPORT, VENDOR_USER_EXPORT.",
|
|
3087
|
+
},
|
|
3088
|
+
q: { type: "string", description: "Search by any part of the report id, or of the name or email of the person who asked for it." },
|
|
3089
|
+
...paging_1.PAGE_PROPS,
|
|
3090
|
+
},
|
|
3091
|
+
},
|
|
2885
3092
|
},
|
|
2886
3093
|
{
|
|
2887
3094
|
name: "didit_report_get",
|
|
@@ -2931,15 +3138,28 @@ function createServer(options = {}) {
|
|
|
2931
3138
|
},
|
|
2932
3139
|
{
|
|
2933
3140
|
name: "didit_alert_list",
|
|
2934
|
-
description: "List
|
|
3141
|
+
description: "List the application's alerts, one per channel: `alert_type` (email or slack), where it is sent (`value`) and whether it is on (`is_active`).",
|
|
2935
3142
|
inputSchema: { type: "object", properties: { ...orgapp_1.ORG_APP_PROPS } },
|
|
2936
3143
|
},
|
|
2937
3144
|
{
|
|
2938
3145
|
name: "didit_alert_configure",
|
|
2939
|
-
description: "
|
|
3146
|
+
description: "Set where one of the application's alerts is sent, or turn it on or off. `alert_type` is the channel. An " +
|
|
3147
|
+
"alert with no destination is always off. If the API answers 409 legacy_alerts_read_only, this " +
|
|
3148
|
+
"application's alerts are managed in the console's Notification settings and cannot be changed here.",
|
|
2940
3149
|
inputSchema: {
|
|
2941
3150
|
type: "object",
|
|
2942
|
-
properties: {
|
|
3151
|
+
properties: {
|
|
3152
|
+
...orgapp_1.ORG_APP_PROPS,
|
|
3153
|
+
alert_type: { type: "string", enum: ["email", "slack"], description: "The channel to change." },
|
|
3154
|
+
data: {
|
|
3155
|
+
type: "object",
|
|
3156
|
+
description: "What to change; a field left out keeps its value.",
|
|
3157
|
+
properties: {
|
|
3158
|
+
value: { type: "string", description: "The destination: an email address for email, a Slack webhook URL for slack." },
|
|
3159
|
+
is_active: { type: "boolean", description: "Whether the alert is on." },
|
|
3160
|
+
},
|
|
3161
|
+
},
|
|
3162
|
+
},
|
|
2943
3163
|
required: ["alert_type"],
|
|
2944
3164
|
},
|
|
2945
3165
|
},
|
|
@@ -2979,10 +3199,16 @@ function createServer(options = {}) {
|
|
|
2979
3199
|
},
|
|
2980
3200
|
{
|
|
2981
3201
|
name: "didit_org_remove_member",
|
|
2982
|
-
description: "Remove a member from the organization.",
|
|
3202
|
+
description: "Remove a member from the organization. It cannot be undone: to come back the person has to be invited again.",
|
|
2983
3203
|
inputSchema: {
|
|
2984
3204
|
type: "object",
|
|
2985
|
-
properties: {
|
|
3205
|
+
properties: {
|
|
3206
|
+
organization_id: orgapp_1.ORG_APP_PROPS.organization_id,
|
|
3207
|
+
member_id: {
|
|
3208
|
+
type: "string",
|
|
3209
|
+
description: "The `uuid` of the member's row in didit_org_list_members. Not `user_id`, and not the email address.",
|
|
3210
|
+
},
|
|
3211
|
+
},
|
|
2986
3212
|
required: ["member_id"],
|
|
2987
3213
|
},
|
|
2988
3214
|
},
|
|
@@ -3136,13 +3362,23 @@ function createServer(options = {}) {
|
|
|
3136
3362
|
additionalProperties: false,
|
|
3137
3363
|
},
|
|
3138
3364
|
},
|
|
3365
|
+
// The documentation, searched from the same connection (tools/docs.ts).
|
|
3366
|
+
...((0, docs_1.docsMcpUrl)() ? [(0, docs_1.docsSearchToolDef)()] : []),
|
|
3139
3367
|
...privileged_tools_1.PRIVILEGED_TOOL_DEFS,
|
|
3140
3368
|
];
|
|
3141
3369
|
const inputSchemaByTool = new Map(toolDefinitions().map((t) => [t.name, t.inputSchema]));
|
|
3142
|
-
|
|
3370
|
+
// ---------------------------------------------------------------------------
|
|
3371
|
+
// What a caller may use, and what a connection lists
|
|
3372
|
+
// ---------------------------------------------------------------------------
|
|
3373
|
+
/**
|
|
3374
|
+
* Every tool this caller may use on this endpoint, before the connection's selection
|
|
3375
|
+
* narrows what is LISTED. tools/list, the discovery tools and the server instructions all
|
|
3376
|
+
* start from here, so they can never disagree about what exists.
|
|
3377
|
+
*/
|
|
3378
|
+
const usableBy = (authInfo) => {
|
|
3143
3379
|
// Privileged operational tools are emitted ONLY to privileged connections; everyone else never
|
|
3144
3380
|
// sees them in tools/list (and a call is rejected below). In the open-source build there are none.
|
|
3145
|
-
const isPrivileged = (0, privileged_tools_1.isPrivilegedCaller)(
|
|
3381
|
+
const isPrivileged = (0, privileged_tools_1.isPrivilegedCaller)(authInfo, { hosted });
|
|
3146
3382
|
const tools = toolDefinitions();
|
|
3147
3383
|
// Hosted (Bearer-authenticated) catalogs never include the account-bootstrap /
|
|
3148
3384
|
// checkout / secret-reveal tools — the public app catalog must stay free of
|
|
@@ -3151,7 +3387,7 @@ function createServer(options = {}) {
|
|
|
3151
3387
|
// Only a remote (HTTP) request carries authInfo. A local stdio server started with
|
|
3152
3388
|
// DIDIT_ACCESS_TOKEN is a local setup and keeps the full catalog, as documented; counting
|
|
3153
3389
|
// that env token as a remote Bearer hid didit_org_top_up and the key reveal from it.
|
|
3154
|
-
const remoteBearer = Boolean(
|
|
3390
|
+
const remoteBearer = Boolean(authInfo?.token);
|
|
3155
3391
|
let catalog = remoteBearer && !isPrivileged
|
|
3156
3392
|
? tools.filter((t) => !HOSTED_APP_EXCLUDED_TOOLS.has(t.name) || (moneyTools && t.name === MONEY_TOOL))
|
|
3157
3393
|
: tools;
|
|
@@ -3160,15 +3396,103 @@ function createServer(options = {}) {
|
|
|
3160
3396
|
// (staff included), regardless of Bearer state. They remain available on stdio.
|
|
3161
3397
|
if (hosted)
|
|
3162
3398
|
catalog = catalog.filter((t) => !ACCOUNT_BOOTSTRAP_TOOLS.has(t.name));
|
|
3399
|
+
// An API key connection is one application and no person (api-key-connection.ts): the tools
|
|
3400
|
+
// that act for a member of an organization are not offered to it, and a call is refused below.
|
|
3401
|
+
// `describesApiKey` covers the instructions, which describe the catalog with no request at hand.
|
|
3402
|
+
if (describesApiKey || (0, api_key_connection_1.apiKeyScopeOf)(authInfo))
|
|
3403
|
+
catalog = catalog.filter((t) => !api_key_connection_1.PERSON_ONLY_TOOLS.has(t.name));
|
|
3163
3404
|
// A tool the caller's organization role could never run is not offered (permissions.ts);
|
|
3164
3405
|
// only in enforce mode — shadow mode lists everything and just records the verdicts.
|
|
3165
|
-
const tokenOrg =
|
|
3166
|
-
const query = { scopes:
|
|
3406
|
+
const tokenOrg = authInfo?.extra?.organization_id;
|
|
3407
|
+
const query = { scopes: authInfo?.scopes, mode: (0, config_1.permissionMode)(), tokenOrg, targetOrg: tokenOrg };
|
|
3167
3408
|
catalog = catalog.filter((t) => (0, permissions_1.decidePermission)({ ...query, tool: t.name }) !== "deny");
|
|
3168
3409
|
const visible = isPrivileged ? catalog : catalog.filter((t) => !(0, privileged_tools_1.isPrivilegedToolName)(t.name));
|
|
3410
|
+
// A read-only connection has no use for a tool that changes data: it is neither listed nor
|
|
3411
|
+
// discoverable, and a call is refused below.
|
|
3412
|
+
return selection.readOnly ? visible.filter((t) => annotationsFor(t.name).readOnlyHint) : visible;
|
|
3413
|
+
};
|
|
3414
|
+
/** Whether this connection lists the tool. The payments endpoint always lists its money tool. */
|
|
3415
|
+
const isListed = (name) => (0, toolsets_1.selectionLists)(selection, name) || (moneyTools && name === MONEY_TOOL);
|
|
3416
|
+
/** The usable catalog as the discovery tools read it (tools/discovery.ts). */
|
|
3417
|
+
const discoverable = (usable, authInfo) => usable.map((tool) => {
|
|
3418
|
+
const { readOnlyHint, destructiveHint } = annotationsFor(tool.name);
|
|
3419
|
+
const trimmed = definitionFor(tool, { apiKey: Boolean((0, api_key_connection_1.apiKeyScopeOf)(authInfo)) });
|
|
3420
|
+
return {
|
|
3421
|
+
name: tool.name,
|
|
3422
|
+
description: String(trimmed.description ?? ""),
|
|
3423
|
+
inputSchema: trimmed.inputSchema ?? {},
|
|
3424
|
+
access: readOnlyHint ? "read" : destructiveHint ? "destructive" : "write",
|
|
3425
|
+
listed: isListed(tool.name),
|
|
3426
|
+
};
|
|
3427
|
+
});
|
|
3428
|
+
// Capabilities, and what the server says about itself when a client connects (guidance.ts).
|
|
3429
|
+
// The instructions describe the catalog of an ordinary (non-staff) caller: they are fixed
|
|
3430
|
+
// when the server is built, before any request is seen.
|
|
3431
|
+
const servesWidgets = (0, chatgpt_app_1.profileServesWidgets)(profile);
|
|
3432
|
+
const capabilities = lean
|
|
3433
|
+
? { tools: {}, prompts: {} }
|
|
3434
|
+
: servesWidgets
|
|
3435
|
+
? { tools: {}, resources: {} }
|
|
3436
|
+
: { tools: {} };
|
|
3437
|
+
const unloadedToolsets = () => {
|
|
3438
|
+
const unloaded = new Set(usableBy(undefined)
|
|
3439
|
+
.filter((tool) => !isListed(tool.name))
|
|
3440
|
+
.map((tool) => (0, toolsets_1.toolsetOf)(tool.name))
|
|
3441
|
+
.filter((id) => Boolean(id)));
|
|
3442
|
+
return toolsets_1.TOOLSETS.map((toolset) => toolset.id).filter((id) => unloaded.has(id));
|
|
3443
|
+
};
|
|
3444
|
+
const instructions = lean
|
|
3445
|
+
? (0, guidance_1.serverInstructions)({
|
|
3446
|
+
hosted,
|
|
3447
|
+
apiKey: describesApiKey,
|
|
3448
|
+
selection,
|
|
3449
|
+
unloaded: unloadedToolsets(),
|
|
3450
|
+
selectable: toolsets_1.SELECTABLE_TOOLSET_IDS,
|
|
3451
|
+
})
|
|
3452
|
+
: undefined;
|
|
3453
|
+
const server = new index_js_1.Server({ name: "didit", version: config_1.SERVER_VERSION }, { capabilities, ...(instructions ? { instructions } : {}) });
|
|
3454
|
+
serverDescriptors.set(server, { capabilities, ...(instructions ? { instructions } : {}) });
|
|
3455
|
+
if (servesWidgets) {
|
|
3456
|
+
// The UI templates (`ui://` resources) the tools reference. Static, identical for every
|
|
3457
|
+
// caller, and behind the same Bearer gate as the rest of the endpoint (http.ts).
|
|
3458
|
+
server.setRequestHandler(types_js_1.ListResourcesRequestSchema, async () => ({ resources: (0, chatgpt_app_1.listWidgetResources)() }));
|
|
3459
|
+
server.setRequestHandler(types_js_1.ListResourceTemplatesRequestSchema, async () => ({ resourceTemplates: [] }));
|
|
3460
|
+
server.setRequestHandler(types_js_1.ReadResourceRequestSchema, async (request) => (0, chatgpt_app_1.readWidgetResource)(request.params.uri));
|
|
3461
|
+
}
|
|
3462
|
+
if (lean) {
|
|
3463
|
+
// Starting points a person picks from the client's prompt menu (guidance.ts). Static and
|
|
3464
|
+
// identical for every caller.
|
|
3465
|
+
server.setRequestHandler(types_js_1.ListPromptsRequestSchema, async () => ({ prompts: (0, guidance_1.listPrompts)() }));
|
|
3466
|
+
// A prompt names each tool the way this connection reaches it: directly when it is listed,
|
|
3467
|
+
// through the discovery tool that runs it when it is not.
|
|
3468
|
+
const promptContext = {
|
|
3469
|
+
use: (tool) => isListed(tool) ? tool : `${annotationsFor(tool).readOnlyHint ? discovery_1.TOOL_CALL_READ : discovery_1.TOOL_CALL_WRITE} (name: ${tool})`,
|
|
3470
|
+
docs: Boolean((0, docs_1.docsMcpUrl)()),
|
|
3471
|
+
};
|
|
3472
|
+
server.setRequestHandler(types_js_1.GetPromptRequestSchema, async (request) => {
|
|
3473
|
+
const prompt = (0, guidance_1.getPrompt)(request.params.name, request.params.arguments, promptContext);
|
|
3474
|
+
if (!prompt)
|
|
3475
|
+
throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Unknown prompt: ${request.params.name}`);
|
|
3476
|
+
return prompt;
|
|
3477
|
+
});
|
|
3478
|
+
}
|
|
3479
|
+
server.setRequestHandler(types_js_1.ListToolsRequestSchema, async (_request, extra) => {
|
|
3480
|
+
const usable = usableBy(extra?.authInfo);
|
|
3169
3481
|
// Endpoint catalog profile (chatgpt-app.ts): the ChatGPT endpoint offers only the
|
|
3170
3482
|
// allow-listed tools, with restricted input properties removed from their schemas.
|
|
3171
|
-
const
|
|
3483
|
+
const allowed = (0, chatgpt_app_1.applyCatalogProfile)(usable, profile);
|
|
3484
|
+
// The connection's selection (toolsets.ts): list what it asked to load, trimmed of what a
|
|
3485
|
+
// model does not need repeated, and keep the rest one step away through the discovery tools.
|
|
3486
|
+
// They appear only when something the caller may use is left out of the list.
|
|
3487
|
+
const connection = { apiKey: Boolean((0, api_key_connection_1.apiKeyScopeOf)(extra?.authInfo)) };
|
|
3488
|
+
const listed = lean
|
|
3489
|
+
? shareGraphManual(allowed.filter((t) => isListed(t.name)).map((t) => definitionFor(t, connection)))
|
|
3490
|
+
: allowed;
|
|
3491
|
+
// Discovery reads the same profile-filtered catalog the list is cut from, so a match is always
|
|
3492
|
+
// a tool this endpoint will run.
|
|
3493
|
+
const offered = lean && listed.length < allowed.length
|
|
3494
|
+
? [...listed, ...(0, discovery_1.discoveryToolDefs)(discoverable(allowed, extra?.authInfo), { readOnly: selection.readOnly })]
|
|
3495
|
+
: listed;
|
|
3172
3496
|
// Annotate each tool so the connector UI splits them into Read-only / Write / Destructive
|
|
3173
3497
|
// groups (driven by readOnlyHint + destructiveHint) instead of one flat "Other tools"
|
|
3174
3498
|
// bucket; also tag the logical domain group via _meta for future UI use.
|
|
@@ -3186,8 +3510,8 @@ function createServer(options = {}) {
|
|
|
3186
3510
|
},
|
|
3187
3511
|
_meta: {
|
|
3188
3512
|
...(t._meta ?? {}),
|
|
3189
|
-
"anthropic/toolGroup": toolGroupOf(t.name),
|
|
3190
|
-
category: toolGroupOf(t.name),
|
|
3513
|
+
"anthropic/toolGroup": (0, toolsets_1.toolGroupOf)(t.name),
|
|
3514
|
+
category: (0, toolsets_1.toolGroupOf)(t.name),
|
|
3191
3515
|
// MCP Apps linkage for the ChatGPT console (chatgpt-app.ts); `{}` on every other
|
|
3192
3516
|
// profile, so their descriptors are unchanged.
|
|
3193
3517
|
...(0, chatgpt_app_1.widgetToolMeta)(profile, t.name),
|
|
@@ -3202,17 +3526,27 @@ function createServer(options = {}) {
|
|
|
3202
3526
|
// ---------------------------------------------------------------------------
|
|
3203
3527
|
server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request, extra) => {
|
|
3204
3528
|
const authInfo = extra?.authInfo;
|
|
3529
|
+
// A call through didit_tool_call_read / _write (tools/discovery.ts) names the real tool and
|
|
3530
|
+
// carries its arguments. It is unwrapped HERE, before anything else looks at the request, so
|
|
3531
|
+
// every check below - the hosted exclusions, the permission pre-check, read-only mode, the
|
|
3532
|
+
// confirm guards, the audit line - sees the real tool, exactly as on a direct call.
|
|
3533
|
+
const via = lean && (0, discovery_1.isToolCallProxy)(request.params.name) ? request.params.name : undefined;
|
|
3534
|
+
const unwrapped = via ? (0, discovery_1.unwrapToolCall)(request.params.arguments) : undefined;
|
|
3535
|
+
const unwrapError = typeof unwrapped === "string" ? unwrapped : undefined;
|
|
3536
|
+
const proxied = unwrapped && typeof unwrapped !== "string" ? unwrapped : undefined;
|
|
3537
|
+
const toolName = proxied?.name ?? request.params.name;
|
|
3538
|
+
const toolArgs = proxied ? proxied.arguments : request.params.arguments;
|
|
3205
3539
|
// Console (management) tools target /organization/{org}/application/{app}/... paths.
|
|
3206
3540
|
// An explicit organization_id / application_id in the tool arguments takes precedence
|
|
3207
3541
|
// over the token's org context; both flow into requestContext so orgAppPath() resolves.
|
|
3208
|
-
const callArgs = (
|
|
3542
|
+
const callArgs = (toolArgs ?? {});
|
|
3209
3543
|
const argOrg = typeof callArgs.organization_id === "string" ? callArgs.organization_id : undefined;
|
|
3210
3544
|
const argApp = typeof callArgs.application_id === "string" ? callArgs.application_id : undefined;
|
|
3211
3545
|
// Permission pre-check verdict (permissions.ts): decided once here so the audit line
|
|
3212
3546
|
// can record a shadow-mode "would_deny" and the dispatch below can refuse a "deny".
|
|
3213
3547
|
const tokenOrg = authInfo?.extra?.organization_id;
|
|
3214
3548
|
const permission = (0, permissions_1.decidePermission)({
|
|
3215
|
-
tool:
|
|
3549
|
+
tool: toolName,
|
|
3216
3550
|
scopes: authInfo?.scopes,
|
|
3217
3551
|
mode: (0, config_1.permissionMode)(),
|
|
3218
3552
|
tokenOrg,
|
|
@@ -3221,23 +3555,56 @@ function createServer(options = {}) {
|
|
|
3221
3555
|
const permissionCheck = permission === "would_deny" ? permission : undefined;
|
|
3222
3556
|
// Local sign-in (device code): only a stdio server with no Bearer of its own reads the stored
|
|
3223
3557
|
// credentials, so hosted mode and DIDIT_ACCESS_TOKEN setups are untouched.
|
|
3224
|
-
const storedToken = !authInfo?.token && !hosted && !process.env.DIDIT_ACCESS_TOKEN && !ACCOUNT_BOOTSTRAP_TOOLS.has(
|
|
3558
|
+
const storedToken = !authInfo?.token && !hosted && !process.env.DIDIT_ACCESS_TOKEN && !ACCOUNT_BOOTSTRAP_TOOLS.has(toolName)
|
|
3225
3559
|
? await storedDeviceLoginToken()
|
|
3226
3560
|
: undefined;
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
authInfo?.
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3561
|
+
// An API key connection (api-key-connection.ts) is one application: its key goes out as
|
|
3562
|
+
// x-api-key and never as a Bearer, and the organization and application are the key's own.
|
|
3563
|
+
// A call that names another one is refused below rather than silently redirected.
|
|
3564
|
+
const keyScope = (0, api_key_connection_1.apiKeyScopeOf)(authInfo);
|
|
3565
|
+
return config_1.requestContext.run(keyScope
|
|
3566
|
+
? {
|
|
3567
|
+
apiKey: authInfo?.token,
|
|
3568
|
+
apiKeyScope: keyScope,
|
|
3569
|
+
organizationId: keyScope.organizationId,
|
|
3570
|
+
applicationId: keyScope.applicationId,
|
|
3571
|
+
toolName,
|
|
3572
|
+
actorVia: (0, investigator_1.actorViaFromHeaders)(extra?.requestInfo?.headers),
|
|
3573
|
+
}
|
|
3574
|
+
: {
|
|
3575
|
+
// Hosted mode: per-request Bearer from OAuth introspection. Stdio mode (tests/eval):
|
|
3576
|
+
// fall back to DIDIT_ACCESS_TOKEN + MCP_DEFAULT_ORG/APP env so the console-path tools
|
|
3577
|
+
// authenticate as that Bearer without the hosted layer.
|
|
3578
|
+
accessToken: authInfo?.token || process.env.DIDIT_ACCESS_TOKEN || storedToken || undefined,
|
|
3579
|
+
organizationId: argOrg ||
|
|
3580
|
+
authInfo?.extra?.organization_id ||
|
|
3581
|
+
process.env.MCP_DEFAULT_ORG ||
|
|
3582
|
+
undefined,
|
|
3583
|
+
applicationId: argApp || process.env.MCP_DEFAULT_APP || undefined,
|
|
3584
|
+
toolName,
|
|
3585
|
+
actorVia: (0, investigator_1.actorViaFromHeaders)(extra?.requestInfo?.headers),
|
|
3586
|
+
}, () => (0, audit_log_1.auditToolCall)({ tool: toolName, args: callArgs, authInfo, hosted, permissionCheck, via }, async () => {
|
|
3587
|
+
const name = toolName;
|
|
3588
|
+
const refuse = (text) => ({ content: [{ type: "text", text }], isError: true });
|
|
3589
|
+
if (unwrapError)
|
|
3590
|
+
return refuse(unwrapError);
|
|
3591
|
+
// A read-only connection never changes data, whatever the client has listed or remembers.
|
|
3592
|
+
if (selection.readOnly && !annotationsFor(name).readOnlyHint) {
|
|
3593
|
+
return refuse(`'${name}' changes data and this connection is read-only. To allow changes, the person reconnects without ` +
|
|
3594
|
+
(hosted ? "`read_only=true` in the server URL (or the X-MCP-Readonly header)." : "--read-only (or DIDIT_READ_ONLY)."));
|
|
3595
|
+
}
|
|
3596
|
+
// Mirror of the tools/list exclusion for an API key connection, and its one-application rule.
|
|
3597
|
+
if (keyScope) {
|
|
3598
|
+
const outOfScope = (0, api_key_connection_1.apiKeyScopeRefusal)(keyScope, argOrg, argApp);
|
|
3599
|
+
if (outOfScope)
|
|
3600
|
+
return refuse(outOfScope);
|
|
3601
|
+
if (api_key_connection_1.PERSON_ONLY_TOOLS.has(name))
|
|
3602
|
+
return refuse((0, api_key_connection_1.personOnlyRefusal)(name));
|
|
3603
|
+
}
|
|
3604
|
+
// The read proxy is annotated read-only, so it only ever runs a tool that is.
|
|
3605
|
+
if (via === discovery_1.TOOL_CALL_READ && !annotationsFor(name).readOnlyHint) {
|
|
3606
|
+
return refuse(`'${name}' changes data, so ${discovery_1.TOOL_CALL_READ} does not run it. Use ${discovery_1.TOOL_CALL_WRITE} with the same name and arguments.`);
|
|
3607
|
+
}
|
|
3241
3608
|
// organization_id / application_id are ROUTING, consumed above into
|
|
3242
3609
|
// requestContext — they are not payload. Removing them here is what makes
|
|
3243
3610
|
// declaring them on a tool safe: the handlers that forward their args
|
|
@@ -3251,7 +3618,7 @@ function createServer(options = {}) {
|
|
|
3251
3618
|
// handlers forward the call a schema-honouring model would have made. READ
|
|
3252
3619
|
// tools only — on an update tool a `""` can mean "clear this field", and a
|
|
3253
3620
|
// dropped one would PATCH nothing and report success.
|
|
3254
|
-
const args = (0, blank_args_1.dropBlankOptionals)((0, config_1.stripRoutingIds)(
|
|
3621
|
+
const args = (0, blank_args_1.dropBlankOptionals)((0, config_1.stripRoutingIds)(toolArgs), annotationsFor(name).readOnlyHint ? inputSchemaByTool.get(name) : undefined);
|
|
3255
3622
|
// ...but a handful of handlers take the routing ids as EXPLICIT PARAMETERS rather than
|
|
3256
3623
|
// resolving them from requestContext, and the strip above hands them `undefined`:
|
|
3257
3624
|
// the auth-service tools build their URL path from the argument (and the reveal tool
|
|
@@ -3325,6 +3692,13 @@ function createServer(options = {}) {
|
|
|
3325
3692
|
return { content: [{ type: "text", text: `Unknown tool: ${name}` }], isError: true };
|
|
3326
3693
|
return (0, chatgpt_app_1.consoleOpenResult)(callArgs);
|
|
3327
3694
|
}
|
|
3695
|
+
// The discovery tools (tools/discovery.ts) answer from the caller's own catalog: no Didit call.
|
|
3696
|
+
// Same catalog as tools/list: what the caller may use, cut to this endpoint's profile.
|
|
3697
|
+
if (lean && (name === discovery_1.TOOL_SEARCH || name === discovery_1.TOOL_DESCRIBE)) {
|
|
3698
|
+
const catalog = discoverable((0, chatgpt_app_1.applyCatalogProfile)(usableBy(authInfo), profile), authInfo);
|
|
3699
|
+
const found = name === discovery_1.TOOL_SEARCH ? (0, discovery_1.searchTools)(catalog, callArgs) : (0, discovery_1.describeTools)(catalog, callArgs);
|
|
3700
|
+
return { content: [{ type: "text", text: JSON.stringify(found) }], structuredContent: found };
|
|
3701
|
+
}
|
|
3328
3702
|
// Single-org/single-app callers: fill the default scope so they needn't pass/discover ids.
|
|
3329
3703
|
await ensureScopeDefaults(name);
|
|
3330
3704
|
try {
|
|
@@ -3362,14 +3736,15 @@ function createServer(options = {}) {
|
|
|
3362
3736
|
case "didit_account_register":
|
|
3363
3737
|
result = await auth.register(args.email, args.password);
|
|
3364
3738
|
break;
|
|
3739
|
+
// The three tools that answer with a sign-in: the local server keeps it (account-session.ts).
|
|
3365
3740
|
case "didit_account_verify_email":
|
|
3366
|
-
result = await auth.verifyEmail(args.email, args.code);
|
|
3741
|
+
result = (0, account_session_1.keepSignIn)(await auth.verifyEmail(args.email, args.code), { hosted });
|
|
3367
3742
|
break;
|
|
3368
3743
|
case "didit_account_resend_otp":
|
|
3369
3744
|
result = await auth.resendOtp(args.email);
|
|
3370
3745
|
break;
|
|
3371
3746
|
case "didit_account_login":
|
|
3372
|
-
result = await auth.login(args.email, args.password);
|
|
3747
|
+
result = (0, account_session_1.keepSignIn)(await auth.login(args.email, args.password), { hosted });
|
|
3373
3748
|
break;
|
|
3374
3749
|
case "didit_account_device_login_start":
|
|
3375
3750
|
result = await auth.deviceLoginStart();
|
|
@@ -3378,16 +3753,20 @@ function createServer(options = {}) {
|
|
|
3378
3753
|
result = await auth.deviceLoginPoll();
|
|
3379
3754
|
break;
|
|
3380
3755
|
case "didit_account_verify_2fa":
|
|
3381
|
-
result = await auth.verify2fa(args.temp_token, args.code);
|
|
3756
|
+
result = (0, account_session_1.keepSignIn)(await auth.verify2fa(args.temp_token, args.code), { hosted });
|
|
3382
3757
|
break;
|
|
3758
|
+
// An API key connection answers these from the key's own application: the membership
|
|
3759
|
+
// routes behind them only answer to a person (api-key-connection.ts).
|
|
3383
3760
|
case "didit_org_list":
|
|
3384
|
-
result = await auth.listOrganizations(stdioAccessTokenArg(args));
|
|
3761
|
+
result = keyScope ? (0, api_key_connection_1.apiKeyOrganizations)(keyScope) : await auth.listOrganizations(stdioAccessTokenArg(args));
|
|
3385
3762
|
break;
|
|
3386
3763
|
case "didit_org_list_applications":
|
|
3387
|
-
result = await auth.listApplications(argOrg, stdioAccessTokenArg(args));
|
|
3764
|
+
result = keyScope ? [(0, api_key_connection_1.apiKeyApplication)(keyScope)] : await auth.listApplications(argOrg, stdioAccessTokenArg(args));
|
|
3388
3765
|
break;
|
|
3389
3766
|
case "didit_org_get_application":
|
|
3390
|
-
result =
|
|
3767
|
+
result = keyScope
|
|
3768
|
+
? (0, api_key_connection_1.apiKeyApplication)(keyScope)
|
|
3769
|
+
: await auth.getApplication(argOrg, argApp, stdioAccessTokenArg(args));
|
|
3391
3770
|
break;
|
|
3392
3771
|
case "didit_org_reveal_application_api_key":
|
|
3393
3772
|
result = await auth.revealApplicationApiKey(argOrg, argApp, args?.confirm, stdioAccessTokenArg(args));
|
|
@@ -3470,7 +3849,7 @@ function createServer(options = {}) {
|
|
|
3470
3849
|
result = await sessions.validateSignatures(args.session_id, args.node_id, args?.signature_id);
|
|
3471
3850
|
break;
|
|
3472
3851
|
case "didit_session_list_reviews":
|
|
3473
|
-
result = await sessions.listSessionReviews(args.session_id);
|
|
3852
|
+
result = await sessions.listSessionReviews(args.session_id, (0, paging_1.pageParams)(args));
|
|
3474
3853
|
break;
|
|
3475
3854
|
case "didit_session_add_review": {
|
|
3476
3855
|
const { session_id, ...data } = args;
|
|
@@ -3516,7 +3895,7 @@ function createServer(options = {}) {
|
|
|
3516
3895
|
break;
|
|
3517
3896
|
// Workflows
|
|
3518
3897
|
case "didit_workflow_list":
|
|
3519
|
-
result = await settings.listWorkflows();
|
|
3898
|
+
result = await settings.listWorkflows((0, paging_1.pageParams)(args));
|
|
3520
3899
|
break;
|
|
3521
3900
|
case "didit_workflow_create":
|
|
3522
3901
|
result = await settings.createWorkflow(args || {});
|
|
@@ -3585,7 +3964,7 @@ function createServer(options = {}) {
|
|
|
3585
3964
|
break;
|
|
3586
3965
|
// Questionnaires
|
|
3587
3966
|
case "didit_questionnaire_list":
|
|
3588
|
-
result = await questionnaires.listQuestionnaires();
|
|
3967
|
+
result = await questionnaires.listQuestionnaires((0, paging_1.pageParams)(args));
|
|
3589
3968
|
break;
|
|
3590
3969
|
case "didit_questionnaire_create":
|
|
3591
3970
|
result = await questionnaires.createQuestionnaire(args);
|
|
@@ -3853,7 +4232,7 @@ function createServer(options = {}) {
|
|
|
3853
4232
|
break;
|
|
3854
4233
|
// Blocklist / allowlist
|
|
3855
4234
|
case "didit_blocklist_get":
|
|
3856
|
-
result = await blocklist.getBlocklist(args);
|
|
4235
|
+
result = await blocklist.getBlocklist({ ...args, ...(0, paging_1.pageParams)(args) });
|
|
3857
4236
|
break;
|
|
3858
4237
|
case "didit_blocklist_add":
|
|
3859
4238
|
result = await blocklist.addToBlocklist(args);
|
|
@@ -3882,7 +4261,7 @@ function createServer(options = {}) {
|
|
|
3882
4261
|
break;
|
|
3883
4262
|
// Reports
|
|
3884
4263
|
case "didit_report_list":
|
|
3885
|
-
result = await reports.listReports(args);
|
|
4264
|
+
result = await reports.listReports({ ...args, ...(0, paging_1.pageParams)(args) });
|
|
3886
4265
|
break;
|
|
3887
4266
|
case "didit_report_get":
|
|
3888
4267
|
result = await reports.getReport(args.report_id);
|
|
@@ -3931,8 +4310,15 @@ function createServer(options = {}) {
|
|
|
3931
4310
|
case "didit_workflow_build_graph":
|
|
3932
4311
|
result = await compliance.buildWorkflow(args);
|
|
3933
4312
|
break;
|
|
4313
|
+
// Documentation search: a public corpus, no Didit credentials involved.
|
|
4314
|
+
case docs_1.DOCS_SEARCH_TOOL:
|
|
4315
|
+
result = await (0, docs_1.searchDocs)(args);
|
|
4316
|
+
break;
|
|
3934
4317
|
default:
|
|
3935
|
-
return {
|
|
4318
|
+
return {
|
|
4319
|
+
content: [{ type: "text", text: `Unknown tool: ${name}${lean ? `. Find the right name with ${discovery_1.TOOL_SEARCH}.` : ""}` }],
|
|
4320
|
+
isError: true,
|
|
4321
|
+
};
|
|
3936
4322
|
}
|
|
3937
4323
|
// Annotated here, after BOTH paths (the scoped list and the cross-app aggregate
|
|
3938
4324
|
// fallback) have produced their rows, so the flag behaves the same either way.
|
|
@@ -3975,7 +4361,7 @@ function createServer(options = {}) {
|
|
|
3975
4361
|
// unauthenticated call. The message carries no token.
|
|
3976
4362
|
async function storedDeviceLoginToken() {
|
|
3977
4363
|
try {
|
|
3978
|
-
return await (0,
|
|
4364
|
+
return await (0, account_session_1.localSignInToken)();
|
|
3979
4365
|
}
|
|
3980
4366
|
catch (err) {
|
|
3981
4367
|
if (err instanceof device_login_1.DeviceLoginError)
|
|
@@ -3990,9 +4376,12 @@ async function main() {
|
|
|
3990
4376
|
return;
|
|
3991
4377
|
}
|
|
3992
4378
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
3993
|
-
|
|
4379
|
+
// A local server lists everything unless told otherwise, like the hosted one: `--toolsets` /
|
|
4380
|
+
// DIDIT_TOOLSETS and `--read-only` / DIDIT_READ_ONLY change it (toolsets.ts).
|
|
4381
|
+
const selection = (0, toolsets_1.selectionFromArgv)(process.argv.slice(2), process.env);
|
|
4382
|
+
const server = createServer({ profile: (0, chatgpt_app_1.stdioCatalogProfile)(), selection });
|
|
3994
4383
|
await server.connect(transport);
|
|
3995
|
-
console.error(`Didit MCP Server v${config_1.SERVER_VERSION} running on stdio`);
|
|
4384
|
+
console.error(`Didit MCP Server v${config_1.SERVER_VERSION} running on stdio (toolsets: ${(0, toolsets_1.selectionLabel)(selection)}${selection.readOnly ? ", read-only" : ""})`);
|
|
3996
4385
|
}
|
|
3997
4386
|
// Only auto-start the stdio server when this file is run directly — when the HTTP
|
|
3998
4387
|
// entrypoint (src/http.ts) imports createServer(), main() must NOT fire.
|