@mcpjam/cli 3.14.0 → 3.15.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 +76 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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, redactSensitiveValue, runServerDoctor, collectServerSnapshot, serializeStableServerSnapshot, serializeServerSnapshot, buildServerDiffReport, validateToolCallResult, isCallToolResultError, buildToolCallValidationReport, listResources, readResource, listTools, listPrompts, getPrompt, MCPAppsConformanceTest, MCPAppsConformanceSuite, runOAuthLogin, OAuthConformanceTest, OAuthConformanceSuite, runXaaFlow, MCPConformanceTest, MCPConformanceSuite, withEphemeralClient, diffServerSnapshots, ServerSnapshotFormatError, renderStructuredRunJUnitXml, renderStructuredRunJson, toConformanceReport, renderConformanceReportJUnitXml, renderConformanceReportJson, formatOAuthConformanceHuman, formatOAuthConformanceSuiteHuman, fetchOAuthMetadata, executeOAuthProxy, executeDebugOAuthProxy, normalizeRegistrationStrategy, normalizeIdentityAssertionFormat, IDENTITY_ASSERTION_FORMATS, generateRandomString, generateCodeChallenge, createInteractiveAuthorizationSession, openUrlInBrowser, MCPClientManager, MCP_APPS_CHECK_CATEGORIES, MCP_APPS_CHECK_IDS, OAuthProxyError, MCP_CHECK_CATEGORIES, MCP_CHECK_IDS } from '@mcpjam/sdk';
|
|
5
|
+
import { probeMcpServer, redactSensitiveValue, runServerDoctor, collectServerSnapshot, serializeStableServerSnapshot, serializeServerSnapshot, buildServerDiffReport, validateToolCallResult, isCallToolResultError, buildToolCallValidationReport, listResources, readResource, listTools, listPrompts, getPrompt, MCPAppsConformanceTest, MCPAppsConformanceSuite, runOAuthLogin, OAuthConformanceTest, OAuthConformanceSuite, runXaaFlow, MCPConformanceTest, MCPConformanceSuite, withEphemeralClient, diffServerSnapshots, ServerSnapshotFormatError, renderStructuredRunJUnitXml, renderStructuredRunJson, toConformanceReport, renderConformanceReportJUnitXml, renderConformanceReportJson, formatOAuthConformanceHuman, formatOAuthConformanceSuiteHuman, fetchOAuthMetadata, executeOAuthProxy, executeDebugOAuthProxy, normalizeRegistrationStrategy, normalizeIdentityAssertionFormat, IDENTITY_ASSERTION_FORMATS, XAA_CONFIDENTIAL_CIMD_ORIGIN, initXaaClientKeyPair, buildConfidentialCimdUrl, getXaaClientJwks, generateRandomString, generateCodeChallenge, createInteractiveAuthorizationSession, openUrlInBrowser, MCPClientManager, MCP_APPS_CHECK_CATEGORIES, MCP_APPS_CHECK_IDS, OAuthProxyError, isLoopbackHost, MCP_CHECK_CATEGORIES, MCP_CHECK_IDS } 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';
|
|
@@ -23,7 +23,7 @@ import { WebSocket } from 'ws';
|
|
|
23
23
|
|
|
24
24
|
// package.json
|
|
25
25
|
var package_default = {
|
|
26
|
-
version: "3.
|
|
26
|
+
version: "3.15.0"};
|
|
27
27
|
|
|
28
28
|
// src/lib/output.ts
|
|
29
29
|
var DEFAULT_OUTPUT_FORMAT = "json";
|
|
@@ -6562,6 +6562,13 @@ function registerXaaCommands(program) {
|
|
|
6562
6562
|
).option(
|
|
6563
6563
|
"--client-metadata-url <url>",
|
|
6564
6564
|
"CIMD only: the Client ID Metadata Document URL to present as the client_id (default: the hosted XAA debugger document)"
|
|
6565
|
+
).option(
|
|
6566
|
+
"--client-auth <method>",
|
|
6567
|
+
"CIMD only: how the client authenticates. none (public, default) or private-key-jwt (confidential \u2014 generates a client key, publishes it via the hosted reflector, and signs a client_assertion)",
|
|
6568
|
+
parseClientAuth
|
|
6569
|
+
).option(
|
|
6570
|
+
"--cimd-metadata-origin <url>",
|
|
6571
|
+
"Confidential CIMD only: origin hosting the metadata-document reflector (default: the hosted app.mcpjam.com). An http loopback origin is a dev-only opt-in (requires no --https-only)"
|
|
6565
6572
|
).option(
|
|
6566
6573
|
"--authz-server-issuer <issuer>",
|
|
6567
6574
|
"Target authorization-server issuer. When set, protected-resource metadata discovery is skipped"
|
|
@@ -6586,6 +6593,7 @@ function registerXaaCommands(program) {
|
|
|
6586
6593
|
options,
|
|
6587
6594
|
globalOptions.timeout
|
|
6588
6595
|
);
|
|
6596
|
+
resolveConfidentialCimd(config, globalOptions.quiet);
|
|
6589
6597
|
const isTTY = process.stderr.isTTY && !globalOptions.quiet;
|
|
6590
6598
|
if (isTTY) {
|
|
6591
6599
|
config.onProgress = (message) => {
|
|
@@ -6693,6 +6701,32 @@ function buildXaaConfig(options, timeoutMs) {
|
|
|
6693
6701
|
);
|
|
6694
6702
|
}
|
|
6695
6703
|
}
|
|
6704
|
+
const clientAuth = options.clientAuth ?? "none";
|
|
6705
|
+
const cimdMetadataOrigin = options.cimdMetadataOrigin?.trim() || void 0;
|
|
6706
|
+
if (clientAuth === "private_key_jwt" && strategy !== "cimd") {
|
|
6707
|
+
throw usageError(
|
|
6708
|
+
"--client-auth private-key-jwt is only valid with --registration cimd."
|
|
6709
|
+
);
|
|
6710
|
+
}
|
|
6711
|
+
if (clientAuth === "private_key_jwt" && clientMetadataUrl) {
|
|
6712
|
+
throw usageError(
|
|
6713
|
+
"--client-metadata-url cannot be combined with --client-auth private-key-jwt: the confidential client publishes its own metadata document via the reflector."
|
|
6714
|
+
);
|
|
6715
|
+
}
|
|
6716
|
+
if (cimdMetadataOrigin) {
|
|
6717
|
+
assertValidUrl3(cimdMetadataOrigin, "CIMD metadata origin");
|
|
6718
|
+
if (clientAuth !== "private_key_jwt") {
|
|
6719
|
+
throw usageError(
|
|
6720
|
+
"--cimd-metadata-origin is only valid with --client-auth private-key-jwt."
|
|
6721
|
+
);
|
|
6722
|
+
}
|
|
6723
|
+
const parsed = new URL(cimdMetadataOrigin);
|
|
6724
|
+
if (parsed.pathname !== "/" || parsed.search || parsed.hash) {
|
|
6725
|
+
throw usageError(
|
|
6726
|
+
"--cimd-metadata-origin must be a bare origin (scheme + host[:port]) with no path, query, or fragment."
|
|
6727
|
+
);
|
|
6728
|
+
}
|
|
6729
|
+
}
|
|
6696
6730
|
const authzServerIssuer = options.authzServerIssuer?.trim() || void 0;
|
|
6697
6731
|
if (authzServerIssuer) {
|
|
6698
6732
|
assertValidUrl3(authzServerIssuer, "authorization server issuer");
|
|
@@ -6721,6 +6755,8 @@ function buildXaaConfig(options, timeoutMs) {
|
|
|
6721
6755
|
...clientId ? { clientId } : {},
|
|
6722
6756
|
...strategy !== "preregistered" ? { registrationStrategy: strategy } : {},
|
|
6723
6757
|
...clientMetadataUrl ? { clientIdMetadataUrl: clientMetadataUrl } : {},
|
|
6758
|
+
...clientAuth !== "none" ? { clientAuth } : {},
|
|
6759
|
+
...cimdMetadataOrigin ? { cimdMetadataOrigin } : {},
|
|
6724
6760
|
...authzServerIssuer ? { authzServerIssuer } : {},
|
|
6725
6761
|
...tokenEndpoint ? { tokenEndpoint } : {},
|
|
6726
6762
|
...options.email?.trim() ? { email: options.email.trim() } : {},
|
|
@@ -6750,6 +6786,44 @@ function parseRegistration(value) {
|
|
|
6750
6786
|
}
|
|
6751
6787
|
return strategy;
|
|
6752
6788
|
}
|
|
6789
|
+
function isLoopbackHttpOrigin(origin) {
|
|
6790
|
+
try {
|
|
6791
|
+
const { protocol, hostname } = new URL(origin);
|
|
6792
|
+
return protocol === "http:" && isLoopbackHost(hostname);
|
|
6793
|
+
} catch {
|
|
6794
|
+
return false;
|
|
6795
|
+
}
|
|
6796
|
+
}
|
|
6797
|
+
function resolveConfidentialCimd(config, quiet) {
|
|
6798
|
+
if (config.clientAuth !== "private_key_jwt") return;
|
|
6799
|
+
const origin = config.cimdMetadataOrigin ?? XAA_CONFIDENTIAL_CIMD_ORIGIN;
|
|
6800
|
+
const loopback = isLoopbackHttpOrigin(origin);
|
|
6801
|
+
if (loopback && config.httpsOnly) {
|
|
6802
|
+
throw usageError(
|
|
6803
|
+
"--cimd-metadata-origin is an http loopback URL, but --https-only is set. Use an HTTPS origin, or drop --https-only for local dev."
|
|
6804
|
+
);
|
|
6805
|
+
}
|
|
6806
|
+
initXaaClientKeyPair();
|
|
6807
|
+
config.clientIdMetadataUrl = buildConfidentialCimdUrl(
|
|
6808
|
+
getXaaClientJwks().keys[0],
|
|
6809
|
+
origin
|
|
6810
|
+
);
|
|
6811
|
+
if (loopback) {
|
|
6812
|
+
config.allowLoopbackClientMetadata = true;
|
|
6813
|
+
if (!quiet) {
|
|
6814
|
+
process.stderr.write(
|
|
6815
|
+
`Note: using a loopback CIMD reflector (${origin}) \u2014 dev-only and non-standard (CIMD requires HTTPS); production uses ${XAA_CONFIDENTIAL_CIMD_ORIGIN}.
|
|
6816
|
+
`
|
|
6817
|
+
);
|
|
6818
|
+
}
|
|
6819
|
+
}
|
|
6820
|
+
}
|
|
6821
|
+
function parseClientAuth(value) {
|
|
6822
|
+
if (value === "none") return "none";
|
|
6823
|
+
if (value === "private-key-jwt" || value === "private_key_jwt")
|
|
6824
|
+
return "private_key_jwt";
|
|
6825
|
+
throw usageError("--client-auth must be none or private-key-jwt.");
|
|
6826
|
+
}
|
|
6753
6827
|
function parseTokenEndpointAuthMethod(value) {
|
|
6754
6828
|
if (value === "client_secret_basic" || value === "client_secret_post" || value === "none") {
|
|
6755
6829
|
return value;
|