@mcp-z/cli 1.0.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.
Files changed (126) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +166 -0
  3. package/bin/cli.js +5 -0
  4. package/dist/cjs/cli.d.cts +1 -0
  5. package/dist/cjs/cli.d.ts +1 -0
  6. package/dist/cjs/cli.js +576 -0
  7. package/dist/cjs/cli.js.map +1 -0
  8. package/dist/cjs/commands/call-tool.d.cts +26 -0
  9. package/dist/cjs/commands/call-tool.d.ts +26 -0
  10. package/dist/cjs/commands/call-tool.js +362 -0
  11. package/dist/cjs/commands/call-tool.js.map +1 -0
  12. package/dist/cjs/commands/get-prompt.d.cts +26 -0
  13. package/dist/cjs/commands/get-prompt.d.ts +26 -0
  14. package/dist/cjs/commands/get-prompt.js +335 -0
  15. package/dist/cjs/commands/get-prompt.js.map +1 -0
  16. package/dist/cjs/commands/inspect.d.cts +35 -0
  17. package/dist/cjs/commands/inspect.d.ts +35 -0
  18. package/dist/cjs/commands/inspect.js +896 -0
  19. package/dist/cjs/commands/inspect.js.map +1 -0
  20. package/dist/cjs/commands/manifest/env-prompting.d.cts +21 -0
  21. package/dist/cjs/commands/manifest/env-prompting.d.ts +21 -0
  22. package/dist/cjs/commands/manifest/env-prompting.js +657 -0
  23. package/dist/cjs/commands/manifest/env-prompting.js.map +1 -0
  24. package/dist/cjs/commands/manifest/generate.d.cts +124 -0
  25. package/dist/cjs/commands/manifest/generate.d.ts +124 -0
  26. package/dist/cjs/commands/manifest/generate.js +2541 -0
  27. package/dist/cjs/commands/manifest/generate.js.map +1 -0
  28. package/dist/cjs/commands/manifest/index.d.cts +2 -0
  29. package/dist/cjs/commands/manifest/index.d.ts +2 -0
  30. package/dist/cjs/commands/manifest/index.js +229 -0
  31. package/dist/cjs/commands/manifest/index.js.map +1 -0
  32. package/dist/cjs/commands/manifest/metadata-reader.d.cts +71 -0
  33. package/dist/cjs/commands/manifest/metadata-reader.d.ts +71 -0
  34. package/dist/cjs/commands/manifest/metadata-reader.js +441 -0
  35. package/dist/cjs/commands/manifest/metadata-reader.js.map +1 -0
  36. package/dist/cjs/commands/manifest/validate.d.cts +1 -0
  37. package/dist/cjs/commands/manifest/validate.d.ts +1 -0
  38. package/dist/cjs/commands/manifest/validate.js +525 -0
  39. package/dist/cjs/commands/manifest/validate.js.map +1 -0
  40. package/dist/cjs/commands/read-resource.d.cts +24 -0
  41. package/dist/cjs/commands/read-resource.d.ts +24 -0
  42. package/dist/cjs/commands/read-resource.js +311 -0
  43. package/dist/cjs/commands/read-resource.js.map +1 -0
  44. package/dist/cjs/commands/search.d.cts +31 -0
  45. package/dist/cjs/commands/search.d.ts +31 -0
  46. package/dist/cjs/commands/search.js +464 -0
  47. package/dist/cjs/commands/search.js.map +1 -0
  48. package/dist/cjs/commands/up.d.cts +49 -0
  49. package/dist/cjs/commands/up.d.ts +49 -0
  50. package/dist/cjs/commands/up.js +235 -0
  51. package/dist/cjs/commands/up.js.map +1 -0
  52. package/dist/cjs/index.d.cts +7 -0
  53. package/dist/cjs/index.d.ts +7 -0
  54. package/dist/cjs/index.js +85 -0
  55. package/dist/cjs/index.js.map +1 -0
  56. package/dist/cjs/lib/find-config.d.cts +14 -0
  57. package/dist/cjs/lib/find-config.d.ts +14 -0
  58. package/dist/cjs/lib/find-config.js +93 -0
  59. package/dist/cjs/lib/find-config.js.map +1 -0
  60. package/dist/cjs/lib/json-schema.d.cts +18 -0
  61. package/dist/cjs/lib/json-schema.d.ts +18 -0
  62. package/dist/cjs/lib/json-schema.js +306 -0
  63. package/dist/cjs/lib/json-schema.js.map +1 -0
  64. package/dist/cjs/lib/resolve-server-config.d.cts +50 -0
  65. package/dist/cjs/lib/resolve-server-config.d.ts +50 -0
  66. package/dist/cjs/lib/resolve-server-config.js +214 -0
  67. package/dist/cjs/lib/resolve-server-config.js.map +1 -0
  68. package/dist/cjs/package.json +1 -0
  69. package/dist/cjs/types.d.cts +21 -0
  70. package/dist/cjs/types.d.ts +21 -0
  71. package/dist/cjs/types.js +32 -0
  72. package/dist/cjs/types.js.map +1 -0
  73. package/dist/esm/cli.d.ts +1 -0
  74. package/dist/esm/cli.js +129 -0
  75. package/dist/esm/cli.js.map +1 -0
  76. package/dist/esm/commands/call-tool.d.ts +26 -0
  77. package/dist/esm/commands/call-tool.js +151 -0
  78. package/dist/esm/commands/call-tool.js.map +1 -0
  79. package/dist/esm/commands/get-prompt.d.ts +26 -0
  80. package/dist/esm/commands/get-prompt.js +118 -0
  81. package/dist/esm/commands/get-prompt.js.map +1 -0
  82. package/dist/esm/commands/inspect.d.ts +35 -0
  83. package/dist/esm/commands/inspect.js +438 -0
  84. package/dist/esm/commands/inspect.js.map +1 -0
  85. package/dist/esm/commands/manifest/env-prompting.d.ts +21 -0
  86. package/dist/esm/commands/manifest/env-prompting.js +213 -0
  87. package/dist/esm/commands/manifest/env-prompting.js.map +1 -0
  88. package/dist/esm/commands/manifest/generate.d.ts +124 -0
  89. package/dist/esm/commands/manifest/generate.js +1087 -0
  90. package/dist/esm/commands/manifest/generate.js.map +1 -0
  91. package/dist/esm/commands/manifest/index.d.ts +2 -0
  92. package/dist/esm/commands/manifest/index.js +23 -0
  93. package/dist/esm/commands/manifest/index.js.map +1 -0
  94. package/dist/esm/commands/manifest/metadata-reader.d.ts +71 -0
  95. package/dist/esm/commands/manifest/metadata-reader.js +143 -0
  96. package/dist/esm/commands/manifest/metadata-reader.js.map +1 -0
  97. package/dist/esm/commands/manifest/validate.d.ts +1 -0
  98. package/dist/esm/commands/manifest/validate.js +167 -0
  99. package/dist/esm/commands/manifest/validate.js.map +1 -0
  100. package/dist/esm/commands/read-resource.d.ts +24 -0
  101. package/dist/esm/commands/read-resource.js +95 -0
  102. package/dist/esm/commands/read-resource.js.map +1 -0
  103. package/dist/esm/commands/search.d.ts +31 -0
  104. package/dist/esm/commands/search.js +145 -0
  105. package/dist/esm/commands/search.js.map +1 -0
  106. package/dist/esm/commands/up.d.ts +49 -0
  107. package/dist/esm/commands/up.js +74 -0
  108. package/dist/esm/commands/up.js.map +1 -0
  109. package/dist/esm/index.d.ts +7 -0
  110. package/dist/esm/index.js +11 -0
  111. package/dist/esm/index.js.map +1 -0
  112. package/dist/esm/lib/find-config.d.ts +14 -0
  113. package/dist/esm/lib/find-config.js +42 -0
  114. package/dist/esm/lib/find-config.js.map +1 -0
  115. package/dist/esm/lib/json-schema.d.ts +18 -0
  116. package/dist/esm/lib/json-schema.js +66 -0
  117. package/dist/esm/lib/json-schema.js.map +1 -0
  118. package/dist/esm/lib/resolve-server-config.d.ts +50 -0
  119. package/dist/esm/lib/resolve-server-config.js +154 -0
  120. package/dist/esm/lib/resolve-server-config.js.map +1 -0
  121. package/dist/esm/package.json +1 -0
  122. package/dist/esm/types.d.ts +21 -0
  123. package/dist/esm/types.js +11 -0
  124. package/dist/esm/types.js.map +1 -0
  125. package/package.json +99 -0
  126. package/schemas/server.schema.json +489 -0
