@mcp-z/cli 1.0.0 → 1.0.2
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/cjs/index.d.cts +4 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.js +16 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/json-schema.js +15 -13
- package/dist/cjs/lib/json-schema.js.map +1 -1
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/json-schema.js +8 -11
- package/dist/esm/lib/json-schema.js.map +1 -1
- package/package.json +1 -2
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
export { callToolCommand } from './commands/call-tool.js';
|
|
2
|
+
export { getPromptCommand } from './commands/get-prompt.js';
|
|
3
|
+
export { inspectCommand } from './commands/inspect.js';
|
|
1
4
|
export { type Combination, type ConfigChoice, type ConfigurationMode, createConfigChoices, type Dimension, discoverServerJson, extractServerName, filterConfigChoices, generateConditionalCombinations, generateConfigFile, generateConfigObject, generateMatrixCombinations, shouldPromptEnvVar, TRANSPORT_MAP, } from './commands/manifest/generate.js';
|
|
2
5
|
export { type CliArgMetadata, type EnvVarMetadata, MetadataReader, type ServerMetadata } from './commands/manifest/metadata-reader.js';
|
|
3
6
|
export { validateCommand } from './commands/manifest/validate.js';
|
|
7
|
+
export { readResourceCommand } from './commands/read-resource.js';
|
|
4
8
|
export { upCommand } from './commands/up.js';
|
|
5
9
|
export { getSchema, SCHEMA_URL, validateSchema } from './lib/json-schema.js';
|
|
6
10
|
export { type InlineConfigOptions, type ResolvedServerConfig, resolveServerConfig } from './lib/resolve-server-config.js';
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
export { callToolCommand } from './commands/call-tool.js';
|
|
2
|
+
export { getPromptCommand } from './commands/get-prompt.js';
|
|
3
|
+
export { inspectCommand } from './commands/inspect.js';
|
|
1
4
|
export { type Combination, type ConfigChoice, type ConfigurationMode, createConfigChoices, type Dimension, discoverServerJson, extractServerName, filterConfigChoices, generateConditionalCombinations, generateConfigFile, generateConfigObject, generateMatrixCombinations, shouldPromptEnvVar, TRANSPORT_MAP, } from './commands/manifest/generate.js';
|
|
2
5
|
export { type CliArgMetadata, type EnvVarMetadata, MetadataReader, type ServerMetadata } from './commands/manifest/metadata-reader.js';
|
|
3
6
|
export { validateCommand } from './commands/manifest/validate.js';
|
|
7
|
+
export { readResourceCommand } from './commands/read-resource.js';
|
|
4
8
|
export { upCommand } from './commands/up.js';
|
|
5
9
|
export { getSchema, SCHEMA_URL, validateSchema } from './lib/json-schema.js';
|
|
6
10
|
export { type InlineConfigOptions, type ResolvedServerConfig, resolveServerConfig } from './lib/resolve-server-config.js';
|
package/dist/cjs/index.js
CHANGED
|
@@ -19,6 +19,9 @@ _export(exports, {
|
|
|
19
19
|
get TRANSPORT_MAP () {
|
|
20
20
|
return _generatets.TRANSPORT_MAP;
|
|
21
21
|
},
|
|
22
|
+
get callToolCommand () {
|
|
23
|
+
return _calltoolts.callToolCommand;
|
|
24
|
+
},
|
|
22
25
|
get createConfigChoices () {
|
|
23
26
|
return _generatets.createConfigChoices;
|
|
24
27
|
},
|
|
@@ -43,9 +46,18 @@ _export(exports, {
|
|
|
43
46
|
get generateMatrixCombinations () {
|
|
44
47
|
return _generatets.generateMatrixCombinations;
|
|
45
48
|
},
|
|
49
|
+
get getPromptCommand () {
|
|
50
|
+
return _getpromptts.getPromptCommand;
|
|
51
|
+
},
|
|
46
52
|
get getSchema () {
|
|
47
53
|
return _jsonschemats.getSchema;
|
|
48
54
|
},
|
|
55
|
+
get inspectCommand () {
|
|
56
|
+
return _inspectts.inspectCommand;
|
|
57
|
+
},
|
|
58
|
+
get readResourceCommand () {
|
|
59
|
+
return _readresourcets.readResourceCommand;
|
|
60
|
+
},
|
|
49
61
|
get resolveServerConfig () {
|
|
50
62
|
return _resolveserverconfigts.resolveServerConfig;
|
|
51
63
|
},
|
|
@@ -62,9 +74,13 @@ _export(exports, {
|
|
|
62
74
|
return _jsonschemats.validateSchema;
|
|
63
75
|
}
|
|
64
76
|
});
|
|
77
|
+
var _calltoolts = require("./commands/call-tool.js");
|
|
78
|
+
var _getpromptts = require("./commands/get-prompt.js");
|
|
79
|
+
var _inspectts = require("./commands/inspect.js");
|
|
65
80
|
var _generatets = require("./commands/manifest/generate.js");
|
|
66
81
|
var _metadatareaderts = require("./commands/manifest/metadata-reader.js");
|
|
67
82
|
var _validatets = require("./commands/manifest/validate.js");
|
|
83
|
+
var _readresourcets = require("./commands/read-resource.js");
|
|
68
84
|
var _upts = require("./commands/up.js");
|
|
69
85
|
var _jsonschemats = require("./lib/json-schema.js");
|
|
70
86
|
var _resolveserverconfigts = require("./lib/resolve-server-config.js");
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/cli/src/index.ts"],"sourcesContent":["// Base types and type guards\n\nexport {\n type Combination,\n type ConfigChoice,\n type ConfigurationMode,\n createConfigChoices,\n type Dimension,\n discoverServerJson,\n extractServerName,\n filterConfigChoices,\n generateConditionalCombinations,\n generateConfigFile,\n generateConfigObject,\n generateMatrixCombinations,\n shouldPromptEnvVar,\n TRANSPORT_MAP,\n} from './commands/manifest/generate.ts';\nexport { type CliArgMetadata, type EnvVarMetadata, MetadataReader, type ServerMetadata } from './commands/manifest/metadata-reader.ts';\n
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/cli/src/index.ts"],"sourcesContent":["// Base types and type guards\n\nexport { callToolCommand } from './commands/call-tool.ts';\nexport { getPromptCommand } from './commands/get-prompt.ts';\nexport { inspectCommand } from './commands/inspect.ts';\nexport {\n type Combination,\n type ConfigChoice,\n type ConfigurationMode,\n createConfigChoices,\n type Dimension,\n discoverServerJson,\n extractServerName,\n filterConfigChoices,\n generateConditionalCombinations,\n generateConfigFile,\n generateConfigObject,\n generateMatrixCombinations,\n shouldPromptEnvVar,\n TRANSPORT_MAP,\n} from './commands/manifest/generate.ts';\nexport { type CliArgMetadata, type EnvVarMetadata, MetadataReader, type ServerMetadata } from './commands/manifest/metadata-reader.ts';\n// Manifest commands\nexport { validateCommand } from './commands/manifest/validate.ts';\nexport { readResourceCommand } from './commands/read-resource.ts';\nexport { upCommand } from './commands/up.ts';\n\n// Library utilities\nexport { getSchema, SCHEMA_URL, validateSchema } from './lib/json-schema.ts';\nexport { type InlineConfigOptions, type ResolvedServerConfig, resolveServerConfig } from './lib/resolve-server-config.ts';\nexport * from './types.ts';\n"],"names":["MetadataReader","SCHEMA_URL","TRANSPORT_MAP","callToolCommand","createConfigChoices","discoverServerJson","extractServerName","filterConfigChoices","generateConditionalCombinations","generateConfigFile","generateConfigObject","generateMatrixCombinations","getPromptCommand","getSchema","inspectCommand","readResourceCommand","resolveServerConfig","shouldPromptEnvVar","upCommand","validateCommand","validateSchema"],"mappings":"AAAA,6BAA6B;;;;;;;;;;;;QAqBsBA;eAAAA,gCAAc;;QAO7CC;eAAAA,wBAAU;;QAT5BC;eAAAA,yBAAa;;QAjBNC;eAAAA,2BAAe;;QAOtBC;eAAAA,+BAAmB;;QAEnBC;eAAAA,8BAAkB;;QAClBC;eAAAA,6BAAiB;;QACjBC;eAAAA,+BAAmB;;QACnBC;eAAAA,2CAA+B;;QAC/BC;eAAAA,8BAAkB;;QAClBC;eAAAA,gCAAoB;;QACpBC;eAAAA,sCAA0B;;QAdnBC;eAAAA,6BAAgB;;QAyBhBC;eAAAA,uBAAS;;QAxBTC;eAAAA,yBAAc;;QAoBdC;eAAAA,mCAAmB;;QAKkCC;eAAAA,0CAAmB;;QAX/EC;eAAAA,8BAAkB;;QAOXC;eAAAA,eAAS;;QAFTC;eAAAA,2BAAe;;QAKQC;eAAAA,4BAAc;;;0BA1Bd;2BACC;yBACF;0BAgBxB;gCACuF;0BAE9D;8BACI;oBACV;4BAG4B;qCACmC;qBAC3E"}
|
|
@@ -20,10 +20,11 @@ _export(exports, {
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
var _ajv = require("ajv");
|
|
23
|
+
var _ajvformats = /*#__PURE__*/ _interop_require_default(require("ajv-formats"));
|
|
23
24
|
var _fs = /*#__PURE__*/ _interop_require_wildcard(require("fs"));
|
|
24
|
-
var
|
|
25
|
+
var _modulerootsync = /*#__PURE__*/ _interop_require_default(require("module-root-sync"));
|
|
25
26
|
var _path = /*#__PURE__*/ _interop_require_wildcard(require("path"));
|
|
26
|
-
var _url = require("url");
|
|
27
|
+
var _url = /*#__PURE__*/ _interop_require_wildcard(require("url"));
|
|
27
28
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
28
29
|
try {
|
|
29
30
|
var info = gen[key](arg);
|
|
@@ -53,6 +54,11 @@ function _async_to_generator(fn) {
|
|
|
53
54
|
});
|
|
54
55
|
};
|
|
55
56
|
}
|
|
57
|
+
function _interop_require_default(obj) {
|
|
58
|
+
return obj && obj.__esModule ? obj : {
|
|
59
|
+
default: obj
|
|
60
|
+
};
|
|
61
|
+
}
|
|
56
62
|
function _getRequireWildcardCache(nodeInterop) {
|
|
57
63
|
if (typeof WeakMap !== "function") return null;
|
|
58
64
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -193,17 +199,13 @@ function _ts_generator(thisArg, body) {
|
|
|
193
199
|
};
|
|
194
200
|
}
|
|
195
201
|
}
|
|
196
|
-
|
|
197
|
-
var
|
|
198
|
-
var __dirname = _path.dirname(__filename1);
|
|
199
|
-
// Import ajv-formats (CommonJS module - use createRequire for ESM compatibility)
|
|
200
|
-
var require1 = (0, _module.createRequire)(require("url").pathToFileURL(__filename).toString());
|
|
201
|
-
var addFormats = require1('ajv-formats');
|
|
202
|
+
var __dirname = _path.dirname(typeof __filename !== 'undefined' ? __filename : _url.fileURLToPath(require("url").pathToFileURL(__filename).toString()));
|
|
203
|
+
var packageRoot = (0, _modulerootsync.default)(__dirname);
|
|
202
204
|
var SCHEMA_URL = 'https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json';
|
|
203
205
|
var schemaCache = null;
|
|
204
206
|
function getSchema() {
|
|
205
207
|
return _async_to_generator(function() {
|
|
206
|
-
var response, unused,
|
|
208
|
+
var response, unused, schemaPath;
|
|
207
209
|
return _ts_generator(this, function(_state) {
|
|
208
210
|
switch(_state.label){
|
|
209
211
|
case 0:
|
|
@@ -255,11 +257,11 @@ function getSchema() {
|
|
|
255
257
|
];
|
|
256
258
|
case 6:
|
|
257
259
|
// Fallback to bundled schema
|
|
258
|
-
|
|
259
|
-
if (!_fs.existsSync(
|
|
260
|
+
schemaPath = _path.join(packageRoot, './schemas/server.schema.json');
|
|
261
|
+
if (!_fs.existsSync(schemaPath)) {
|
|
260
262
|
throw new Error('Failed to fetch MCP schema from URL and no bundled schema found. ' + 'Check network connection or report this as a bug.');
|
|
261
263
|
}
|
|
262
|
-
schemaCache = JSON.parse(_fs.readFileSync(
|
|
264
|
+
schemaCache = JSON.parse(_fs.readFileSync(schemaPath, 'utf8'));
|
|
263
265
|
return [
|
|
264
266
|
2,
|
|
265
267
|
schemaCache
|
|
@@ -286,7 +288,7 @@ function validateSchema(serverJson, serverName) {
|
|
|
286
288
|
strictSchema: false
|
|
287
289
|
});
|
|
288
290
|
// Add format validators (uri, email, etc.) to silence warnings
|
|
289
|
-
|
|
291
|
+
(0, _ajvformats.default)(ajv);
|
|
290
292
|
validate = ajv.compile(schema);
|
|
291
293
|
valid = validate(serverJson);
|
|
292
294
|
if (!valid) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/cli/src/lib/json-schema.ts"],"sourcesContent":["import { Ajv, type ErrorObject } from 'ajv';\nimport * as fs from 'fs';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/cli/src/lib/json-schema.ts"],"sourcesContent":["import { Ajv, type ErrorObject } from 'ajv';\nimport addFormats from 'ajv-formats';\nimport * as fs from 'fs';\nimport moduleRoot from 'module-root-sync';\nimport * as path from 'path';\nimport * as url from 'url';\n\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\nconst packageRoot = moduleRoot(__dirname);\n\nexport const SCHEMA_URL = 'https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json';\n\nlet schemaCache: object | null = null;\n\n/**\n * Get MCP server.json schema (fetches once, then caches)\n *\n * Strategy:\n * 1. Return cached schema if available\n * 2. Try fetching latest schema from URL\n * 3. Fall back to bundled schema if network fails\n */\nexport async function getSchema(): Promise<object> {\n // Return cached schema\n if (schemaCache) {\n return schemaCache;\n }\n\n try {\n // Try fetching latest schema\n const response = await fetch(SCHEMA_URL);\n if (response.ok) {\n schemaCache = (await response.json()) as object;\n return schemaCache;\n }\n } catch {\n // Network error - fall through to bundled version\n }\n\n // Fallback to bundled schema\n const schemaPath = path.join(packageRoot, './schemas/server.schema.json');\n if (!fs.existsSync(schemaPath)) {\n throw new Error('Failed to fetch MCP schema from URL and no bundled schema found. ' + 'Check network connection or report this as a bug.');\n }\n\n schemaCache = JSON.parse(fs.readFileSync(schemaPath, 'utf8')) as object;\n return schemaCache;\n}\n\n/**\n * Validate server.json against MCP schema\n *\n * @param serverJson - Parsed server.json content to validate\n * @param serverName - Server name for error messages\n * @throws Error with detailed validation messages if invalid\n */\nexport async function validateSchema(serverJson: unknown, serverName: string): Promise<void> {\n const schema = await getSchema();\n\n const ajv = new Ajv({\n allErrors: true,\n verbose: true,\n strictSchema: false, // Allow non-standard keywords like \"example\", \"choices\"\n });\n\n // Add format validators (uri, email, etc.) to silence warnings\n addFormats(ajv);\n\n const validate = ajv.compile(schema);\n const valid = validate(serverJson);\n\n if (!valid) {\n const errors = validate.errors?.map((e: ErrorObject) => ` - ${e.instancePath || '(root)'} ${e.message}`).join('\\n') || 'Unknown validation error';\n\n throw new Error(`Invalid server.json for '${serverName}':\\n${errors}\\n\\nThe server.json file does not conform to the MCP specification.\\nSee: https://modelcontextprotocol.io/specification/server\\n\\nTo fix: Update the server.json file to match the schema requirements above.`);\n }\n}\n"],"names":["SCHEMA_URL","getSchema","validateSchema","__dirname","path","dirname","__filename","url","fileURLToPath","packageRoot","moduleRoot","schemaCache","response","schemaPath","fetch","ok","json","join","fs","existsSync","Error","JSON","parse","readFileSync","serverJson","serverName","schema","ajv","validate","valid","errors","Ajv","allErrors","verbose","strictSchema","addFormats","compile","map","e","instancePath","message"],"mappings":";;;;;;;;;;;QAUaA;eAAAA;;QAYSC;eAAAA;;QAkCAC;eAAAA;;;mBAxDgB;iEACf;0DACH;qEACG;4DACD;2DACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErB,IAAMC,YAAYC,MAAKC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,KAAIC,aAAa,CAAC;AAClG,IAAMC,cAAcC,IAAAA,uBAAU,EAACP;AAExB,IAAMH,aAAa;AAE1B,IAAIW,cAA6B;AAU1B,SAAeV;;YAQZW,kBAUFC;;;;oBAjBN,uBAAuB;oBACvB,IAAIF,aAAa;wBACf;;4BAAOA;;oBACT;;;;;;;;;oBAImB;;wBAAMG,MAAMd;;;oBAAvBY,WAAW;yBACbA,SAASG,EAAE,EAAXH;;;;oBACa;;wBAAMA,SAASI,IAAI;;;oBAAlCL,cAAe;oBACf;;wBAAOA;;;;;;;;;;;;;;oBAMX,6BAA6B;oBACvBE,aAAaT,MAAKa,IAAI,CAACR,aAAa;oBAC1C,IAAI,CAACS,IAAGC,UAAU,CAACN,aAAa;wBAC9B,MAAM,IAAIO,MAAM,sEAAsE;oBACxF;oBAEAT,cAAcU,KAAKC,KAAK,CAACJ,IAAGK,YAAY,CAACV,YAAY;oBACrD;;wBAAOF;;;;IACT;;AASO,SAAeT,eAAesB,UAAmB,EAAEC,UAAkB;;YACpEC,QAEAC,KASAC,UACAC,OAGWD,kBAATE;;;;oBAfO;;wBAAM7B;;;oBAAfyB,SAAS;oBAETC,MAAM,IAAII,QAAG,CAAC;wBAClBC,WAAW;wBACXC,SAAS;wBACTC,cAAc;oBAChB;oBAEA,+DAA+D;oBAC/DC,IAAAA,mBAAU,EAACR;oBAELC,WAAWD,IAAIS,OAAO,CAACV;oBACvBG,QAAQD,SAASJ;oBAEvB,IAAI,CAACK,OAAO;;wBACJC,SAASF,EAAAA,mBAAAA,SAASE,MAAM,cAAfF,uCAAAA,iBAAiBS,GAAG,CAAC,SAACC;mCAAmB,AAAC,OAAoCA,OAA9BA,EAAEC,YAAY,IAAI,UAAS,KAAa,OAAVD,EAAEE,OAAO;2BAAIvB,IAAI,CAAC,UAAS;wBAExH,MAAM,IAAIG,MAAM,AAAC,4BAA4CU,OAAjBL,YAAW,QAAa,OAAPK,QAAO;oBACtE;;;;;;IACF"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
export { callToolCommand } from './commands/call-tool.js';
|
|
2
|
+
export { getPromptCommand } from './commands/get-prompt.js';
|
|
3
|
+
export { inspectCommand } from './commands/inspect.js';
|
|
1
4
|
export { type Combination, type ConfigChoice, type ConfigurationMode, createConfigChoices, type Dimension, discoverServerJson, extractServerName, filterConfigChoices, generateConditionalCombinations, generateConfigFile, generateConfigObject, generateMatrixCombinations, shouldPromptEnvVar, TRANSPORT_MAP, } from './commands/manifest/generate.js';
|
|
2
5
|
export { type CliArgMetadata, type EnvVarMetadata, MetadataReader, type ServerMetadata } from './commands/manifest/metadata-reader.js';
|
|
3
6
|
export { validateCommand } from './commands/manifest/validate.js';
|
|
7
|
+
export { readResourceCommand } from './commands/read-resource.js';
|
|
4
8
|
export { upCommand } from './commands/up.js';
|
|
5
9
|
export { getSchema, SCHEMA_URL, validateSchema } from './lib/json-schema.js';
|
|
6
10
|
export { type InlineConfigOptions, type ResolvedServerConfig, resolveServerConfig } from './lib/resolve-server-config.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
// Base types and type guards
|
|
2
|
+
export { callToolCommand } from './commands/call-tool.js';
|
|
3
|
+
export { getPromptCommand } from './commands/get-prompt.js';
|
|
4
|
+
export { inspectCommand } from './commands/inspect.js';
|
|
2
5
|
export { createConfigChoices, discoverServerJson, extractServerName, filterConfigChoices, generateConditionalCombinations, generateConfigFile, generateConfigObject, generateMatrixCombinations, shouldPromptEnvVar, TRANSPORT_MAP } from './commands/manifest/generate.js';
|
|
3
6
|
export { MetadataReader } from './commands/manifest/metadata-reader.js';
|
|
4
7
|
// Manifest commands
|
|
5
8
|
export { validateCommand } from './commands/manifest/validate.js';
|
|
6
|
-
|
|
9
|
+
export { readResourceCommand } from './commands/read-resource.js';
|
|
7
10
|
export { upCommand } from './commands/up.js';
|
|
8
11
|
// Library utilities
|
|
9
12
|
export { getSchema, SCHEMA_URL, validateSchema } from './lib/json-schema.js';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/cli/src/index.ts"],"sourcesContent":["// Base types and type guards\n\nexport {\n type Combination,\n type ConfigChoice,\n type ConfigurationMode,\n createConfigChoices,\n type Dimension,\n discoverServerJson,\n extractServerName,\n filterConfigChoices,\n generateConditionalCombinations,\n generateConfigFile,\n generateConfigObject,\n generateMatrixCombinations,\n shouldPromptEnvVar,\n TRANSPORT_MAP,\n} from './commands/manifest/generate.ts';\nexport { type CliArgMetadata, type EnvVarMetadata, MetadataReader, type ServerMetadata } from './commands/manifest/metadata-reader.ts';\n
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/cli/src/index.ts"],"sourcesContent":["// Base types and type guards\n\nexport { callToolCommand } from './commands/call-tool.ts';\nexport { getPromptCommand } from './commands/get-prompt.ts';\nexport { inspectCommand } from './commands/inspect.ts';\nexport {\n type Combination,\n type ConfigChoice,\n type ConfigurationMode,\n createConfigChoices,\n type Dimension,\n discoverServerJson,\n extractServerName,\n filterConfigChoices,\n generateConditionalCombinations,\n generateConfigFile,\n generateConfigObject,\n generateMatrixCombinations,\n shouldPromptEnvVar,\n TRANSPORT_MAP,\n} from './commands/manifest/generate.ts';\nexport { type CliArgMetadata, type EnvVarMetadata, MetadataReader, type ServerMetadata } from './commands/manifest/metadata-reader.ts';\n// Manifest commands\nexport { validateCommand } from './commands/manifest/validate.ts';\nexport { readResourceCommand } from './commands/read-resource.ts';\nexport { upCommand } from './commands/up.ts';\n\n// Library utilities\nexport { getSchema, SCHEMA_URL, validateSchema } from './lib/json-schema.ts';\nexport { type InlineConfigOptions, type ResolvedServerConfig, resolveServerConfig } from './lib/resolve-server-config.ts';\nexport * from './types.ts';\n"],"names":["callToolCommand","getPromptCommand","inspectCommand","createConfigChoices","discoverServerJson","extractServerName","filterConfigChoices","generateConditionalCombinations","generateConfigFile","generateConfigObject","generateMatrixCombinations","shouldPromptEnvVar","TRANSPORT_MAP","MetadataReader","validateCommand","readResourceCommand","upCommand","getSchema","SCHEMA_URL","validateSchema","resolveServerConfig"],"mappings":"AAAA,6BAA6B;AAE7B,SAASA,eAAe,QAAQ,0BAA0B;AAC1D,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAIEC,mBAAmB,EAEnBC,kBAAkB,EAClBC,iBAAiB,EACjBC,mBAAmB,EACnBC,+BAA+B,EAC/BC,kBAAkB,EAClBC,oBAAoB,EACpBC,0BAA0B,EAC1BC,kBAAkB,EAClBC,aAAa,QACR,kCAAkC;AACzC,SAAmDC,cAAc,QAA6B,yCAAyC;AACvI,oBAAoB;AACpB,SAASC,eAAe,QAAQ,kCAAkC;AAClE,SAASC,mBAAmB,QAAQ,8BAA8B;AAClE,SAASC,SAAS,QAAQ,mBAAmB;AAE7C,oBAAoB;AACpB,SAASC,SAAS,EAAEC,UAAU,EAAEC,cAAc,QAAQ,uBAAuB;AAC7E,SAA8DC,mBAAmB,QAAQ,iCAAiC;AAC1H,cAAc,aAAa"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { Ajv } from 'ajv';
|
|
2
|
+
import addFormats from 'ajv-formats';
|
|
2
3
|
import * as fs from 'fs';
|
|
3
|
-
import
|
|
4
|
+
import moduleRoot from 'module-root-sync';
|
|
4
5
|
import * as path from 'path';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const __dirname = path.dirname(__filename);
|
|
9
|
-
// Import ajv-formats (CommonJS module - use createRequire for ESM compatibility)
|
|
10
|
-
const require = createRequire(import.meta.url);
|
|
11
|
-
const addFormats = require('ajv-formats');
|
|
6
|
+
import * as url from 'url';
|
|
7
|
+
const __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));
|
|
8
|
+
const packageRoot = moduleRoot(__dirname);
|
|
12
9
|
export const SCHEMA_URL = 'https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json';
|
|
13
10
|
let schemaCache = null;
|
|
14
11
|
/**
|
|
@@ -34,11 +31,11 @@ let schemaCache = null;
|
|
|
34
31
|
// Network error - fall through to bundled version
|
|
35
32
|
}
|
|
36
33
|
// Fallback to bundled schema
|
|
37
|
-
const
|
|
38
|
-
if (!fs.existsSync(
|
|
34
|
+
const schemaPath = path.join(packageRoot, './schemas/server.schema.json');
|
|
35
|
+
if (!fs.existsSync(schemaPath)) {
|
|
39
36
|
throw new Error('Failed to fetch MCP schema from URL and no bundled schema found. ' + 'Check network connection or report this as a bug.');
|
|
40
37
|
}
|
|
41
|
-
schemaCache = JSON.parse(fs.readFileSync(
|
|
38
|
+
schemaCache = JSON.parse(fs.readFileSync(schemaPath, 'utf8'));
|
|
42
39
|
return schemaCache;
|
|
43
40
|
}
|
|
44
41
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/cli/src/lib/json-schema.ts"],"sourcesContent":["import { Ajv, type ErrorObject } from 'ajv';\nimport * as fs from 'fs';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/cli/src/lib/json-schema.ts"],"sourcesContent":["import { Ajv, type ErrorObject } from 'ajv';\nimport addFormats from 'ajv-formats';\nimport * as fs from 'fs';\nimport moduleRoot from 'module-root-sync';\nimport * as path from 'path';\nimport * as url from 'url';\n\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\nconst packageRoot = moduleRoot(__dirname);\n\nexport const SCHEMA_URL = 'https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json';\n\nlet schemaCache: object | null = null;\n\n/**\n * Get MCP server.json schema (fetches once, then caches)\n *\n * Strategy:\n * 1. Return cached schema if available\n * 2. Try fetching latest schema from URL\n * 3. Fall back to bundled schema if network fails\n */\nexport async function getSchema(): Promise<object> {\n // Return cached schema\n if (schemaCache) {\n return schemaCache;\n }\n\n try {\n // Try fetching latest schema\n const response = await fetch(SCHEMA_URL);\n if (response.ok) {\n schemaCache = (await response.json()) as object;\n return schemaCache;\n }\n } catch {\n // Network error - fall through to bundled version\n }\n\n // Fallback to bundled schema\n const schemaPath = path.join(packageRoot, './schemas/server.schema.json');\n if (!fs.existsSync(schemaPath)) {\n throw new Error('Failed to fetch MCP schema from URL and no bundled schema found. ' + 'Check network connection or report this as a bug.');\n }\n\n schemaCache = JSON.parse(fs.readFileSync(schemaPath, 'utf8')) as object;\n return schemaCache;\n}\n\n/**\n * Validate server.json against MCP schema\n *\n * @param serverJson - Parsed server.json content to validate\n * @param serverName - Server name for error messages\n * @throws Error with detailed validation messages if invalid\n */\nexport async function validateSchema(serverJson: unknown, serverName: string): Promise<void> {\n const schema = await getSchema();\n\n const ajv = new Ajv({\n allErrors: true,\n verbose: true,\n strictSchema: false, // Allow non-standard keywords like \"example\", \"choices\"\n });\n\n // Add format validators (uri, email, etc.) to silence warnings\n addFormats(ajv);\n\n const validate = ajv.compile(schema);\n const valid = validate(serverJson);\n\n if (!valid) {\n const errors = validate.errors?.map((e: ErrorObject) => ` - ${e.instancePath || '(root)'} ${e.message}`).join('\\n') || 'Unknown validation error';\n\n throw new Error(`Invalid server.json for '${serverName}':\\n${errors}\\n\\nThe server.json file does not conform to the MCP specification.\\nSee: https://modelcontextprotocol.io/specification/server\\n\\nTo fix: Update the server.json file to match the schema requirements above.`);\n }\n}\n"],"names":["Ajv","addFormats","fs","moduleRoot","path","url","__dirname","dirname","__filename","fileURLToPath","packageRoot","SCHEMA_URL","schemaCache","getSchema","response","fetch","ok","json","schemaPath","join","existsSync","Error","JSON","parse","readFileSync","validateSchema","serverJson","serverName","schema","ajv","allErrors","verbose","strictSchema","validate","compile","valid","errors","map","e","instancePath","message"],"mappings":"AAAA,SAASA,GAAG,QAA0B,MAAM;AAC5C,OAAOC,gBAAgB,cAAc;AACrC,YAAYC,QAAQ,KAAK;AACzB,OAAOC,gBAAgB,mBAAmB;AAC1C,YAAYC,UAAU,OAAO;AAC7B,YAAYC,SAAS,MAAM;AAE3B,MAAMC,YAAYF,KAAKG,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaH,IAAII,aAAa,CAAC,YAAYJ,GAAG;AACjH,MAAMK,cAAcP,WAAWG;AAE/B,OAAO,MAAMK,aAAa,+EAA+E;AAEzG,IAAIC,cAA6B;AAEjC;;;;;;;CAOC,GACD,OAAO,eAAeC;IACpB,uBAAuB;IACvB,IAAID,aAAa;QACf,OAAOA;IACT;IAEA,IAAI;QACF,6BAA6B;QAC7B,MAAME,WAAW,MAAMC,MAAMJ;QAC7B,IAAIG,SAASE,EAAE,EAAE;YACfJ,cAAe,MAAME,SAASG,IAAI;YAClC,OAAOL;QACT;IACF,EAAE,OAAM;IACN,kDAAkD;IACpD;IAEA,6BAA6B;IAC7B,MAAMM,aAAad,KAAKe,IAAI,CAACT,aAAa;IAC1C,IAAI,CAACR,GAAGkB,UAAU,CAACF,aAAa;QAC9B,MAAM,IAAIG,MAAM,sEAAsE;IACxF;IAEAT,cAAcU,KAAKC,KAAK,CAACrB,GAAGsB,YAAY,CAACN,YAAY;IACrD,OAAON;AACT;AAEA;;;;;;CAMC,GACD,OAAO,eAAea,eAAeC,UAAmB,EAAEC,UAAkB;IAC1E,MAAMC,SAAS,MAAMf;IAErB,MAAMgB,MAAM,IAAI7B,IAAI;QAClB8B,WAAW;QACXC,SAAS;QACTC,cAAc;IAChB;IAEA,+DAA+D;IAC/D/B,WAAW4B;IAEX,MAAMI,WAAWJ,IAAIK,OAAO,CAACN;IAC7B,MAAMO,QAAQF,SAASP;IAEvB,IAAI,CAACS,OAAO;YACKF;QAAf,MAAMG,SAASH,EAAAA,mBAAAA,SAASG,MAAM,cAAfH,uCAAAA,iBAAiBI,GAAG,CAAC,CAACC,IAAmB,CAAC,IAAI,EAAEA,EAAEC,YAAY,IAAI,SAAS,CAAC,EAAED,EAAEE,OAAO,EAAE,EAAErB,IAAI,CAAC,UAAS;QAExH,MAAM,IAAIE,MAAM,CAAC,yBAAyB,EAAEM,WAAW,IAAI,EAAES,OAAO,6MAA6M,CAAC;IACpR;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-z/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "CLI tool for managing MCP server clusters and testing workflows.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -87,7 +87,6 @@
|
|
|
87
87
|
"node-version-use": "^2.1.6",
|
|
88
88
|
"ts-dev-stack": "^1.21.3",
|
|
89
89
|
"tsds-config": "^1.0.0",
|
|
90
|
-
"typescript": "^5.9.3",
|
|
91
90
|
"zod": "^4.0.0"
|
|
92
91
|
},
|
|
93
92
|
"engines": {
|