@mcpjam/cli 3.20.0 → 3.21.0
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 +284 -45
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
import { Command, CommanderError } from 'commander';
|
|
3
3
|
import { realpathSync, mkdirSync, writeFileSync, readFileSync, existsSync, statSync, closeSync, renameSync, openSync } from 'fs';
|
|
4
4
|
import { pathToFileURL } from 'url';
|
|
5
|
-
import { probeMcpServer,
|
|
5
|
+
import { probeMcpServer, redactForTelemetry, runServerDoctor, collectServerSnapshot, serializeStableServerSnapshot, serializeServerSnapshot, buildServerDiffReport, classifyMcpHeader, validateToolCallResult, isCallToolResultError, buildToolCallValidationReport, listResources, readResource, SubscriptionCoordinator, listTools, listPrompts, getPrompt, MCPAppsConformanceTest, scoreFromAppsResult, MCPAppsConformanceSuite, MCPTasksConformanceTest, scoreFromTasksResult, runOAuthLogin, OAuthConformanceTest, scoreFromOAuthResult, OAuthConformanceSuite, runXaaFlow, MCPConformanceTest, scoreFromProtocolResult, MCPConformanceSuite, openUrlInBrowser, withEphemeralClient, diffServerSnapshots, ServerSnapshotFormatError, renderStructuredRunJUnitXml, renderStructuredRunJson, DEFAULT_SUBSCRIPTION_RECONNECT_POLICY, isKnownProtocolVersion, describeConformanceScore, toConformanceReport, renderConformanceReportJUnitXml, renderConformanceReportJson, formatOAuthConformanceHuman, formatOAuthConformanceSuiteHuman, fetchOAuthMetadata, executeOAuthProxy, executeDebugOAuthProxy, normalizeRegistrationStrategy, normalizeXaaClientAuth, normalizeIdentityAssertionFormat, IDENTITY_ASSERTION_FORMATS, XAA_CONFIDENTIAL_CIMD_ORIGIN, getLocalConfidentialCimdProvider, MCP_PROTOCOL_VERSIONS, generateRandomString, generateCodeChallenge, createInteractiveAuthorizationSession, MCPClientManager, decodeMcpHeaderValue, canDeclareTasksExtension, createStrictElicitationContentValidator, MCP_APPS_CHECK_CATEGORIES, MCP_APPS_CHECK_IDS, MCP_TASKS_CHECK_CATEGORIES, MCP_TASKS_CHECK_IDS, OAuthProxyError, isLoopbackHost, MCP_CHECK_CATEGORIES, MCP_CHECK_IDS, TaskLifecycleEngine, driveTaskToTerminal, extensionTaskToObservation, legacyTaskToObservation, isUnknownTaskError, isMCPTasksWireError, LEGACY_TASK_STATUSES } from '@mcpjam/sdk';
|
|
6
6
|
import { mkdir, writeFile, readFile, chmod, rename, rm } from 'fs/promises';
|
|
7
7
|
import path2, { dirname, join, basename } from 'path';
|
|
8
8
|
import { randomUUID } from 'crypto';
|
|
9
9
|
import { spawn } from 'child_process';
|
|
10
10
|
import { createRequire } from 'module';
|
|
11
11
|
import os, { homedir } from 'os';
|
|
12
|
-
import { createProjectOperation, updateProjectOperation, deleteProjectOperation, listEvalSuiteRunsOperation, cancelEvalRunOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, setEvalSuiteEnvironmentsOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, listChatboxesOperation, getChatboxOperation, listChatSessionsOperation, createHostOperation, updateHostOperation, setHostServersOperation, duplicateHostOperation, createEnvironmentOperation, updateEnvironmentOperation, createImageOperation, validateImageBlueprintOperation, updateImageOperation, createTunnelOperation, DEFAULT_PLATFORM_API_BASE_URL, PlatformApiClient, isPlatformApiError, PlatformApiError, listProjectsOperation, listProjectServersOperation, createProjectServerOperation, getProjectServerOperation, updateProjectServerOperation, deleteProjectServerOperation, showServersOperation, createEvalSuiteOperation, listEvalSuitesOperation, runEvalSuiteOperation, getEvalRunOperation, listHostsOperation, getHostOperation, deleteHostOperation, listEnvironmentsOperation, getEnvironmentOperation, resolveEnvironmentOperation, archiveEnvironmentOperation, restoreEnvironmentOperation, listJourneysOperation, listJourneyRunsOperation, getJourneyRunOperation, launchJourneyRunOperation, cancelJourneyRunOperation, listJourneyRunSessionsOperation, publishScenarioOperation, unpublishScenarioOperation, listImagesOperation, getImageOperation, buildImageOperation, listImageBuildsOperation, useImageOperation, resetComputerOperation, promoteImageOperation, deleteImageOperation } from '@mcpjam/sdk/platform';
|
|
12
|
+
import { createProjectOperation, updateProjectOperation, deleteProjectOperation, connectProjectServerOperation, getProjectServerConnectionStatusOperation, listEvalSuiteRunsOperation, cancelEvalRunOperation, listEvalRunIterationsOperation, getEvalIterationTraceOperation, getEvalRunStepsOperation, getEvalSuiteOperation, updateEvalSuiteOperation, deleteEvalSuiteOperation, setEvalSuiteScheduleOperation, setEvalSuiteEnvironmentsOperation, listEvalCasesOperation, getEvalCaseOperation, runEvalCaseOperation, createEvalCaseOperation, updateEvalCaseOperation, deleteEvalCaseOperation, generateEvalCasesOperation, listChatboxesOperation, getChatboxOperation, listChatSessionsOperation, createHostOperation, updateHostOperation, setHostServersOperation, duplicateHostOperation, createEnvironmentOperation, updateEnvironmentOperation, createImageOperation, validateImageBlueprintOperation, updateImageOperation, createTunnelOperation, DEFAULT_PLATFORM_API_BASE_URL, PlatformApiClient, isPlatformApiError, PlatformApiError, listProjectsOperation, listProjectServersOperation, createProjectServerOperation, getProjectServerOperation, updateProjectServerOperation, deleteProjectServerOperation, showServersOperation, createEvalSuiteOperation, listEvalSuitesOperation, runEvalSuiteOperation, getEvalRunOperation, listHostsOperation, getHostOperation, deleteHostOperation, listEnvironmentsOperation, getEnvironmentOperation, resolveEnvironmentOperation, getEnvironmentCapabilitiesOperation, archiveEnvironmentOperation, restoreEnvironmentOperation, listJourneysOperation, listJourneyRunsOperation, getJourneyRunOperation, launchJourneyRunOperation, cancelJourneyRunOperation, listJourneyRunSessionsOperation, publishScenarioOperation, unpublishScenarioOperation, listImagesOperation, getImageOperation, buildImageOperation, listImageBuildsOperation, useImageOperation, resetComputerOperation, promoteImageOperation, deleteImageOperation } from '@mcpjam/sdk/platform';
|
|
13
13
|
import { buildHostProfilesFromCatalog, buildMarketHostProfiles, scanWidgetUsage, evaluateMarketHosts, fetchHostCompatCatalog } from '@mcpjam/sdk/host-compat';
|
|
14
14
|
import { HOST_TEMPLATES as HOST_TEMPLATES$1, HOST_TEMPLATE_IDS, seedHostTemplate } from '@mcpjam/sdk/host-config/templates';
|
|
15
15
|
import { applyVisibilityPolicyAndCountSignals, isAppOnlyTool, extractHostExecutionPolicy, hostConnectionProfile } from '@mcpjam/sdk/host-config/internal';
|
|
@@ -25,7 +25,7 @@ import { WebSocket } from 'ws';
|
|
|
25
25
|
|
|
26
26
|
// package.json
|
|
27
27
|
var package_default = {
|
|
28
|
-
version: "3.
|
|
28
|
+
version: "3.21.0"};
|
|
29
29
|
function conformanceExitCode(result) {
|
|
30
30
|
if (result.outcome === "incomplete") return 3;
|
|
31
31
|
if (result.outcome === "failed") return 1;
|
|
@@ -532,7 +532,7 @@ function getCliRpcLogEvents(collectors) {
|
|
|
532
532
|
function redactCliRpcLogs(logs) {
|
|
533
533
|
return logs.map((event) => ({
|
|
534
534
|
...event,
|
|
535
|
-
message:
|
|
535
|
+
message: redactForTelemetry(event.message)
|
|
536
536
|
}));
|
|
537
537
|
}
|
|
538
538
|
|
|
@@ -642,7 +642,7 @@ function assertNoCredentialsFileAuthConflicts(options) {
|
|
|
642
642
|
);
|
|
643
643
|
}
|
|
644
644
|
function redactCredentialsFromResult(result, credentialsFilePath) {
|
|
645
|
-
const redacted =
|
|
645
|
+
const redacted = redactForTelemetry(result);
|
|
646
646
|
const credentials = result.credentials ?? {};
|
|
647
647
|
const hasCredentials = Object.keys(credentials).length > 0;
|
|
648
648
|
const secretMarker = credentialsFilePath ? "[SAVED_TO_FILE]" : "[REDACTED]";
|
|
@@ -2259,7 +2259,7 @@ function buildDebugArtifactEnvelope(options) {
|
|
|
2259
2259
|
if (rpcLogs.length > 0) {
|
|
2260
2260
|
payload._rpcLogs = rpcLogs;
|
|
2261
2261
|
}
|
|
2262
|
-
return
|
|
2262
|
+
return redactForTelemetry(payload);
|
|
2263
2263
|
}
|
|
2264
2264
|
function buildCommandArtifactError(code, message, details) {
|
|
2265
2265
|
return {
|
|
@@ -2282,7 +2282,7 @@ async function writeBinaryArtifact(outputPath, data) {
|
|
|
2282
2282
|
}
|
|
2283
2283
|
async function writeDebugArtifact(outputPath, payload) {
|
|
2284
2284
|
const resolvedPath = path2.resolve(process.cwd(), outputPath);
|
|
2285
|
-
const redactedPayload =
|
|
2285
|
+
const redactedPayload = redactForTelemetry(payload);
|
|
2286
2286
|
try {
|
|
2287
2287
|
await mkdir(path2.dirname(resolvedPath), { recursive: true });
|
|
2288
2288
|
await writeFile(
|
|
@@ -4641,6 +4641,27 @@ function validateInput2(op, raw) {
|
|
|
4641
4641
|
}
|
|
4642
4642
|
return parsed.data;
|
|
4643
4643
|
}
|
|
4644
|
+
async function assertModelOverridesSupported(options, timeoutMs, args) {
|
|
4645
|
+
if (!args.supplied) return;
|
|
4646
|
+
const result = await runPlatformCommand3(
|
|
4647
|
+
options,
|
|
4648
|
+
timeoutMs,
|
|
4649
|
+
({ client, signal }) => getEnvironmentCapabilitiesOperation.execute(
|
|
4650
|
+
{ project: args.project },
|
|
4651
|
+
{ client, signal }
|
|
4652
|
+
)
|
|
4653
|
+
);
|
|
4654
|
+
const supported = result.capabilities.modelOverrides;
|
|
4655
|
+
if (!supported) {
|
|
4656
|
+
throw usageError(
|
|
4657
|
+
'This MCPJam deployment does not support environment model overrides. Upgrade the platform, or omit --model / --clear-model / "modelId".'
|
|
4658
|
+
);
|
|
4659
|
+
}
|
|
4660
|
+
}
|
|
4661
|
+
function projectSelector(options, body) {
|
|
4662
|
+
if (options.project !== void 0) return { project: options.project };
|
|
4663
|
+
return typeof body.project === "string" && body.project.trim() ? { project: body.project } : {};
|
|
4664
|
+
}
|
|
4644
4665
|
function loadJsonObject(options) {
|
|
4645
4666
|
if (options.file !== void 0 && options.json !== void 0) {
|
|
4646
4667
|
throw usageError("Provide either --file or --json, not both.");
|
|
@@ -4751,22 +4772,30 @@ function registerEnvironmentsCommands(program) {
|
|
|
4751
4772
|
environments.command("create").description(
|
|
4752
4773
|
"Create a project environment (requires project admin). Body fields may be supplied via --file/--json"
|
|
4753
4774
|
).option("--project <id-or-name>", "Project name or ID").option("--name <name>", "Display name for the new environment").option("--host-id <id>", "ID of the host this environment runs against").option("--description <text>", "Optional description").option(
|
|
4775
|
+
"--model <id>",
|
|
4776
|
+
"Model this environment runs, overriding the model pinned on its host. Omit to inherit the host's. Stored verbatim \u2014 pass exactly the id the provider request should carry"
|
|
4777
|
+
).option(
|
|
4754
4778
|
"--sandbox-image <id>",
|
|
4755
4779
|
"Project-shared sandbox image (see `mcpjam images`) to pin: eval runs boot a fresh sandbox from it"
|
|
4756
4780
|
).option(
|
|
4757
4781
|
"--file <path>",
|
|
4758
|
-
"Environment JSON file with any of name/hostId/description/serverAttachmentId/skillSelection/pluginVersionIds/sandboxImageId (or - for stdin)"
|
|
4782
|
+
"Environment JSON file with any of name/hostId/description/serverAttachmentId/modelId/skillSelection/pluginVersionIds/sandboxImageId (or - for stdin)"
|
|
4759
4783
|
).option("--json <json>", "Inline environment JSON (or @file, or -)")
|
|
4760
4784
|
).action(
|
|
4761
4785
|
async (options, command) => {
|
|
4762
4786
|
const globalOptions = getGlobalOptions(command);
|
|
4763
4787
|
const body = loadJsonObject(options) ?? {};
|
|
4788
|
+
await assertModelOverridesSupported(options, globalOptions.timeout, {
|
|
4789
|
+
supplied: options.model !== void 0 || "modelId" in body,
|
|
4790
|
+
...projectSelector(options, body)
|
|
4791
|
+
});
|
|
4764
4792
|
const input = validateInput2(createEnvironmentOperation, {
|
|
4765
4793
|
...body,
|
|
4766
4794
|
...options.project !== void 0 ? { project: options.project } : {},
|
|
4767
4795
|
...options.name !== void 0 ? { name: options.name } : {},
|
|
4768
4796
|
...options.hostId !== void 0 ? { hostId: options.hostId } : {},
|
|
4769
4797
|
...options.description !== void 0 ? { description: options.description } : {},
|
|
4798
|
+
...options.model !== void 0 ? { modelId: options.model } : {},
|
|
4770
4799
|
...options.sandboxImage !== void 0 ? { sandboxImageId: options.sandboxImage } : {}
|
|
4771
4800
|
});
|
|
4772
4801
|
const result = await runPlatformCommand3(
|
|
@@ -4779,13 +4808,19 @@ function registerEnvironmentsCommands(program) {
|
|
|
4779
4808
|
);
|
|
4780
4809
|
addPlatformOptions3(
|
|
4781
4810
|
environments.command("update").description(
|
|
4782
|
-
"Edit an environment. Only the fields you pass change; use --file/--json with a null value to clear serverAttachmentId, skillSelection, pluginVersionIds, or sandboxImageId"
|
|
4811
|
+
"Edit an environment. Only the fields you pass change; use --clear-model, or --file/--json with a null value, to clear serverAttachmentId, modelId, skillSelection, pluginVersionIds, or sandboxImageId"
|
|
4783
4812
|
).requiredOption("--environment <id-or-name>", "Environment name or ID").requiredOption(
|
|
4784
4813
|
"--expected-revision <n>",
|
|
4785
4814
|
"The revision you last read (from `environments get`); a stale value is rejected instead of overwriting a concurrent edit"
|
|
4786
4815
|
).option("--project <id-or-name>", "Project name or ID").option("--name <name>", "New display name").option("--host-id <id>", "New host for this environment").option(
|
|
4787
4816
|
"--description <text>",
|
|
4788
4817
|
"New description (empty string clears it)"
|
|
4818
|
+
).option(
|
|
4819
|
+
"--model <id>",
|
|
4820
|
+
"New model override, replacing the host's pinned model"
|
|
4821
|
+
).option(
|
|
4822
|
+
"--clear-model",
|
|
4823
|
+
"Clear the model override so the environment inherits its host's model again"
|
|
4789
4824
|
).option(
|
|
4790
4825
|
"--sandbox-image <id>",
|
|
4791
4826
|
`New sandbox-image pin (clear via --json '{"sandboxImageId": null}')`
|
|
@@ -4797,6 +4832,13 @@ function registerEnvironmentsCommands(program) {
|
|
|
4797
4832
|
async (options, command) => {
|
|
4798
4833
|
const globalOptions = getGlobalOptions(command);
|
|
4799
4834
|
const body = loadJsonObject(options) ?? {};
|
|
4835
|
+
if (options.model !== void 0 && options.clearModel) {
|
|
4836
|
+
throw usageError("Provide either --model or --clear-model, not both.");
|
|
4837
|
+
}
|
|
4838
|
+
await assertModelOverridesSupported(options, globalOptions.timeout, {
|
|
4839
|
+
supplied: options.model !== void 0 || options.clearModel === true || "modelId" in body,
|
|
4840
|
+
...projectSelector(options, body)
|
|
4841
|
+
});
|
|
4800
4842
|
const input = validateInput2(updateEnvironmentOperation, {
|
|
4801
4843
|
...body,
|
|
4802
4844
|
...options.project !== void 0 ? { project: options.project } : {},
|
|
@@ -4805,6 +4847,10 @@ function registerEnvironmentsCommands(program) {
|
|
|
4805
4847
|
...options.name !== void 0 ? { name: options.name } : {},
|
|
4806
4848
|
...options.hostId !== void 0 ? { hostId: options.hostId } : {},
|
|
4807
4849
|
...options.description !== void 0 ? { description: options.description } : {},
|
|
4850
|
+
// `--clear-model` is the flag spelling of the JSON `"modelId": null`
|
|
4851
|
+
// both this command and the API already accept; neither is removed.
|
|
4852
|
+
...options.clearModel ? { modelId: null } : {},
|
|
4853
|
+
...options.model !== void 0 ? { modelId: options.model } : {},
|
|
4808
4854
|
...options.sandboxImage !== void 0 ? { sandboxImageId: options.sandboxImage } : {}
|
|
4809
4855
|
});
|
|
4810
4856
|
const result = await runPlatformCommand3(
|
|
@@ -6905,7 +6951,7 @@ function createMcpJamMcpServer(options) {
|
|
|
6905
6951
|
target: summarizeServerDoctorTarget(target, config),
|
|
6906
6952
|
timeout: input.timeoutMs ?? defaultTimeoutMs
|
|
6907
6953
|
});
|
|
6908
|
-
return
|
|
6954
|
+
return redactForTelemetry(result);
|
|
6909
6955
|
})
|
|
6910
6956
|
);
|
|
6911
6957
|
server.registerTool(
|
|
@@ -6929,7 +6975,7 @@ function createMcpJamMcpServer(options) {
|
|
|
6929
6975
|
headers,
|
|
6930
6976
|
timeoutMs: timeoutMs ?? defaultTimeoutMs
|
|
6931
6977
|
});
|
|
6932
|
-
return
|
|
6978
|
+
return redactForTelemetry(result);
|
|
6933
6979
|
})
|
|
6934
6980
|
);
|
|
6935
6981
|
let closed = false;
|
|
@@ -7085,15 +7131,33 @@ function statusGlyph(status) {
|
|
|
7085
7131
|
return "!";
|
|
7086
7132
|
}
|
|
7087
7133
|
}
|
|
7088
|
-
|
|
7089
|
-
// src/commands/projects.ts
|
|
7090
7134
|
function addPlatformOptions8(command) {
|
|
7091
7135
|
return command.option("--api-key <key>", "MCPJam sk_ API key (overrides MCPJAM_API_KEY)").option(
|
|
7092
7136
|
"--api-url <url>",
|
|
7093
7137
|
"MCPJam API base URL (defaults to https://app.mcpjam.com/api/v1)"
|
|
7094
7138
|
);
|
|
7095
7139
|
}
|
|
7096
|
-
|
|
7140
|
+
function platformOptionsOf(command) {
|
|
7141
|
+
const nearestFirst = [];
|
|
7142
|
+
for (let current = command; current !== null; current = current.parent) {
|
|
7143
|
+
nearestFirst.push(current);
|
|
7144
|
+
}
|
|
7145
|
+
const merged = {};
|
|
7146
|
+
for (const cmd of nearestFirst.reverse()) {
|
|
7147
|
+
for (const [key, value] of Object.entries(cmd.opts())) {
|
|
7148
|
+
if (value !== void 0) merged[key] = value;
|
|
7149
|
+
}
|
|
7150
|
+
}
|
|
7151
|
+
return merged;
|
|
7152
|
+
}
|
|
7153
|
+
function requireProject(command, options) {
|
|
7154
|
+
const project = options.project?.trim();
|
|
7155
|
+
if (!project) {
|
|
7156
|
+
command.error("error: required option '--project <id-or-name>' not specified");
|
|
7157
|
+
}
|
|
7158
|
+
return project;
|
|
7159
|
+
}
|
|
7160
|
+
async function runPlatformCommand8(options, timeoutMs, execute, externalSignal) {
|
|
7097
7161
|
const controller = new AbortController();
|
|
7098
7162
|
const timeoutHandle = setTimeout(() => {
|
|
7099
7163
|
controller.abort(
|
|
@@ -7107,6 +7171,9 @@ async function runPlatformCommand8(options, timeoutMs, execute) {
|
|
|
7107
7171
|
);
|
|
7108
7172
|
}, timeoutMs);
|
|
7109
7173
|
timeoutHandle.unref?.();
|
|
7174
|
+
const onExternalAbort = () => controller.abort(externalSignal?.reason);
|
|
7175
|
+
if (externalSignal?.aborted) onExternalAbort();
|
|
7176
|
+
else externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
|
|
7110
7177
|
try {
|
|
7111
7178
|
const { client } = buildPlatformClient({ ...options, timeoutMs });
|
|
7112
7179
|
return await execute({ client, signal: controller.signal });
|
|
@@ -7117,6 +7184,7 @@ async function runPlatformCommand8(options, timeoutMs, execute) {
|
|
|
7117
7184
|
throw toCliError(error);
|
|
7118
7185
|
} finally {
|
|
7119
7186
|
clearTimeout(timeoutHandle);
|
|
7187
|
+
externalSignal?.removeEventListener("abort", onExternalAbort);
|
|
7120
7188
|
}
|
|
7121
7189
|
}
|
|
7122
7190
|
function registerProjectsCommands(program) {
|
|
@@ -7125,10 +7193,10 @@ function registerProjectsCommands(program) {
|
|
|
7125
7193
|
);
|
|
7126
7194
|
addPlatformOptions8(
|
|
7127
7195
|
projects.command("list").description("List the projects you can access")
|
|
7128
|
-
).action(async (
|
|
7196
|
+
).action(async (_options, command) => {
|
|
7129
7197
|
const globalOptions = getGlobalOptions(command);
|
|
7130
7198
|
const result = await runPlatformCommand8(
|
|
7131
|
-
|
|
7199
|
+
platformOptionsOf(command),
|
|
7132
7200
|
globalOptions.timeout,
|
|
7133
7201
|
({ client, signal }) => listProjectsOperation.execute({}, { client, signal })
|
|
7134
7202
|
);
|
|
@@ -7151,7 +7219,7 @@ function registerProjectsCommands(program) {
|
|
|
7151
7219
|
...options.visibility === void 0 ? {} : { visibility: options.visibility }
|
|
7152
7220
|
});
|
|
7153
7221
|
const result = await runPlatformCommand8(
|
|
7154
|
-
|
|
7222
|
+
platformOptionsOf(command),
|
|
7155
7223
|
globalOptions.timeout,
|
|
7156
7224
|
({ client, signal }) => createProjectOperation.execute(input, { client, signal })
|
|
7157
7225
|
);
|
|
@@ -7163,14 +7231,15 @@ function registerProjectsCommands(program) {
|
|
|
7163
7231
|
).action(
|
|
7164
7232
|
async (options, command) => {
|
|
7165
7233
|
const globalOptions = getGlobalOptions(command);
|
|
7234
|
+
const platformOptions = platformOptionsOf(command);
|
|
7166
7235
|
const input = updateProjectOperation.inputSchema.parse({
|
|
7167
|
-
project:
|
|
7236
|
+
project: requireProject(command, platformOptions),
|
|
7168
7237
|
...options.name === void 0 ? {} : { name: options.name },
|
|
7169
7238
|
...options.description === void 0 ? {} : { description: options.description },
|
|
7170
7239
|
...options.visibility === void 0 ? {} : { visibility: options.visibility }
|
|
7171
7240
|
});
|
|
7172
7241
|
const result = await runPlatformCommand8(
|
|
7173
|
-
|
|
7242
|
+
platformOptions,
|
|
7174
7243
|
globalOptions.timeout,
|
|
7175
7244
|
({ client, signal }) => updateProjectOperation.execute(input, { client, signal })
|
|
7176
7245
|
);
|
|
@@ -7179,13 +7248,14 @@ function registerProjectsCommands(program) {
|
|
|
7179
7248
|
);
|
|
7180
7249
|
addPlatformOptions8(
|
|
7181
7250
|
projects.command("delete").description("Delete a project and its project-owned resources").requiredOption("--project <id-or-name>", "Project name or ID")
|
|
7182
|
-
).action(async (
|
|
7251
|
+
).action(async (_options, command) => {
|
|
7183
7252
|
const globalOptions = getGlobalOptions(command);
|
|
7253
|
+
const platformOptions = platformOptionsOf(command);
|
|
7184
7254
|
const input = deleteProjectOperation.inputSchema.parse({
|
|
7185
|
-
project:
|
|
7255
|
+
project: requireProject(command, platformOptions)
|
|
7186
7256
|
});
|
|
7187
7257
|
const result = await runPlatformCommand8(
|
|
7188
|
-
|
|
7258
|
+
platformOptions,
|
|
7189
7259
|
globalOptions.timeout,
|
|
7190
7260
|
({ client, signal }) => deleteProjectOperation.execute(input, { client, signal })
|
|
7191
7261
|
);
|
|
@@ -7197,13 +7267,14 @@ function registerProjectsCommands(program) {
|
|
|
7197
7267
|
"--project <id-or-name>",
|
|
7198
7268
|
"Project name or ID (defaults to the most recently updated project)"
|
|
7199
7269
|
);
|
|
7200
|
-
servers.action(async (
|
|
7270
|
+
servers.action(async (_options, command) => {
|
|
7201
7271
|
const globalOptions = getGlobalOptions(command);
|
|
7272
|
+
const platformOptions = platformOptionsOf(command);
|
|
7202
7273
|
const result = await runPlatformCommand8(
|
|
7203
|
-
|
|
7274
|
+
platformOptions,
|
|
7204
7275
|
globalOptions.timeout,
|
|
7205
7276
|
({ client, signal }) => listProjectServersOperation.execute(
|
|
7206
|
-
{ project:
|
|
7277
|
+
{ project: platformOptions.project },
|
|
7207
7278
|
{ client, signal }
|
|
7208
7279
|
)
|
|
7209
7280
|
);
|
|
@@ -7222,44 +7293,50 @@ function registerProjectsCommands(program) {
|
|
|
7222
7293
|
return parsed;
|
|
7223
7294
|
};
|
|
7224
7295
|
addPlatformOptions8(
|
|
7225
|
-
servers.command("create").alias("add").description("Create a saved MCP server").
|
|
7296
|
+
servers.command("create").alias("add").description("Create a saved MCP server").option("--project <id-or-name>", "Project name or ID").requiredOption("--body <json>", "Server JSON body")
|
|
7226
7297
|
).action(async (options, command) => {
|
|
7227
7298
|
const globalOptions = getGlobalOptions(command);
|
|
7299
|
+
const platformOptions = platformOptionsOf(command);
|
|
7300
|
+
const project = requireProject(command, platformOptions);
|
|
7228
7301
|
const result = await runPlatformCommand8(
|
|
7229
|
-
|
|
7302
|
+
platformOptions,
|
|
7230
7303
|
globalOptions.timeout,
|
|
7231
7304
|
({ client, signal }) => createProjectServerOperation.execute(
|
|
7232
|
-
{ project
|
|
7305
|
+
{ project, body: parseBody(options.body) },
|
|
7233
7306
|
{ client, signal }
|
|
7234
7307
|
)
|
|
7235
7308
|
);
|
|
7236
7309
|
writeResult(result, globalOptions.format);
|
|
7237
7310
|
});
|
|
7238
7311
|
addPlatformOptions8(
|
|
7239
|
-
servers.command("get").description("Get one saved MCP server").
|
|
7312
|
+
servers.command("get").description("Get one saved MCP server").option("--project <id-or-name>", "Project name or ID").requiredOption("--server <id>", "Server ID")
|
|
7240
7313
|
).action(async (options, command) => {
|
|
7241
7314
|
const globalOptions = getGlobalOptions(command);
|
|
7315
|
+
const platformOptions = platformOptionsOf(command);
|
|
7316
|
+
const project = requireProject(command, platformOptions);
|
|
7242
7317
|
const result = await runPlatformCommand8(
|
|
7243
|
-
|
|
7318
|
+
platformOptions,
|
|
7244
7319
|
globalOptions.timeout,
|
|
7245
7320
|
({ client, signal }) => getProjectServerOperation.execute(
|
|
7246
|
-
{ project
|
|
7321
|
+
{ project, serverId: options.server },
|
|
7247
7322
|
{ client, signal }
|
|
7248
7323
|
)
|
|
7249
7324
|
);
|
|
7250
7325
|
writeResult(result, globalOptions.format);
|
|
7251
7326
|
});
|
|
7252
7327
|
addPlatformOptions8(
|
|
7253
|
-
servers.command("update").description("Update one saved MCP server").
|
|
7328
|
+
servers.command("update").description("Update one saved MCP server").option("--project <id-or-name>", "Project name or ID").requiredOption("--server <id>", "Server ID").requiredOption("--body <json>", "Patch JSON body")
|
|
7254
7329
|
).action(
|
|
7255
7330
|
async (options, command) => {
|
|
7256
7331
|
const globalOptions = getGlobalOptions(command);
|
|
7332
|
+
const platformOptions = platformOptionsOf(command);
|
|
7333
|
+
const project = requireProject(command, platformOptions);
|
|
7257
7334
|
const result = await runPlatformCommand8(
|
|
7258
|
-
|
|
7335
|
+
platformOptions,
|
|
7259
7336
|
globalOptions.timeout,
|
|
7260
7337
|
({ client, signal }) => updateProjectServerOperation.execute(
|
|
7261
7338
|
{
|
|
7262
|
-
project
|
|
7339
|
+
project,
|
|
7263
7340
|
serverId: options.server,
|
|
7264
7341
|
body: parseBody(options.body)
|
|
7265
7342
|
},
|
|
@@ -7270,19 +7347,110 @@ function registerProjectsCommands(program) {
|
|
|
7270
7347
|
}
|
|
7271
7348
|
);
|
|
7272
7349
|
addPlatformOptions8(
|
|
7273
|
-
servers.command("delete").alias("remove").description("Delete one saved MCP server").
|
|
7350
|
+
servers.command("delete").alias("remove").description("Delete one saved MCP server").option("--project <id-or-name>", "Project name or ID").requiredOption("--server <id>", "Server ID")
|
|
7274
7351
|
).action(async (options, command) => {
|
|
7275
7352
|
const globalOptions = getGlobalOptions(command);
|
|
7353
|
+
const platformOptions = platformOptionsOf(command);
|
|
7354
|
+
const project = requireProject(command, platformOptions);
|
|
7276
7355
|
const result = await runPlatformCommand8(
|
|
7277
|
-
|
|
7356
|
+
platformOptions,
|
|
7278
7357
|
globalOptions.timeout,
|
|
7279
7358
|
({ client, signal }) => deleteProjectServerOperation.execute(
|
|
7280
|
-
{ project
|
|
7359
|
+
{ project, serverId: options.server },
|
|
7281
7360
|
{ client, signal }
|
|
7282
7361
|
)
|
|
7283
7362
|
);
|
|
7284
7363
|
writeResult(result, globalOptions.format);
|
|
7285
7364
|
});
|
|
7365
|
+
addPlatformOptions8(
|
|
7366
|
+
servers.command("connect").description(
|
|
7367
|
+
"Connect an MCP server URL to a project, authorizing in a browser if needed"
|
|
7368
|
+
).requiredOption("--url <url>", "MCP server URL to connect").option("--project <id-or-name>", "Project name or ID").option(
|
|
7369
|
+
"--server <id>",
|
|
7370
|
+
"Existing server ID, when the project has several on this URL"
|
|
7371
|
+
).option("--name <name>", "Name for the server, if one is created").option("--reauthorize", "Force a fresh authorization").option("--no-browser", "Print the authorization link instead of opening it").option("--no-wait", "Return as soon as the request is created")
|
|
7372
|
+
).action(
|
|
7373
|
+
async (options, command) => {
|
|
7374
|
+
const globalOptions = getGlobalOptions(command);
|
|
7375
|
+
const platformOptions = platformOptionsOf(command);
|
|
7376
|
+
const input = connectProjectServerOperation.inputSchema.parse({
|
|
7377
|
+
url: options.url,
|
|
7378
|
+
// NOT `options.project` — the `servers` group declares `--project` too
|
|
7379
|
+
// and therefore consumes it, so the subcommand's own copy is always
|
|
7380
|
+
// undefined and this command quietly connected to the default project
|
|
7381
|
+
// instead of the one that was named.
|
|
7382
|
+
project: platformOptions.project,
|
|
7383
|
+
serverId: options.server,
|
|
7384
|
+
name: options.name,
|
|
7385
|
+
reauthorize: options.reauthorize
|
|
7386
|
+
});
|
|
7387
|
+
const created = await runPlatformCommand8(
|
|
7388
|
+
platformOptions,
|
|
7389
|
+
globalOptions.timeout,
|
|
7390
|
+
({ client, signal }) => connectProjectServerOperation.execute(input, { client, signal })
|
|
7391
|
+
);
|
|
7392
|
+
if (created.handoffUrl) {
|
|
7393
|
+
process.stderr.write(
|
|
7394
|
+
`Open this link to finish connecting:
|
|
7395
|
+
${created.handoffUrl}
|
|
7396
|
+
`
|
|
7397
|
+
);
|
|
7398
|
+
if (options.browser !== false) {
|
|
7399
|
+
await openUrlInBrowser(created.handoffUrl).catch(() => {
|
|
7400
|
+
process.stderr.write(
|
|
7401
|
+
"Could not open a browser automatically \u2014 open the link above.\n"
|
|
7402
|
+
);
|
|
7403
|
+
});
|
|
7404
|
+
}
|
|
7405
|
+
}
|
|
7406
|
+
if (options.wait === false || isTerminalConnectionStatus(created.status)) {
|
|
7407
|
+
if (options.wait === false && !isTerminalConnectionStatus(created.status)) {
|
|
7408
|
+
process.stderr.write(
|
|
7409
|
+
`Not waiting. Follow it with:
|
|
7410
|
+
mcpjam projects server connect-status --request ${created.connectionRequestId}
|
|
7411
|
+
`
|
|
7412
|
+
);
|
|
7413
|
+
}
|
|
7414
|
+
writeResult(created, globalOptions.format);
|
|
7415
|
+
return;
|
|
7416
|
+
}
|
|
7417
|
+
const settled = await pollConnection(
|
|
7418
|
+
platformOptions,
|
|
7419
|
+
globalOptions.timeout,
|
|
7420
|
+
created.connectionRequestId,
|
|
7421
|
+
created.expiresAt
|
|
7422
|
+
);
|
|
7423
|
+
const latest = settled.result ?? created;
|
|
7424
|
+
writeResult(latest, globalOptions.format);
|
|
7425
|
+
if (settled.gaveUp) {
|
|
7426
|
+
process.stderr.write(
|
|
7427
|
+
`Stopped waiting; the request is still ${latest.status} and continues in the cloud.
|
|
7428
|
+
mcpjam projects server connect-status --request ${created.connectionRequestId}
|
|
7429
|
+
`
|
|
7430
|
+
);
|
|
7431
|
+
process.exitCode = 1;
|
|
7432
|
+
}
|
|
7433
|
+
}
|
|
7434
|
+
);
|
|
7435
|
+
addPlatformOptions8(
|
|
7436
|
+
servers.command("connect-status").description("Check a connection request started by `server connect`").requiredOption("--request <id>", "Connection request id (scr_\u2026)")
|
|
7437
|
+
).action(
|
|
7438
|
+
async (options, command) => {
|
|
7439
|
+
const globalOptions = getGlobalOptions(command);
|
|
7440
|
+
const input = getProjectServerConnectionStatusOperation.inputSchema.parse({
|
|
7441
|
+
connectionRequestId: options.request
|
|
7442
|
+
});
|
|
7443
|
+
const payload = await runPlatformCommand8(
|
|
7444
|
+
platformOptionsOf(command),
|
|
7445
|
+
globalOptions.timeout,
|
|
7446
|
+
({ client, signal }) => getProjectServerConnectionStatusOperation.execute(input, {
|
|
7447
|
+
client,
|
|
7448
|
+
signal
|
|
7449
|
+
})
|
|
7450
|
+
);
|
|
7451
|
+
writeResult(payload, globalOptions.format);
|
|
7452
|
+
}
|
|
7453
|
+
);
|
|
7286
7454
|
addPlatformOptions8(
|
|
7287
7455
|
projects.command("status").description(
|
|
7288
7456
|
"Health-check every server in a project (hosted doctor per server)"
|
|
@@ -7290,13 +7458,14 @@ function registerProjectsCommands(program) {
|
|
|
7290
7458
|
"--project <id-or-name>",
|
|
7291
7459
|
"Project name or ID (defaults to the most recently updated project)"
|
|
7292
7460
|
)
|
|
7293
|
-
).action(async (
|
|
7461
|
+
).action(async (_options, command) => {
|
|
7294
7462
|
const globalOptions = getGlobalOptions(command);
|
|
7463
|
+
const platformOptions = platformOptionsOf(command);
|
|
7295
7464
|
const payload = await runPlatformCommand8(
|
|
7296
|
-
|
|
7465
|
+
platformOptions,
|
|
7297
7466
|
globalOptions.timeout,
|
|
7298
7467
|
({ client, signal }) => showServersOperation.execute(
|
|
7299
|
-
{ project:
|
|
7468
|
+
{ project: platformOptions.project },
|
|
7300
7469
|
{ client, signal }
|
|
7301
7470
|
)
|
|
7302
7471
|
);
|
|
@@ -7308,6 +7477,75 @@ function registerProjectsCommands(program) {
|
|
|
7308
7477
|
}
|
|
7309
7478
|
});
|
|
7310
7479
|
}
|
|
7480
|
+
var TERMINAL_CONNECTION_STATUSES = /* @__PURE__ */ new Set([
|
|
7481
|
+
"ready",
|
|
7482
|
+
"failed",
|
|
7483
|
+
"expired",
|
|
7484
|
+
"cancelled"
|
|
7485
|
+
]);
|
|
7486
|
+
function isTerminalConnectionStatus(status) {
|
|
7487
|
+
return TERMINAL_CONNECTION_STATUSES.has(status);
|
|
7488
|
+
}
|
|
7489
|
+
var FALLBACK_POLL_WINDOW_MS = 60 * 60 * 1e3;
|
|
7490
|
+
async function pollConnection(options, timeoutMs, connectionRequestId, expiresAt) {
|
|
7491
|
+
let delayMs = 2e3;
|
|
7492
|
+
const expiryMs = expiresAt ? Date.parse(expiresAt) : Number.NaN;
|
|
7493
|
+
const deadline = Number.isFinite(expiryMs) ? expiryMs : Date.now() + FALLBACK_POLL_WINDOW_MS;
|
|
7494
|
+
let interrupted = false;
|
|
7495
|
+
let wakeSleep;
|
|
7496
|
+
const interruptController = new AbortController();
|
|
7497
|
+
let lastResult;
|
|
7498
|
+
const onInterrupt = () => {
|
|
7499
|
+
interrupted = true;
|
|
7500
|
+
process.stderr.write(
|
|
7501
|
+
"\nStopped watching. The request continues in the cloud \u2014 open the link above to finish it.\n"
|
|
7502
|
+
);
|
|
7503
|
+
wakeSleep?.();
|
|
7504
|
+
interruptController.abort(new Error("Interrupted by the user."));
|
|
7505
|
+
};
|
|
7506
|
+
process.once("SIGINT", onInterrupt);
|
|
7507
|
+
try {
|
|
7508
|
+
for (; ; ) {
|
|
7509
|
+
let current;
|
|
7510
|
+
try {
|
|
7511
|
+
current = await runPlatformCommand8(
|
|
7512
|
+
options,
|
|
7513
|
+
timeoutMs,
|
|
7514
|
+
({ client, signal }) => getProjectServerConnectionStatusOperation.execute(
|
|
7515
|
+
{ connectionRequestId },
|
|
7516
|
+
{ client, signal }
|
|
7517
|
+
),
|
|
7518
|
+
interruptController.signal
|
|
7519
|
+
);
|
|
7520
|
+
} catch (error) {
|
|
7521
|
+
if (!interrupted) throw error;
|
|
7522
|
+
return { result: lastResult, gaveUp: true };
|
|
7523
|
+
}
|
|
7524
|
+
lastResult = current;
|
|
7525
|
+
if (isTerminalConnectionStatus(current.status)) {
|
|
7526
|
+
return { result: current, gaveUp: false };
|
|
7527
|
+
}
|
|
7528
|
+
if (interrupted) return { result: current, gaveUp: true };
|
|
7529
|
+
if (Date.now() + delayMs > deadline) {
|
|
7530
|
+
return { result: current, gaveUp: true };
|
|
7531
|
+
}
|
|
7532
|
+
await new Promise((resolve) => {
|
|
7533
|
+
const timer = setTimeout(resolve, delayMs);
|
|
7534
|
+
wakeSleep = () => {
|
|
7535
|
+
clearTimeout(timer);
|
|
7536
|
+
resolve();
|
|
7537
|
+
};
|
|
7538
|
+
});
|
|
7539
|
+
wakeSleep = void 0;
|
|
7540
|
+
if (interrupted) {
|
|
7541
|
+
return { result: current, gaveUp: true };
|
|
7542
|
+
}
|
|
7543
|
+
delayMs = Math.min(delayMs * 1.5, 1e4);
|
|
7544
|
+
}
|
|
7545
|
+
} finally {
|
|
7546
|
+
process.removeListener("SIGINT", onInterrupt);
|
|
7547
|
+
}
|
|
7548
|
+
}
|
|
7311
7549
|
function registerProtocolCommands(program) {
|
|
7312
7550
|
const protocol = program.command("protocol").description("MCP protocol inspection and conformance checks");
|
|
7313
7551
|
protocol.command("conformance").description("Run MCP protocol conformance checks against an HTTP server").requiredOption("--url <url>", "MCP server URL").option("--access-token <token>", "Bearer access token for HTTP servers").option(
|
|
@@ -7473,10 +7711,10 @@ function redactOAuthConformanceResult(result, options) {
|
|
|
7473
7711
|
options.credentialsFilePath
|
|
7474
7712
|
);
|
|
7475
7713
|
}
|
|
7476
|
-
return
|
|
7714
|
+
return redactForTelemetry(result);
|
|
7477
7715
|
}
|
|
7478
7716
|
function redactOAuthConformanceSuiteResult(result, options) {
|
|
7479
|
-
const redacted =
|
|
7717
|
+
const redacted = redactForTelemetry(result);
|
|
7480
7718
|
if (options.credentialsFilePath) {
|
|
7481
7719
|
redacted.credentialsFile = options.credentialsFilePath;
|
|
7482
7720
|
}
|
|
@@ -8287,7 +8525,7 @@ function printRegistrationNotes(result, quiet) {
|
|
|
8287
8525
|
function redactXaaResult(result) {
|
|
8288
8526
|
const rawIdJag = result.idJag?.token;
|
|
8289
8527
|
const masked = result.idJag ? { ...result, idJag: { ...result.idJag, token: "[REDACTED]" } } : result;
|
|
8290
|
-
const scrubbed =
|
|
8528
|
+
const scrubbed = redactForTelemetry(masked);
|
|
8291
8529
|
const afterRaw = rawIdJag ? replaceRawValue(scrubbed, rawIdJag) : scrubbed;
|
|
8292
8530
|
return result.registration ? { ...afterRaw, registration: result.registration } : afterRaw;
|
|
8293
8531
|
}
|
|
@@ -8812,7 +9050,7 @@ function registerServerCommands(program) {
|
|
|
8812
9050
|
throw operationalError("Probe did not return a result.");
|
|
8813
9051
|
}
|
|
8814
9052
|
writeResult(
|
|
8815
|
-
|
|
9053
|
+
redactForTelemetry(result),
|
|
8816
9054
|
globalOptions.format
|
|
8817
9055
|
);
|
|
8818
9056
|
if (result.status === "error") {
|
|
@@ -8841,7 +9079,7 @@ function registerServerCommands(program) {
|
|
|
8841
9079
|
retryPolicy
|
|
8842
9080
|
});
|
|
8843
9081
|
const rawPayload = globalOptions.rpc ? attachCliRpcLogs(result, collector) : result;
|
|
8844
|
-
const jsonPayload =
|
|
9082
|
+
const jsonPayload = redactForTelemetry(rawPayload);
|
|
8845
9083
|
const artifactPath = options.out ? await writeDebugArtifact(options.out, jsonPayload) : void 0;
|
|
8846
9084
|
if (globalOptions.format === "human") {
|
|
8847
9085
|
process.stdout.write(
|
|
@@ -13024,6 +13262,7 @@ function registerInspectorCommands(program) {
|
|
|
13024
13262
|
// src/index.ts
|
|
13025
13263
|
var pkgVersion = package_default.version;
|
|
13026
13264
|
async function main(argv = process.argv, dependencies = {}) {
|
|
13265
|
+
process.exitCode = 0;
|
|
13027
13266
|
const program = addGlobalOptions(
|
|
13028
13267
|
new Command().name("mcpjam").version(pkgVersion, "-v, --version", "output the CLI version").description(
|
|
13029
13268
|
"Test, debug, and validate MCP servers. Health checks, OAuth conformance, tool-surface diffing, and structured triage from the terminal or CI."
|