@ductape/mcp 0.2.2 → 0.2.4
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/dist/index.js +78 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { createRequire } from 'module';
|
|
13
13
|
import { execSync } from 'child_process';
|
|
14
|
+
import { homedir } from 'os';
|
|
15
|
+
import { delimiter, join } from 'path';
|
|
14
16
|
import { z } from 'zod';
|
|
15
17
|
import { executeViaProxy, generateExecutablePayload, getAssetSchemas, } from './proxy-client.js';
|
|
16
18
|
const MODULES = [
|
|
@@ -141,9 +143,10 @@ There are THREE categories of operations. Use the right tool for each:
|
|
|
141
143
|
ductape_cli("resources database create -f db-config.json")
|
|
142
144
|
This applies to: products, apps, and resources (databases, storage, caches, etc.),
|
|
143
145
|
cloud connections, and secrets. Environments have their own CLI commands (see below);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
through
|
|
146
|
+
App actions and auths are configured in the Workbench UI. Quotas, fallbacks, jobs, and
|
|
147
|
+
healthchecks are administrative resources managed with ductape_cli("resources <type> ...").
|
|
148
|
+
Features have no CLI create command because their definitions are code-first through
|
|
149
|
+
features.define.
|
|
147
150
|
|
|
148
151
|
⚠ MULTI-ENV REQUIREMENT — applies to ALL product assets (storage, database, cache,
|
|
149
152
|
messageBroker, graph, vector, and any other resource with an envs array):
|
|
@@ -1175,15 +1178,19 @@ function checkCli() {
|
|
|
1175
1178
|
try {
|
|
1176
1179
|
const out = execSync('ductape --version', {
|
|
1177
1180
|
encoding: 'utf8',
|
|
1178
|
-
timeout:
|
|
1181
|
+
timeout: 15000,
|
|
1179
1182
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
1180
1183
|
env: cliEnvironment(),
|
|
1181
1184
|
cwd: cliCwd(),
|
|
1182
1185
|
}).trim();
|
|
1183
1186
|
return { available: true, version: out || 'unknown' };
|
|
1184
1187
|
}
|
|
1185
|
-
catch {
|
|
1186
|
-
|
|
1188
|
+
catch (error) {
|
|
1189
|
+
const message = String(error?.stderr || error?.message || error);
|
|
1190
|
+
const commandMissing = error?.code === 'ENOENT' ||
|
|
1191
|
+
error?.status === 127 ||
|
|
1192
|
+
/\b(command not found|not recognized as an internal|no such file or directory)\b/i.test(message);
|
|
1193
|
+
return { available: !commandMissing };
|
|
1187
1194
|
}
|
|
1188
1195
|
}
|
|
1189
1196
|
function checkLoginState() {
|
|
@@ -1298,6 +1305,18 @@ function runCli(command) {
|
|
|
1298
1305
|
function cliEnvironment() {
|
|
1299
1306
|
const environment = { ...process.env };
|
|
1300
1307
|
delete environment.DUCTAPE_ACCESS_KEY;
|
|
1308
|
+
const pathKey = Object.keys(environment).find((key) => key.toLowerCase() === 'path') ?? 'PATH';
|
|
1309
|
+
const configuredPath = environment[pathKey] ?? '';
|
|
1310
|
+
const fallbackBins = [
|
|
1311
|
+
join(homedir(), '.npm-global', 'bin'),
|
|
1312
|
+
join(homedir(), '.local', 'bin'),
|
|
1313
|
+
'/opt/homebrew/bin',
|
|
1314
|
+
'/usr/local/bin',
|
|
1315
|
+
];
|
|
1316
|
+
environment[pathKey] = [...new Set([
|
|
1317
|
+
...configuredPath.split(delimiter).filter(Boolean),
|
|
1318
|
+
...fallbackBins,
|
|
1319
|
+
])].join(delimiter);
|
|
1301
1320
|
return environment;
|
|
1302
1321
|
}
|
|
1303
1322
|
/**
|
|
@@ -2788,10 +2807,13 @@ Resilience covers three mechanisms: quotas (rate-limited provider pools), fallba
|
|
|
2788
2807
|
provider switching), and healthchecks (continuous probe monitoring with failure actions).
|
|
2789
2808
|
|
|
2790
2809
|
CONFIGURATION BOUNDARY
|
|
2791
|
-
Quotas, fallbacks, and health checks are administrative product configuration.
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2810
|
+
Quotas, fallbacks, and health checks are administrative product configuration. Manage them with
|
|
2811
|
+
the authenticated CLI:
|
|
2812
|
+
ductape_cli("resources quota ...")
|
|
2813
|
+
ductape_cli("resources fallback ...")
|
|
2814
|
+
ductape_cli("resources health ...")
|
|
2815
|
+
Workbench is also supported. Never route their administrative create/update methods through
|
|
2816
|
+
ductape_execute: its publishable-key runtime proxy will fail.
|
|
2795
2817
|
|
|
2796
2818
|
QUOTAS — rate-limited multi-provider pools:
|
|
2797
2819
|
Workbench definition shape:
|
|
@@ -2822,6 +2844,13 @@ FALLBACKS — automatic provider switching on failure:
|
|
|
2822
2844
|
fallback.dispatch [{ product, env, tag, input, schedule? }]
|
|
2823
2845
|
|
|
2824
2846
|
HEALTHCHECKS — continuous probe with failure notifications:
|
|
2847
|
+
Scheduled probes have a platform-owned fallback runner in the Ductape proxy. A local SDK monitor
|
|
2848
|
+
may also run them: while it consistently persists a fresh lastChecked record, the proxy defers
|
|
2849
|
+
that product/env/check. The proxy freshness window accounts for the SDK's batched backend status
|
|
2850
|
+
flush (currently five minutes), not only the shorter probe interval. If records stop arriving and
|
|
2851
|
+
the freshness window expires, the proxy automatically takes over. Do not instruct users to
|
|
2852
|
+
disable the proxy fallback when using a local monitor.
|
|
2853
|
+
|
|
2825
2854
|
Workbench definition shape:
|
|
2826
2855
|
{
|
|
2827
2856
|
tag: "payment-health",
|
|
@@ -2829,7 +2858,7 @@ HEALTHCHECKS — continuous probe with failure notifications:
|
|
|
2829
2858
|
probe: { type: "app", app: "stripe-app", event: "ping" },
|
|
2830
2859
|
interval: 30000, // ms between checks
|
|
2831
2860
|
retries: 3,
|
|
2832
|
-
envs: [{ slug: "prd", input: {} }],
|
|
2861
|
+
envs: [{ slug: "prd", input: { path: "/health" } }],
|
|
2833
2862
|
onFailure: {
|
|
2834
2863
|
notifications: [{ notification: "ops-alerts", message: "payment-down",
|
|
2835
2864
|
channels: { email: { recipients: ["ops@example.com"] } } }],
|
|
@@ -2840,8 +2869,37 @@ HEALTHCHECKS — continuous probe with failure notifications:
|
|
|
2840
2869
|
health.check [{ product, env, tag }] → same as run
|
|
2841
2870
|
health.status [{ product, env, tag }] → current health status
|
|
2842
2871
|
|
|
2843
|
-
Probe types: app | database | feature | graph |
|
|
2844
|
-
|
|
2872
|
+
Probe types: app | database | feature | graph | events | storage
|
|
2873
|
+
Canonical Events probe:
|
|
2874
|
+
{ type: "events", events: "statecraft-events", event: "health" }
|
|
2875
|
+
Do not create new probes with type/field message_broker or messageBroker; those names are deprecated
|
|
2876
|
+
compatibility aliases.
|
|
2877
|
+
|
|
2878
|
+
APP HEALTHCHECK SETUP — REQUIRED DISCOVERY AND VALIDATION
|
|
2879
|
+
An app healthcheck is not a generic URL ping. It invokes one action belonging to an app already
|
|
2880
|
+
connected to the product. Before creating it:
|
|
2881
|
+
1. Read the product's connected apps with:
|
|
2882
|
+
ductape_cli("products components get --product-tag <product> --type apps --json")
|
|
2883
|
+
2. Select a connected app by its product access tag. Never invent or use an unconnected app tag.
|
|
2884
|
+
3. Inspect that connected app's available actions/schema using the app/schema tools. Select an
|
|
2885
|
+
existing action intended to be safe for repeated health probes.
|
|
2886
|
+
4. Build a payload matching that action's required input schema for every selected product
|
|
2887
|
+
environment. Payloads belong in envs[].input and may differ by environment.
|
|
2888
|
+
5. Create the resource with:
|
|
2889
|
+
ductape_cli("resources health create --tag <product> -f <healthcheck.json> --json")
|
|
2890
|
+
6. Fetch the created healthcheck and verify probe.app, probe.event, and every env payload target;
|
|
2891
|
+
then run one immediate check and inspect status before relying on the schedule.
|
|
2892
|
+
|
|
2893
|
+
Required app probe shape:
|
|
2894
|
+
{
|
|
2895
|
+
probe: { type: "app", app: "<connected-app-access-tag>", event: "<existing-action-tag>" },
|
|
2896
|
+
envs: [{ slug: "<product-env>", input: { ...actionPayload } }]
|
|
2897
|
+
}
|
|
2898
|
+
Do not create an app healthcheck when the app, action, or required payload cannot be verified.
|
|
2899
|
+
The platform must reject missing/unconnected apps, unknown actions, and invalid action payloads;
|
|
2900
|
+
never interpret a successful create response alone as proof that the probe is runnable.
|
|
2901
|
+
|
|
2902
|
+
Failure actions: notification channels, HTTP webhooks, and/or Events emit — all can
|
|
2845
2903
|
be configured simultaneously on the same healthcheck.
|
|
2846
2904
|
Input template references: $Input{field} → maps declared input to the probe's action input.
|
|
2847
2905
|
Provider status: available | unavailable
|
|
@@ -4332,8 +4390,9 @@ const cliInputSchema = z.object({
|
|
|
4332
4390
|
'resources (databases, storage, caches…), event broker topics, cloud connections, secrets, ' +
|
|
4333
4391
|
'and for apply/migrate workflows.\n\n' +
|
|
4334
4392
|
'Note: environments have their own CLI commands (products environments list/get/create/update, ' +
|
|
4335
|
-
'no linked project required — the product tag is always an explicit argument).
|
|
4336
|
-
'
|
|
4393
|
+
'no linked project required — the product tag is always an explicit argument). Quotas, ' +
|
|
4394
|
+
'fallbacks, jobs, and healthchecks use resources commands. App actions and auths are ' +
|
|
4395
|
+
'configured in the Workbench UI. Features have no CLI ' +
|
|
4337
4396
|
'creation command: define them in application code with features.define so application ' +
|
|
4338
4397
|
'boot/runtime registration makes them available.\n\n' +
|
|
4339
4398
|
'The CLI uses the user\'s local logged-in session (ductape login) — no key is required.'),
|
|
@@ -4788,13 +4847,14 @@ async function main() {
|
|
|
4788
4847
|
' After importing, create topics first with ductape_cli("events topics create -f topic.json") — SQS requires explicit topic creation with queueUrls. For other providers, topics auto-register on first produce but should still be created explicitly before any consumer subscribes.\n' +
|
|
4789
4848
|
' - Listing workspaces, products, focused product components, secrets\n' +
|
|
4790
4849
|
' Prefer "products components list --product-tag <tag> --json" for compact inventory; use\n' +
|
|
4791
|
-
' "products components get --product-tag <tag> --type notifications|events --json" for focused detail.\n' +
|
|
4850
|
+
' "products components get --product-tag <tag> --type notifications|events|healthchecks|features --json" for focused detail.\n' +
|
|
4792
4851
|
' - Managing notification components and message templates through "resources notifications" and "notifications messages"\n' +
|
|
4793
4852
|
' - Linking a project folder: "link --product <tag> --env <slug>"\n' +
|
|
4794
4853
|
' - Syncing sessions/notifications/events: "apply" or "apply sessions" etc.\n' +
|
|
4795
4854
|
' - Running database migrations: "db migrate", "db schema generate"\n\n' +
|
|
4796
|
-
'NOTE: Environments have their own CLI commands (products environments *). App actions
|
|
4797
|
-
'
|
|
4855
|
+
'NOTE: Environments have their own CLI commands (products environments *). App actions ' +
|
|
4856
|
+
'and auths are configured in the Workbench UI. Quotas, fallbacks, jobs, and healthchecks ' +
|
|
4857
|
+
'are managed with resources commands. Features have no ' +
|
|
4798
4858
|
'CLI creation command because definitions are code-first through features.define and ' +
|
|
4799
4859
|
'registered by the application runtime.\n\n' +
|
|
4800
4860
|
'DO NOT use ductape_execute for admin operations — it uses a publishable key which only ' +
|