@@ -0,0 +1,306 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get SCHEMA_URL () {
13
+ return SCHEMA_URL;
14
+ },
15
+ get getSchema () {
16
+ return getSchema;
17
+ },
18
+ get validateSchema () {
19
+ return validateSchema;
20
+ }
21
+ });
22
+ var _ajv = require("ajv");
23
+ var _fs = /*#__PURE__*/ _interop_require_wildcard(require("fs"));
24
+ var _module = require("module");
25
+ var _path = /*#__PURE__*/ _interop_require_wildcard(require("path"));
26
+ var _url = require("url");
27
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
28
+ try {
29
+ var info = gen[key](arg);
30
+ var value = info.value;
31
+ } catch (error) {
32
+ reject(error);
33
+ return;
34
+ }
35
+ if (info.done) {
36
+ resolve(value);
37
+ } else {
38
+ Promise.resolve(value).then(_next, _throw);
39
+ }
40
+ }
41
+ function _async_to_generator(fn) {
42
+ return function() {
43
+ var self = this, args = arguments;
44
+ return new Promise(function(resolve, reject) {
45
+ var gen = fn.apply(self, args);
46
+ function _next(value) {
47
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
48
+ }
49
+ function _throw(err) {
50
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
51
+ }
52
+ _next(undefined);
53
+ });
54
+ };
55
+ }
56
+ function _getRequireWildcardCache(nodeInterop) {
57
+ if (typeof WeakMap !== "function") return null;
58
+ var cacheBabelInterop = new WeakMap();
59
+ var cacheNodeInterop = new WeakMap();
60
+ return (_getRequireWildcardCache = function(nodeInterop) {
61
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
62
+ })(nodeInterop);
63
+ }
64
+ function _interop_require_wildcard(obj, nodeInterop) {
65
+ if (!nodeInterop && obj && obj.__esModule) {
66
+ return obj;
67
+ }
68
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
69
+ return {
70
+ default: obj
71
+ };
72
+ }
73
+ var cache = _getRequireWildcardCache(nodeInterop);
74
+ if (cache && cache.has(obj)) {
75
+ return cache.get(obj);
76
+ }
77
+ var newObj = {
78
+ __proto__: null
79
+ };
80
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
81
+ for(var key in obj){
82
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
83
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
84
+ if (desc && (desc.get || desc.set)) {
85
+ Object.defineProperty(newObj, key, desc);
86
+ } else {
87
+ newObj[key] = obj[key];
88
+ }
89
+ }
90
+ }
91
+ newObj.default = obj;
92
+ if (cache) {
93
+ cache.set(obj, newObj);
94
+ }
95
+ return newObj;
96
+ }
97
+ function _ts_generator(thisArg, body) {
98
+ var f, y, t, _ = {
99
+ label: 0,
100
+ sent: function() {
101
+ if (t[0] & 1) throw t[1];
102
+ return t[1];
103
+ },
104
+ trys: [],
105
+ ops: []
106
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
107
+ return d(g, "next", {
108
+ value: verb(0)
109
+ }), d(g, "throw", {
110
+ value: verb(1)
111
+ }), d(g, "return", {
112
+ value: verb(2)
113
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
114
+ value: function() {
115
+ return this;
116
+ }
117
+ }), g;
118
+ function verb(n) {
119
+ return function(v) {
120
+ return step([
121
+ n,
122
+ v
123
+ ]);
124
+ };
125
+ }
126
+ function step(op) {
127
+ if (f) throw new TypeError("Generator is already executing.");
128
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
129
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
130
+ if (y = 0, t) op = [
131
+ op[0] & 2,
132
+ t.value
133
+ ];
134
+ switch(op[0]){
135
+ case 0:
136
+ case 1:
137
+ t = op;
138
+ break;
139
+ case 4:
140
+ _.label++;
141
+ return {
142
+ value: op[1],
143
+ done: false
144
+ };
145
+ case 5:
146
+ _.label++;
147
+ y = op[1];
148
+ op = [
149
+ 0
150
+ ];
151
+ continue;
152
+ case 7:
153
+ op = _.ops.pop();
154
+ _.trys.pop();
155
+ continue;
156
+ default:
157
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
158
+ _ = 0;
159
+ continue;
160
+ }
161
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
162
+ _.label = op[1];
163
+ break;
164
+ }
165
+ if (op[0] === 6 && _.label < t[1]) {
166
+ _.label = t[1];
167
+ t = op;
168
+ break;
169
+ }
170
+ if (t && _.label < t[2]) {
171
+ _.label = t[2];
172
+ _.ops.push(op);
173
+ break;
174
+ }
175
+ if (t[2]) _.ops.pop();
176
+ _.trys.pop();
177
+ continue;
178
+ }
179
+ op = body.call(thisArg, _);
180
+ } catch (e) {
181
+ op = [
182
+ 6,
183
+ e
184
+ ];
185
+ y = 0;
186
+ } finally{
187
+ f = t = 0;
188
+ }
189
+ if (op[0] & 5) throw op[1];
190
+ return {
191
+ value: op[0] ? op[1] : void 0,
192
+ done: true
193
+ };
194
+ }
195
+ }
196
+ // ESM-compatible __dirname equivalent
197
+ var __filename1 = (0, _url.fileURLToPath)(require("url").pathToFileURL(__filename).toString());
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 SCHEMA_URL = 'https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json';
203
+ var schemaCache = null;
204
+ function getSchema() {
205
+ return _async_to_generator(function() {
206
+ var response, unused, bundledPath;
207
+ return _ts_generator(this, function(_state) {
208
+ switch(_state.label){
209
+ case 0:
210
+ // Return cached schema
211
+ if (schemaCache) {
212
+ return [
213
+ 2,
214
+ schemaCache
215
+ ];
216
+ }
217
+ _state.label = 1;
218
+ case 1:
219
+ _state.trys.push([
220
+ 1,
221
+ 5,
222
+ ,
223
+ 6
224
+ ]);
225
+ return [
226
+ 4,
227
+ fetch(SCHEMA_URL)
228
+ ];
229
+ case 2:
230
+ response = _state.sent();
231
+ if (!response.ok) return [
232
+ 3,
233
+ 4
234
+ ];
235
+ return [
236
+ 4,
237
+ response.json()
238
+ ];
239
+ case 3:
240
+ schemaCache = _state.sent();
241
+ return [
242
+ 2,
243
+ schemaCache
244
+ ];
245
+ case 4:
246
+ return [
247
+ 3,
248
+ 6
249
+ ];
250
+ case 5:
251
+ unused = _state.sent();
252
+ return [
253
+ 3,
254
+ 6
255
+ ];
256
+ case 6:
257
+ // Fallback to bundled schema
258
+ bundledPath = _path.join(__dirname, '../../schemas/server.schema.json');
259
+ if (!_fs.existsSync(bundledPath)) {
260
+ 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
+ }
262
+ schemaCache = JSON.parse(_fs.readFileSync(bundledPath, 'utf8'));
263
+ return [
264
+ 2,
265
+ schemaCache
266
+ ];
267
+ }
268
+ });
269
+ })();
270
+ }
271
+ function validateSchema(serverJson, serverName) {
272
+ return _async_to_generator(function() {
273
+ var schema, ajv, validate, valid, _validate_errors, errors;
274
+ return _ts_generator(this, function(_state) {
275
+ switch(_state.label){
276
+ case 0:
277
+ return [
278
+ 4,
279
+ getSchema()
280
+ ];
281
+ case 1:
282
+ schema = _state.sent();
283
+ ajv = new _ajv.Ajv({
284
+ allErrors: true,
285
+ verbose: true,
286
+ strictSchema: false
287
+ });
288
+ // Add format validators (uri, email, etc.) to silence warnings
289
+ addFormats(ajv);
290
+ validate = ajv.compile(schema);
291
+ valid = validate(serverJson);
292
+ if (!valid) {
293
+ ;
294
+ errors = ((_validate_errors = validate.errors) === null || _validate_errors === void 0 ? void 0 : _validate_errors.map(function(e) {
295
+ return " - ".concat(e.instancePath || '(root)', " ").concat(e.message);
296
+ }).join('\n')) || 'Unknown validation error';
297
+ throw new Error("Invalid server.json for '".concat(serverName, "':\n").concat(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."));
298
+ }
299
+ return [
300
+ 2
301
+ ];
302
+ }
303
+ });
304
+ })();
305
+ }
306
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +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 { createRequire } from 'module';\nimport * as path from 'path';\nimport { fileURLToPath } from 'url';\n\n// ESM-compatible __dirname equivalent\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Import ajv-formats (CommonJS module - use createRequire for ESM compatibility)\nconst require = createRequire(import.meta.url);\nconst addFormats = require('ajv-formats');\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 bundledPath = path.join(__dirname, '../../schemas/server.schema.json');\n if (!fs.existsSync(bundledPath)) {\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(bundledPath, '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","__filename","fileURLToPath","__dirname","path","dirname","require","createRequire","addFormats","schemaCache","response","bundledPath","fetch","ok","json","join","fs","existsSync","Error","JSON","parse","readFileSync","serverJson","serverName","schema","ajv","validate","valid","errors","Ajv","allErrors","verbose","strictSchema","compile","map","e","instancePath","message"],"mappings":";;;;;;;;;;;QAcaA;eAAAA;;QAYSC;eAAAA;;QAkCAC;eAAAA;;;mBA5DgB;0DAClB;sBACU;4DACR;mBACQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9B,sCAAsC;AACtC,IAAMC,cAAaC,IAAAA,kBAAa,EAAC;AACjC,IAAMC,YAAYC,MAAKC,OAAO,CAACJ;AAE/B,iFAAiF;AACjF,IAAMK,WAAUC,IAAAA,qBAAa,EAAC;AAC9B,IAAMC,aAAaF,SAAQ;AAEpB,IAAMR,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,cAAcP,MAAKW,IAAI,CAACZ,WAAW;oBACzC,IAAI,CAACa,IAAGC,UAAU,CAACN,cAAc;wBAC/B,MAAM,IAAIO,MAAM,sEAAsE;oBACxF;oBAEAT,cAAcU,KAAKC,KAAK,CAACJ,IAAGK,YAAY,CAACV,aAAa;oBACtD;;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/DxB,WAAWiB;oBAELC,WAAWD,IAAIQ,OAAO,CAACT;oBACvBG,QAAQD,SAASJ;oBAEvB,IAAI,CAACK,OAAO;;wBACJC,SAASF,EAAAA,mBAAAA,SAASE,MAAM,cAAfF,uCAAAA,iBAAiBQ,GAAG,CAAC,SAACC;mCAAmB,AAAC,OAAoCA,OAA9BA,EAAEC,YAAY,IAAI,UAAS,KAAa,OAAVD,EAAEE,OAAO;2BAAItB,IAAI,CAAC,UAAS;wBAExH,MAAM,IAAIG,MAAM,AAAC,4BAA4CU,OAAjBL,YAAW,QAAa,OAAPK,QAAO;oBACtE;;;;;;IACF"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * resolve-server-config.ts
3
+ *
4
+ * Shared config resolution for CLI commands.
5
+ * Supports both config file-based and inline server configurations.
6
+ */
7
+ import type { ServersConfig } from '@mcp-z/client';
8
+ import type { ServerConfig } from '../types.js';
9
+ /**
10
+ * Options for inline server configuration.
11
+ */
12
+ export interface InlineConfigOptions {
13
+ /** Server name (optional when inline config provided) */
14
+ server?: string;
15
+ /** Config file path (mutually exclusive with inline options) */
16
+ config?: string;
17
+ /** Stdio run command string (e.g., "npx -y @echo/server") */
18
+ run?: string;
19
+ /** HTTP server URL */
20
+ url?: string;
21
+ /** Full server config as JSON string */
22
+ serverConfig?: string;
23
+ }
24
+ /**
25
+ * Resolved server configuration.
26
+ */
27
+ export interface ResolvedServerConfig {
28
+ /** Server name for display purposes */
29
+ serverName: string;
30
+ /** The server configuration object */
31
+ serverConfig: ServerConfig;
32
+ /** Working directory for the server (cwd for inline, config dir for file) */
33
+ configDir: string;
34
+ /** Full servers config (for HTTP auth flow that needs full config) */
35
+ fullConfig: ServersConfig;
36
+ }
37
+ /**
38
+ * Resolve server configuration from CLI options.
39
+ *
40
+ * Supports three modes:
41
+ * 1. Config file: --config path + server positional
42
+ * 2. Inline stdio: --run "npx server"
43
+ * 3. Inline HTTP: --url "https://..."
44
+ * 4. Full JSON: --server '{"command":"npx",...}'
45
+ *
46
+ * @param opts - CLI options for config resolution
47
+ * @returns Resolved server configuration
48
+ * @throws Error if configuration is invalid
49
+ */
50
+ export declare function resolveServerConfig(opts: InlineConfigOptions): ResolvedServerConfig;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * resolve-server-config.ts
3
+ *
4
+ * Shared config resolution for CLI commands.
5
+ * Supports both config file-based and inline server configurations.
6
+ */
7
+ import type { ServersConfig } from '@mcp-z/client';
8
+ import type { ServerConfig } from '../types.js';
9
+ /**
10
+ * Options for inline server configuration.
11
+ */
12
+ export interface InlineConfigOptions {
13
+ /** Server name (optional when inline config provided) */
14
+ server?: string;
15
+ /** Config file path (mutually exclusive with inline options) */
16
+ config?: string;
17
+ /** Stdio run command string (e.g., "npx -y @echo/server") */
18
+ run?: string;
19
+ /** HTTP server URL */
20
+ url?: string;
21
+ /** Full server config as JSON string */
22
+ serverConfig?: string;
23
+ }
24
+ /**
25
+ * Resolved server configuration.
26
+ */
27
+ export interface ResolvedServerConfig {
28
+ /** Server name for display purposes */
29
+ serverName: string;
30
+ /** The server configuration object */
31
+ serverConfig: ServerConfig;
32
+ /** Working directory for the server (cwd for inline, config dir for file) */
33
+ configDir: string;
34
+ /** Full servers config (for HTTP auth flow that needs full config) */
35
+ fullConfig: ServersConfig;
36
+ }
37
+ /**
38
+ * Resolve server configuration from CLI options.
39
+ *
40
+ * Supports three modes:
41
+ * 1. Config file: --config path + server positional
42
+ * 2. Inline stdio: --run "npx server"
43
+ * 3. Inline HTTP: --url "https://..."
44
+ * 4. Full JSON: --server '{"command":"npx",...}'
45
+ *
46
+ * @param opts - CLI options for config resolution
47
+ * @returns Resolved server configuration
48
+ * @throws Error if configuration is invalid
49
+ */
50
+ export declare function resolveServerConfig(opts: InlineConfigOptions): ResolvedServerConfig;
@@ -0,0 +1,214 @@
1
+ /**
2
+ * resolve-server-config.ts
3
+ *
4
+ * Shared config resolution for CLI commands.
5
+ * Supports both config file-based and inline server configurations.
6
+ */ "use strict";
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ Object.defineProperty(exports, "resolveServerConfig", {
11
+ enumerable: true,
12
+ get: function() {
13
+ return resolveServerConfig;
14
+ }
15
+ });
16
+ var _client = require("@mcp-z/client");
17
+ var _fs = /*#__PURE__*/ _interop_require_wildcard(require("fs"));
18
+ var _path = /*#__PURE__*/ _interop_require_wildcard(require("path"));
19
+ var _findconfigts = require("./find-config.js");
20
+ function _define_property(obj, key, value) {
21
+ if (key in obj) {
22
+ Object.defineProperty(obj, key, {
23
+ value: value,
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true
27
+ });
28
+ } else {
29
+ obj[key] = value;
30
+ }
31
+ return obj;
32
+ }
33
+ function _instanceof(left, right) {
34
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
35
+ return !!right[Symbol.hasInstance](left);
36
+ } else {
37
+ return left instanceof right;
38
+ }
39
+ }
40
+ function _getRequireWildcardCache(nodeInterop) {
41
+ if (typeof WeakMap !== "function") return null;
42
+ var cacheBabelInterop = new WeakMap();
43
+ var cacheNodeInterop = new WeakMap();
44
+ return (_getRequireWildcardCache = function(nodeInterop) {
45
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
46
+ })(nodeInterop);
47
+ }
48
+ function _interop_require_wildcard(obj, nodeInterop) {
49
+ if (!nodeInterop && obj && obj.__esModule) {
50
+ return obj;
51
+ }
52
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
53
+ return {
54
+ default: obj
55
+ };
56
+ }
57
+ var cache = _getRequireWildcardCache(nodeInterop);
58
+ if (cache && cache.has(obj)) {
59
+ return cache.get(obj);
60
+ }
61
+ var newObj = {
62
+ __proto__: null
63
+ };
64
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
65
+ for(var key in obj){
66
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
67
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
68
+ if (desc && (desc.get || desc.set)) {
69
+ Object.defineProperty(newObj, key, desc);
70
+ } else {
71
+ newObj[key] = obj[key];
72
+ }
73
+ }
74
+ }
75
+ newObj.default = obj;
76
+ if (cache) {
77
+ cache.set(obj, newObj);
78
+ }
79
+ return newObj;
80
+ }
81
+ function _type_of(obj) {
82
+ "@swc/helpers - typeof";
83
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
84
+ }
85
+ function resolveServerConfig(opts) {
86
+ // Validate mutual exclusivity of inline options
87
+ var inlineOptions = [
88
+ opts.run,
89
+ opts.url,
90
+ opts.serverConfig
91
+ ].filter(Boolean);
92
+ if (inlineOptions.length > 1) {
93
+ throw new Error('Cannot use multiple inline config options. Use only one of: --run, --url, or --server');
94
+ }
95
+ var hasInlineConfig = inlineOptions.length > 0;
96
+ // Validate mutual exclusivity with config file
97
+ if (hasInlineConfig && opts.config) {
98
+ throw new Error('Cannot use --config with inline config options (--run, --url, --server)');
99
+ }
100
+ // Handle inline configuration
101
+ if (hasInlineConfig) {
102
+ return resolveInlineConfig(opts);
103
+ }
104
+ // Handle config file-based configuration
105
+ return resolveFileConfig(opts);
106
+ }
107
+ /**
108
+ * Resolve inline server configuration.
109
+ */ function resolveInlineConfig(opts) {
110
+ var serverName = opts.server || 'inline';
111
+ var configDir = process.cwd();
112
+ var serverConfig;
113
+ if (opts.run) {
114
+ // Parse run string into command + args (simple helper, no schema validation needed)
115
+ serverConfig = parseRunString(opts.run);
116
+ } else if (opts.url) {
117
+ // Create HTTP server config (simple helper, no schema validation needed)
118
+ serverConfig = {
119
+ type: 'http',
120
+ url: opts.url
121
+ };
122
+ } else if (opts.serverConfig) {
123
+ // Parse full JSON config with schema validation
124
+ serverConfig = parseServerConfigJson(opts.serverConfig, serverName);
125
+ } else {
126
+ throw new Error('No inline config provided');
127
+ }
128
+ // Create a minimal servers config for the resolved server
129
+ var fullConfig = _define_property({}, serverName, serverConfig);
130
+ return {
131
+ serverName: serverName,
132
+ serverConfig: serverConfig,
133
+ configDir: configDir,
134
+ fullConfig: fullConfig
135
+ };
136
+ }
137
+ /**
138
+ * Resolve config file-based server configuration.
139
+ */ function resolveFileConfig(opts) {
140
+ var _ref, _raw_mcpServers;
141
+ if (!opts.server) {
142
+ throw new Error('Server name is required when using config file');
143
+ }
144
+ var cfgPath = (0, _findconfigts.findConfigPath)(opts.config);
145
+ var raw = JSON.parse(_fs.readFileSync(cfgPath, 'utf8'));
146
+ var servers = (_ref = (_raw_mcpServers = raw.mcpServers) !== null && _raw_mcpServers !== void 0 ? _raw_mcpServers : raw.servers) !== null && _ref !== void 0 ? _ref : raw;
147
+ var serverNames = Object.keys(servers || {});
148
+ if (!serverNames.includes(opts.server)) {
149
+ throw new Error("Server '".concat(opts.server, "' not found in config\n\nAvailable servers: ").concat(serverNames.join(', ')));
150
+ }
151
+ var serverConfig = servers[opts.server];
152
+ if (!serverConfig) {
153
+ throw new Error("Server ".concat(opts.server, " not found in config"));
154
+ }
155
+ return {
156
+ serverName: opts.server,
157
+ serverConfig: serverConfig,
158
+ configDir: _path.dirname(cfgPath),
159
+ fullConfig: servers
160
+ };
161
+ }
162
+ /**
163
+ * Parse a run string into a ServerConfigStdio.
164
+ *
165
+ * @example
166
+ * parseRunString("npx -y @echo/server")
167
+ * // => { command: "npx", args: ["-y", "@echo/server"] }
168
+ */ function parseRunString(runStr) {
169
+ var parts = runStr.trim().split(/\s+/);
170
+ if (parts.length === 0 || !parts[0]) {
171
+ throw new Error('Run string cannot be empty');
172
+ }
173
+ return {
174
+ command: parts[0],
175
+ args: parts.slice(1)
176
+ };
177
+ }
178
+ /**
179
+ * Parse and validate a full server config JSON string against the MCP schema.
180
+ *
181
+ * @example
182
+ * parseServerConfigJson('{"command":"npx","args":["-y","@echo/server"]}')
183
+ * parseServerConfigJson('{"url":"https://example.com/mcp","type":"http"}')
184
+ */ function parseServerConfigJson(jsonStr, serverName) {
185
+ var parsed;
186
+ try {
187
+ parsed = JSON.parse(jsonStr);
188
+ } catch (error) {
189
+ throw new Error("Failed to parse server config JSON: ".concat(_instanceof(error, Error) ? error.message : String(error)));
190
+ }
191
+ if ((typeof parsed === "undefined" ? "undefined" : _type_of(parsed)) !== 'object' || parsed === null) {
192
+ throw new Error('Server config must be a JSON object');
193
+ }
194
+ var config = parsed;
195
+ // Validate: must have either 'command' (stdio) or 'url' (http)
196
+ if (!config.command && !config.url) {
197
+ throw new Error('Server config must have either "command" (for stdio) or "url" (for http)');
198
+ }
199
+ // Normalize: if url is present without explicit type, set type to 'http'
200
+ if (config.url && !config.type) {
201
+ config.type = 'http';
202
+ }
203
+ // Validate against the MCP servers schema
204
+ var serversMap = _define_property({}, serverName, config);
205
+ var validation = (0, _client.validateServers)(serversMap);
206
+ if (!validation.valid) {
207
+ var _validation_errors;
208
+ var errorDetails = ((_validation_errors = validation.errors) === null || _validation_errors === void 0 ? void 0 : _validation_errors.join('\n ')) || 'Unknown validation error';
209
+ throw new Error("Invalid server config:\n ".concat(errorDetails));
210
+ }
211
+ // Return as ServerConfig (compatible with McpServerEntry)
212
+ return config;
213
+ }
214
+ /* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/cli/src/lib/resolve-server-config.ts"],"sourcesContent":["/**\n * resolve-server-config.ts\n *\n * Shared config resolution for CLI commands.\n * Supports both config file-based and inline server configurations.\n */\n\nimport type { McpServerEntry, ServersConfig } from '@mcp-z/client';\nimport { validateServers } from '@mcp-z/client';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport type { ServerConfig } from '../types.ts';\nimport { findConfigPath } from './find-config.ts';\n\n/**\n * Options for inline server configuration.\n */\nexport interface InlineConfigOptions {\n /** Server name (optional when inline config provided) */\n server?: string;\n /** Config file path (mutually exclusive with inline options) */\n config?: string;\n /** Stdio run command string (e.g., \"npx -y @echo/server\") */\n run?: string;\n /** HTTP server URL */\n url?: string;\n /** Full server config as JSON string */\n serverConfig?: string;\n}\n\n/**\n * Resolved server configuration.\n */\nexport interface ResolvedServerConfig {\n /** Server name for display purposes */\n serverName: string;\n /** The server configuration object */\n serverConfig: ServerConfig;\n /** Working directory for the server (cwd for inline, config dir for file) */\n configDir: string;\n /** Full servers config (for HTTP auth flow that needs full config) */\n fullConfig: ServersConfig;\n}\n\n/**\n * Resolve server configuration from CLI options.\n *\n * Supports three modes:\n * 1. Config file: --config path + server positional\n * 2. Inline stdio: --run \"npx server\"\n * 3. Inline HTTP: --url \"https://...\"\n * 4. Full JSON: --server '{\"command\":\"npx\",...}'\n *\n * @param opts - CLI options for config resolution\n * @returns Resolved server configuration\n * @throws Error if configuration is invalid\n */\nexport function resolveServerConfig(opts: InlineConfigOptions): ResolvedServerConfig {\n // Validate mutual exclusivity of inline options\n const inlineOptions = [opts.run, opts.url, opts.serverConfig].filter(Boolean);\n if (inlineOptions.length > 1) {\n throw new Error('Cannot use multiple inline config options. Use only one of: --run, --url, or --server');\n }\n\n const hasInlineConfig = inlineOptions.length > 0;\n\n // Validate mutual exclusivity with config file\n if (hasInlineConfig && opts.config) {\n throw new Error('Cannot use --config with inline config options (--run, --url, --server)');\n }\n\n // Handle inline configuration\n if (hasInlineConfig) {\n return resolveInlineConfig(opts);\n }\n\n // Handle config file-based configuration\n return resolveFileConfig(opts);\n}\n\n/**\n * Resolve inline server configuration.\n */\nfunction resolveInlineConfig(opts: InlineConfigOptions): ResolvedServerConfig {\n const serverName = opts.server || 'inline';\n const configDir = process.cwd();\n let serverConfig: ServerConfig;\n\n if (opts.run) {\n // Parse run string into command + args (simple helper, no schema validation needed)\n serverConfig = parseRunString(opts.run);\n } else if (opts.url) {\n // Create HTTP server config (simple helper, no schema validation needed)\n serverConfig = {\n type: 'http',\n url: opts.url,\n };\n } else if (opts.serverConfig) {\n // Parse full JSON config with schema validation\n serverConfig = parseServerConfigJson(opts.serverConfig, serverName);\n } else {\n throw new Error('No inline config provided');\n }\n\n // Create a minimal servers config for the resolved server\n const fullConfig: ServersConfig = {\n [serverName]: serverConfig,\n };\n\n return {\n serverName,\n serverConfig,\n configDir,\n fullConfig,\n };\n}\n\n/**\n * Resolve config file-based server configuration.\n */\nfunction resolveFileConfig(opts: InlineConfigOptions): ResolvedServerConfig {\n if (!opts.server) {\n throw new Error('Server name is required when using config file');\n }\n\n const cfgPath = findConfigPath(opts.config);\n const raw = JSON.parse(fs.readFileSync(cfgPath, 'utf8'));\n const servers: ServersConfig = raw.mcpServers ?? raw.servers ?? raw;\n\n const serverNames = Object.keys(servers || {});\n if (!serverNames.includes(opts.server)) {\n throw new Error(`Server '${opts.server}' not found in config\\n\\nAvailable servers: ${serverNames.join(', ')}`);\n }\n\n const serverConfig = servers[opts.server];\n if (!serverConfig) {\n throw new Error(`Server ${opts.server} not found in config`);\n }\n\n return {\n serverName: opts.server,\n serverConfig: serverConfig as ServerConfig,\n configDir: path.dirname(cfgPath),\n fullConfig: servers,\n };\n}\n\n/**\n * Parse a run string into a ServerConfigStdio.\n *\n * @example\n * parseRunString(\"npx -y @echo/server\")\n * // => { command: \"npx\", args: [\"-y\", \"@echo/server\"] }\n */\nfunction parseRunString(runStr: string): ServerConfig {\n const parts = runStr.trim().split(/\\s+/);\n if (parts.length === 0 || !parts[0]) {\n throw new Error('Run string cannot be empty');\n }\n\n return {\n command: parts[0],\n args: parts.slice(1),\n };\n}\n\n/**\n * Parse and validate a full server config JSON string against the MCP schema.\n *\n * @example\n * parseServerConfigJson('{\"command\":\"npx\",\"args\":[\"-y\",\"@echo/server\"]}')\n * parseServerConfigJson('{\"url\":\"https://example.com/mcp\",\"type\":\"http\"}')\n */\nfunction parseServerConfigJson(jsonStr: string, serverName: string): ServerConfig {\n let parsed: unknown;\n try {\n parsed = JSON.parse(jsonStr);\n } catch (error) {\n throw new Error(`Failed to parse server config JSON: ${error instanceof Error ? error.message : String(error)}`);\n }\n\n if (typeof parsed !== 'object' || parsed === null) {\n throw new Error('Server config must be a JSON object');\n }\n\n const config = parsed as McpServerEntry;\n\n // Validate: must have either 'command' (stdio) or 'url' (http)\n if (!config.command && !config.url) {\n throw new Error('Server config must have either \"command\" (for stdio) or \"url\" (for http)');\n }\n\n // Normalize: if url is present without explicit type, set type to 'http'\n if (config.url && !config.type) {\n config.type = 'http';\n }\n\n // Validate against the MCP servers schema\n const serversMap = { [serverName]: config };\n const validation = validateServers(serversMap);\n if (!validation.valid) {\n const errorDetails = validation.errors?.join('\\n ') || 'Unknown validation error';\n throw new Error(`Invalid server config:\\n ${errorDetails}`);\n }\n\n // Return as ServerConfig (compatible with McpServerEntry)\n return config as ServerConfig;\n}\n"],"names":["resolveServerConfig","opts","inlineOptions","run","url","serverConfig","filter","Boolean","length","Error","hasInlineConfig","config","resolveInlineConfig","resolveFileConfig","serverName","server","configDir","process","cwd","parseRunString","type","parseServerConfigJson","fullConfig","raw","cfgPath","findConfigPath","JSON","parse","fs","readFileSync","servers","mcpServers","serverNames","Object","keys","includes","join","path","dirname","runStr","parts","trim","split","command","args","slice","jsonStr","parsed","error","message","String","serversMap","validation","validateServers","valid","errorDetails","errors"],"mappings":"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"}
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
@@ -0,0 +1,21 @@
1
+ export interface MCPConfiguration {
2
+ mcpServers: Record<string, ServerConfig>;
3
+ }
4
+ export interface ServerConfigStdio {
5
+ type?: 'stdio';
6
+ command: string;
7
+ args?: string[];
8
+ env?: Record<string, string>;
9
+ }
10
+ export interface ServerConfigHttp {
11
+ type: 'http';
12
+ url: string;
13
+ headers?: Record<string, string>;
14
+ start?: ServerConfigStdio;
15
+ }
16
+ export type ServerConfig = ServerConfigStdio | ServerConfigHttp;
17
+ export declare function isHttpServer(config: ServerConfig): config is ServerConfigHttp;
18
+ export declare function isStdioServer(config: ServerConfig): config is ServerConfigStdio;
19
+ export declare function hasStartBlock(config: ServerConfig): config is ServerConfigHttp & {
20
+ start: ServerConfigStdio;
21
+ };