@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.
- package/LICENSE +21 -0
- package/README.md +166 -0
- package/bin/cli.js +5 -0
- package/dist/cjs/cli.d.cts +1 -0
- package/dist/cjs/cli.d.ts +1 -0
- package/dist/cjs/cli.js +576 -0
- package/dist/cjs/cli.js.map +1 -0
- package/dist/cjs/commands/call-tool.d.cts +26 -0
- package/dist/cjs/commands/call-tool.d.ts +26 -0
- package/dist/cjs/commands/call-tool.js +362 -0
- package/dist/cjs/commands/call-tool.js.map +1 -0
- package/dist/cjs/commands/get-prompt.d.cts +26 -0
- package/dist/cjs/commands/get-prompt.d.ts +26 -0
- package/dist/cjs/commands/get-prompt.js +335 -0
- package/dist/cjs/commands/get-prompt.js.map +1 -0
- package/dist/cjs/commands/inspect.d.cts +35 -0
- package/dist/cjs/commands/inspect.d.ts +35 -0
- package/dist/cjs/commands/inspect.js +896 -0
- package/dist/cjs/commands/inspect.js.map +1 -0
- package/dist/cjs/commands/manifest/env-prompting.d.cts +21 -0
- package/dist/cjs/commands/manifest/env-prompting.d.ts +21 -0
- package/dist/cjs/commands/manifest/env-prompting.js +657 -0
- package/dist/cjs/commands/manifest/env-prompting.js.map +1 -0
- package/dist/cjs/commands/manifest/generate.d.cts +124 -0
- package/dist/cjs/commands/manifest/generate.d.ts +124 -0
- package/dist/cjs/commands/manifest/generate.js +2541 -0
- package/dist/cjs/commands/manifest/generate.js.map +1 -0
- package/dist/cjs/commands/manifest/index.d.cts +2 -0
- package/dist/cjs/commands/manifest/index.d.ts +2 -0
- package/dist/cjs/commands/manifest/index.js +229 -0
- package/dist/cjs/commands/manifest/index.js.map +1 -0
- package/dist/cjs/commands/manifest/metadata-reader.d.cts +71 -0
- package/dist/cjs/commands/manifest/metadata-reader.d.ts +71 -0
- package/dist/cjs/commands/manifest/metadata-reader.js +441 -0
- package/dist/cjs/commands/manifest/metadata-reader.js.map +1 -0
- package/dist/cjs/commands/manifest/validate.d.cts +1 -0
- package/dist/cjs/commands/manifest/validate.d.ts +1 -0
- package/dist/cjs/commands/manifest/validate.js +525 -0
- package/dist/cjs/commands/manifest/validate.js.map +1 -0
- package/dist/cjs/commands/read-resource.d.cts +24 -0
- package/dist/cjs/commands/read-resource.d.ts +24 -0
- package/dist/cjs/commands/read-resource.js +311 -0
- package/dist/cjs/commands/read-resource.js.map +1 -0
- package/dist/cjs/commands/search.d.cts +31 -0
- package/dist/cjs/commands/search.d.ts +31 -0
- package/dist/cjs/commands/search.js +464 -0
- package/dist/cjs/commands/search.js.map +1 -0
- package/dist/cjs/commands/up.d.cts +49 -0
- package/dist/cjs/commands/up.d.ts +49 -0
- package/dist/cjs/commands/up.js +235 -0
- package/dist/cjs/commands/up.js.map +1 -0
- package/dist/cjs/index.d.cts +7 -0
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.js +85 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/find-config.d.cts +14 -0
- package/dist/cjs/lib/find-config.d.ts +14 -0
- package/dist/cjs/lib/find-config.js +93 -0
- package/dist/cjs/lib/find-config.js.map +1 -0
- package/dist/cjs/lib/json-schema.d.cts +18 -0
- package/dist/cjs/lib/json-schema.d.ts +18 -0
- package/dist/cjs/lib/json-schema.js +306 -0
- package/dist/cjs/lib/json-schema.js.map +1 -0
- package/dist/cjs/lib/resolve-server-config.d.cts +50 -0
- package/dist/cjs/lib/resolve-server-config.d.ts +50 -0
- package/dist/cjs/lib/resolve-server-config.js +214 -0
- package/dist/cjs/lib/resolve-server-config.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types.d.cts +21 -0
- package/dist/cjs/types.d.ts +21 -0
- package/dist/cjs/types.js +32 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/cli.d.ts +1 -0
- package/dist/esm/cli.js +129 -0
- package/dist/esm/cli.js.map +1 -0
- package/dist/esm/commands/call-tool.d.ts +26 -0
- package/dist/esm/commands/call-tool.js +151 -0
- package/dist/esm/commands/call-tool.js.map +1 -0
- package/dist/esm/commands/get-prompt.d.ts +26 -0
- package/dist/esm/commands/get-prompt.js +118 -0
- package/dist/esm/commands/get-prompt.js.map +1 -0
- package/dist/esm/commands/inspect.d.ts +35 -0
- package/dist/esm/commands/inspect.js +438 -0
- package/dist/esm/commands/inspect.js.map +1 -0
- package/dist/esm/commands/manifest/env-prompting.d.ts +21 -0
- package/dist/esm/commands/manifest/env-prompting.js +213 -0
- package/dist/esm/commands/manifest/env-prompting.js.map +1 -0
- package/dist/esm/commands/manifest/generate.d.ts +124 -0
- package/dist/esm/commands/manifest/generate.js +1087 -0
- package/dist/esm/commands/manifest/generate.js.map +1 -0
- package/dist/esm/commands/manifest/index.d.ts +2 -0
- package/dist/esm/commands/manifest/index.js +23 -0
- package/dist/esm/commands/manifest/index.js.map +1 -0
- package/dist/esm/commands/manifest/metadata-reader.d.ts +71 -0
- package/dist/esm/commands/manifest/metadata-reader.js +143 -0
- package/dist/esm/commands/manifest/metadata-reader.js.map +1 -0
- package/dist/esm/commands/manifest/validate.d.ts +1 -0
- package/dist/esm/commands/manifest/validate.js +167 -0
- package/dist/esm/commands/manifest/validate.js.map +1 -0
- package/dist/esm/commands/read-resource.d.ts +24 -0
- package/dist/esm/commands/read-resource.js +95 -0
- package/dist/esm/commands/read-resource.js.map +1 -0
- package/dist/esm/commands/search.d.ts +31 -0
- package/dist/esm/commands/search.js +145 -0
- package/dist/esm/commands/search.js.map +1 -0
- package/dist/esm/commands/up.d.ts +49 -0
- package/dist/esm/commands/up.js +74 -0
- package/dist/esm/commands/up.js.map +1 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/find-config.d.ts +14 -0
- package/dist/esm/lib/find-config.js +42 -0
- package/dist/esm/lib/find-config.js.map +1 -0
- package/dist/esm/lib/json-schema.d.ts +18 -0
- package/dist/esm/lib/json-schema.js +66 -0
- package/dist/esm/lib/json-schema.js.map +1 -0
- package/dist/esm/lib/resolve-server-config.d.ts +50 -0
- package/dist/esm/lib/resolve-server-config.js +154 -0
- package/dist/esm/lib/resolve-server-config.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/types.d.ts +21 -0
- package/dist/esm/types.js +11 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +99 -0
- package/schemas/server.schema.json +489 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "upCommand", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return upCommand;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _client = require("@mcp-z/client");
|
|
12
|
+
var _fs = /*#__PURE__*/ _interop_require_wildcard(require("fs"));
|
|
13
|
+
var _path = /*#__PURE__*/ _interop_require_wildcard(require("path"));
|
|
14
|
+
var _findconfigts = require("../lib/find-config.js");
|
|
15
|
+
var _typests = require("../types.js");
|
|
16
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
17
|
+
try {
|
|
18
|
+
var info = gen[key](arg);
|
|
19
|
+
var value = info.value;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
reject(error);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (info.done) {
|
|
25
|
+
resolve(value);
|
|
26
|
+
} else {
|
|
27
|
+
Promise.resolve(value).then(_next, _throw);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function _async_to_generator(fn) {
|
|
31
|
+
return function() {
|
|
32
|
+
var self = this, args = arguments;
|
|
33
|
+
return new Promise(function(resolve, reject) {
|
|
34
|
+
var gen = fn.apply(self, args);
|
|
35
|
+
function _next(value) {
|
|
36
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
37
|
+
}
|
|
38
|
+
function _throw(err) {
|
|
39
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
40
|
+
}
|
|
41
|
+
_next(undefined);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
46
|
+
if (typeof WeakMap !== "function") return null;
|
|
47
|
+
var cacheBabelInterop = new WeakMap();
|
|
48
|
+
var cacheNodeInterop = new WeakMap();
|
|
49
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
50
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
51
|
+
})(nodeInterop);
|
|
52
|
+
}
|
|
53
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
54
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
55
|
+
return obj;
|
|
56
|
+
}
|
|
57
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
58
|
+
return {
|
|
59
|
+
default: obj
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
63
|
+
if (cache && cache.has(obj)) {
|
|
64
|
+
return cache.get(obj);
|
|
65
|
+
}
|
|
66
|
+
var newObj = {
|
|
67
|
+
__proto__: null
|
|
68
|
+
};
|
|
69
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
70
|
+
for(var key in obj){
|
|
71
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
72
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
73
|
+
if (desc && (desc.get || desc.set)) {
|
|
74
|
+
Object.defineProperty(newObj, key, desc);
|
|
75
|
+
} else {
|
|
76
|
+
newObj[key] = obj[key];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
newObj.default = obj;
|
|
81
|
+
if (cache) {
|
|
82
|
+
cache.set(obj, newObj);
|
|
83
|
+
}
|
|
84
|
+
return newObj;
|
|
85
|
+
}
|
|
86
|
+
function _ts_generator(thisArg, body) {
|
|
87
|
+
var f, y, t, _ = {
|
|
88
|
+
label: 0,
|
|
89
|
+
sent: function() {
|
|
90
|
+
if (t[0] & 1) throw t[1];
|
|
91
|
+
return t[1];
|
|
92
|
+
},
|
|
93
|
+
trys: [],
|
|
94
|
+
ops: []
|
|
95
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
96
|
+
return d(g, "next", {
|
|
97
|
+
value: verb(0)
|
|
98
|
+
}), d(g, "throw", {
|
|
99
|
+
value: verb(1)
|
|
100
|
+
}), d(g, "return", {
|
|
101
|
+
value: verb(2)
|
|
102
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
103
|
+
value: function() {
|
|
104
|
+
return this;
|
|
105
|
+
}
|
|
106
|
+
}), g;
|
|
107
|
+
function verb(n) {
|
|
108
|
+
return function(v) {
|
|
109
|
+
return step([
|
|
110
|
+
n,
|
|
111
|
+
v
|
|
112
|
+
]);
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
function step(op) {
|
|
116
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
117
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
118
|
+
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;
|
|
119
|
+
if (y = 0, t) op = [
|
|
120
|
+
op[0] & 2,
|
|
121
|
+
t.value
|
|
122
|
+
];
|
|
123
|
+
switch(op[0]){
|
|
124
|
+
case 0:
|
|
125
|
+
case 1:
|
|
126
|
+
t = op;
|
|
127
|
+
break;
|
|
128
|
+
case 4:
|
|
129
|
+
_.label++;
|
|
130
|
+
return {
|
|
131
|
+
value: op[1],
|
|
132
|
+
done: false
|
|
133
|
+
};
|
|
134
|
+
case 5:
|
|
135
|
+
_.label++;
|
|
136
|
+
y = op[1];
|
|
137
|
+
op = [
|
|
138
|
+
0
|
|
139
|
+
];
|
|
140
|
+
continue;
|
|
141
|
+
case 7:
|
|
142
|
+
op = _.ops.pop();
|
|
143
|
+
_.trys.pop();
|
|
144
|
+
continue;
|
|
145
|
+
default:
|
|
146
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
147
|
+
_ = 0;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
151
|
+
_.label = op[1];
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
155
|
+
_.label = t[1];
|
|
156
|
+
t = op;
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
if (t && _.label < t[2]) {
|
|
160
|
+
_.label = t[2];
|
|
161
|
+
_.ops.push(op);
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
if (t[2]) _.ops.pop();
|
|
165
|
+
_.trys.pop();
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
op = body.call(thisArg, _);
|
|
169
|
+
} catch (e) {
|
|
170
|
+
op = [
|
|
171
|
+
6,
|
|
172
|
+
e
|
|
173
|
+
];
|
|
174
|
+
y = 0;
|
|
175
|
+
} finally{
|
|
176
|
+
f = t = 0;
|
|
177
|
+
}
|
|
178
|
+
if (op[0] & 5) throw op[1];
|
|
179
|
+
return {
|
|
180
|
+
value: op[0] ? op[1] : void 0,
|
|
181
|
+
done: true
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function upCommand() {
|
|
186
|
+
return _async_to_generator(function() {
|
|
187
|
+
var opts, _ref, _raw_mcpServers, configPath, raw, servers, configDir, dialects, hasStartBlocks;
|
|
188
|
+
var _arguments = arguments;
|
|
189
|
+
return _ts_generator(this, function(_state) {
|
|
190
|
+
opts = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {};
|
|
191
|
+
configPath = (0, _findconfigts.findConfigPath)(opts.config);
|
|
192
|
+
raw = JSON.parse(_fs.readFileSync(configPath, 'utf8'));
|
|
193
|
+
servers = (_ref = (_raw_mcpServers = raw.mcpServers) !== null && _raw_mcpServers !== void 0 ? _raw_mcpServers : raw.servers) !== null && _ref !== void 0 ? _ref : raw;
|
|
194
|
+
configDir = _path.dirname(configPath);
|
|
195
|
+
// Determine dialects based on flags
|
|
196
|
+
// Default is ['servers', 'start'] (spawns everything)
|
|
197
|
+
dialects = [
|
|
198
|
+
'servers',
|
|
199
|
+
'start'
|
|
200
|
+
];
|
|
201
|
+
if (opts.stdioOnly) {
|
|
202
|
+
dialects = [
|
|
203
|
+
'servers'
|
|
204
|
+
];
|
|
205
|
+
} else if (opts.httpOnly) {
|
|
206
|
+
dialects = [
|
|
207
|
+
'start'
|
|
208
|
+
];
|
|
209
|
+
// In http-only mode, check if there are any servers with start blocks
|
|
210
|
+
hasStartBlocks = Object.values(servers || {}).some(function(entry) {
|
|
211
|
+
return entry && (0, _typests.hasStartBlock)(entry);
|
|
212
|
+
});
|
|
213
|
+
if (!hasStartBlocks) {
|
|
214
|
+
console.log(' No HTTP servers found with start configuration');
|
|
215
|
+
console.log(' (stdio servers are spawned automatically by Claude Code)');
|
|
216
|
+
// Return empty registry
|
|
217
|
+
return [
|
|
218
|
+
2,
|
|
219
|
+
(0, _client.createServerRegistry)({}, {
|
|
220
|
+
cwd: configDir
|
|
221
|
+
})
|
|
222
|
+
];
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return [
|
|
226
|
+
2,
|
|
227
|
+
(0, _client.createServerRegistry)(servers, {
|
|
228
|
+
cwd: configDir,
|
|
229
|
+
dialects: dialects
|
|
230
|
+
})
|
|
231
|
+
];
|
|
232
|
+
});
|
|
233
|
+
}).apply(this, arguments);
|
|
234
|
+
}
|
|
235
|
+
/* 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/commands/up.ts"],"sourcesContent":["import { createServerRegistry, type Dialect, type ServerRegistry } from '@mcp-z/client';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport { findConfigPath } from '../lib/find-config.ts';\nimport { hasStartBlock, type ServerConfig } from '../types.ts';\n\n/**\n * Configuration options for the upCommand function\n * @public\n */\nexport interface UpOptions {\n /** Optional path to custom .mcp.json configuration file */\n config?: string;\n /** Start only stdio servers (Claude Code compatible mode) */\n stdioOnly?: boolean;\n /** Start only HTTP servers with start blocks (for Claude Code Desktop) */\n httpOnly?: boolean;\n}\n\n/**\n * MCP server configuration entry per MCP specification.\n *\n * Supports two transport types:\n * - stdio (default if no type): spawned process with stdin/stdout\n * - http: remote HTTP server\n *\n * Transport can be inferred from URL protocol:\n * - http:// or https:// → http\n *\n * @see https://modelcontextprotocol.io/specification/2025-06-18/basic/transports\n */\n\n/**\n * Start a cluster of MCP servers from a configuration file or object.\n *\n * @param opts - Configuration options\n * @param opts.config - Optional path to custom .mcp.json file\n * @returns ServerRegistry with servers map, config, connect method, and close function\n *\n * @example\n * // Auto-discover .mcp.json in current directory\n * const registry = await upCommand();\n *\n * @example\n * // Load from specific config\n * const registry = await upCommand({ config: '/path/to/.mcp.json' });\n *\n * @example\n * // Use in-memory config\n * const registry = await upCommand({\n * mcpServers: {\n * 'echo-stdio': { command: 'node', args: ['test/lib/servers/echo-stdio.ts'] }\n * }\n * });\n */\nexport async function upCommand(opts: UpOptions = {}): Promise<ServerRegistry> {\n const configPath = findConfigPath(opts.config);\n const raw = JSON.parse(fs.readFileSync(configPath, 'utf8'));\n const servers = raw.mcpServers ?? raw.servers ?? raw;\n const configDir = path.dirname(configPath);\n\n // Determine dialects based on flags\n // Default is ['servers', 'start'] (spawns everything)\n let dialects: Dialect[] = ['servers', 'start'];\n if (opts.stdioOnly) {\n dialects = ['servers'];\n } else if (opts.httpOnly) {\n dialects = ['start'];\n // In http-only mode, check if there are any servers with start blocks\n const hasStartBlocks = Object.values(servers || {}).some((entry) => entry && hasStartBlock(entry as ServerConfig));\n if (!hasStartBlocks) {\n console.log(' No HTTP servers found with start configuration');\n console.log(' (stdio servers are spawned automatically by Claude Code)');\n // Return empty registry\n return createServerRegistry({}, { cwd: configDir });\n }\n }\n\n return createServerRegistry(servers, {\n cwd: configDir,\n dialects,\n });\n}\n"],"names":["upCommand","opts","raw","configPath","servers","configDir","dialects","hasStartBlocks","findConfigPath","config","JSON","parse","fs","readFileSync","mcpServers","path","dirname","stdioOnly","httpOnly","Object","values","some","entry","hasStartBlock","console","log","createServerRegistry","cwd"],"mappings":";;;;+BAuDsBA;;;eAAAA;;;sBAvDkD;0DACpD;4DACE;4BACS;uBACkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmD1C,SAAeA;;YAAUC,MAGdC,MAAAA,iBAFVC,YACAD,KACAE,SACAC,WAIFC,UAMIC;;;YAdsBN,OAAAA,oEAAkB,CAAC;YAC3CE,aAAaK,IAAAA,4BAAc,EAACP,KAAKQ,MAAM;YACvCP,MAAMQ,KAAKC,KAAK,CAACC,IAAGC,YAAY,CAACV,YAAY;YAC7CC,WAAUF,QAAAA,kBAAAA,IAAIY,UAAU,cAAdZ,6BAAAA,kBAAkBA,IAAIE,OAAO,cAA7BF,kBAAAA,OAAiCA;YAC3CG,YAAYU,MAAKC,OAAO,CAACb;YAE/B,oCAAoC;YACpC,sDAAsD;YAClDG;gBAAuB;gBAAW;;YACtC,IAAIL,KAAKgB,SAAS,EAAE;gBAClBX;oBAAY;;YACd,OAAO,IAAIL,KAAKiB,QAAQ,EAAE;gBACxBZ;oBAAY;;gBACZ,sEAAsE;gBAChEC,iBAAiBY,OAAOC,MAAM,CAAChB,WAAW,CAAC,GAAGiB,IAAI,CAAC,SAACC;2BAAUA,SAASC,IAAAA,sBAAa,EAACD;;gBAC3F,IAAI,CAACf,gBAAgB;oBACnBiB,QAAQC,GAAG,CAAC;oBACZD,QAAQC,GAAG,CAAC;oBACZ,wBAAwB;oBACxB;;wBAAOC,IAAAA,4BAAoB,EAAC,CAAC,GAAG;4BAAEC,KAAKtB;wBAAU;;gBACnD;YACF;YAEA;;gBAAOqB,IAAAA,4BAAoB,EAACtB,SAAS;oBACnCuB,KAAKtB;oBACLC,UAAAA;gBACF;;;IACF"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
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
|
+
export { type CliArgMetadata, type EnvVarMetadata, MetadataReader, type ServerMetadata } from './commands/manifest/metadata-reader.js';
|
|
3
|
+
export { validateCommand } from './commands/manifest/validate.js';
|
|
4
|
+
export { upCommand } from './commands/up.js';
|
|
5
|
+
export { getSchema, SCHEMA_URL, validateSchema } from './lib/json-schema.js';
|
|
6
|
+
export { type InlineConfigOptions, type ResolvedServerConfig, resolveServerConfig } from './lib/resolve-server-config.js';
|
|
7
|
+
export * from './types.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
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
|
+
export { type CliArgMetadata, type EnvVarMetadata, MetadataReader, type ServerMetadata } from './commands/manifest/metadata-reader.js';
|
|
3
|
+
export { validateCommand } from './commands/manifest/validate.js';
|
|
4
|
+
export { upCommand } from './commands/up.js';
|
|
5
|
+
export { getSchema, SCHEMA_URL, validateSchema } from './lib/json-schema.js';
|
|
6
|
+
export { type InlineConfigOptions, type ResolvedServerConfig, resolveServerConfig } from './lib/resolve-server-config.js';
|
|
7
|
+
export * from './types.js';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Base types and type guards
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
function _export(target, all) {
|
|
7
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
get MetadataReader () {
|
|
14
|
+
return _metadatareaderts.MetadataReader;
|
|
15
|
+
},
|
|
16
|
+
get SCHEMA_URL () {
|
|
17
|
+
return _jsonschemats.SCHEMA_URL;
|
|
18
|
+
},
|
|
19
|
+
get TRANSPORT_MAP () {
|
|
20
|
+
return _generatets.TRANSPORT_MAP;
|
|
21
|
+
},
|
|
22
|
+
get createConfigChoices () {
|
|
23
|
+
return _generatets.createConfigChoices;
|
|
24
|
+
},
|
|
25
|
+
get discoverServerJson () {
|
|
26
|
+
return _generatets.discoverServerJson;
|
|
27
|
+
},
|
|
28
|
+
get extractServerName () {
|
|
29
|
+
return _generatets.extractServerName;
|
|
30
|
+
},
|
|
31
|
+
get filterConfigChoices () {
|
|
32
|
+
return _generatets.filterConfigChoices;
|
|
33
|
+
},
|
|
34
|
+
get generateConditionalCombinations () {
|
|
35
|
+
return _generatets.generateConditionalCombinations;
|
|
36
|
+
},
|
|
37
|
+
get generateConfigFile () {
|
|
38
|
+
return _generatets.generateConfigFile;
|
|
39
|
+
},
|
|
40
|
+
get generateConfigObject () {
|
|
41
|
+
return _generatets.generateConfigObject;
|
|
42
|
+
},
|
|
43
|
+
get generateMatrixCombinations () {
|
|
44
|
+
return _generatets.generateMatrixCombinations;
|
|
45
|
+
},
|
|
46
|
+
get getSchema () {
|
|
47
|
+
return _jsonschemats.getSchema;
|
|
48
|
+
},
|
|
49
|
+
get resolveServerConfig () {
|
|
50
|
+
return _resolveserverconfigts.resolveServerConfig;
|
|
51
|
+
},
|
|
52
|
+
get shouldPromptEnvVar () {
|
|
53
|
+
return _generatets.shouldPromptEnvVar;
|
|
54
|
+
},
|
|
55
|
+
get upCommand () {
|
|
56
|
+
return _upts.upCommand;
|
|
57
|
+
},
|
|
58
|
+
get validateCommand () {
|
|
59
|
+
return _validatets.validateCommand;
|
|
60
|
+
},
|
|
61
|
+
get validateSchema () {
|
|
62
|
+
return _jsonschemats.validateSchema;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
var _generatets = require("./commands/manifest/generate.js");
|
|
66
|
+
var _metadatareaderts = require("./commands/manifest/metadata-reader.js");
|
|
67
|
+
var _validatets = require("./commands/manifest/validate.js");
|
|
68
|
+
var _upts = require("./commands/up.js");
|
|
69
|
+
var _jsonschemats = require("./lib/json-schema.js");
|
|
70
|
+
var _resolveserverconfigts = require("./lib/resolve-server-config.js");
|
|
71
|
+
_export_star(require("./types.js"), exports);
|
|
72
|
+
function _export_star(from, to) {
|
|
73
|
+
Object.keys(from).forEach(function(k) {
|
|
74
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
75
|
+
Object.defineProperty(to, k, {
|
|
76
|
+
enumerable: true,
|
|
77
|
+
get: function() {
|
|
78
|
+
return from[k];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return from;
|
|
84
|
+
}
|
|
85
|
+
/* 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/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\n// Manifest commands\nexport { validateCommand } from './commands/manifest/validate.ts';\n// Commands\nexport { upCommand } from './commands/up.ts';\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","createConfigChoices","discoverServerJson","extractServerName","filterConfigChoices","generateConditionalCombinations","generateConfigFile","generateConfigObject","generateMatrixCombinations","getSchema","resolveServerConfig","shouldPromptEnvVar","upCommand","validateCommand","validateSchema"],"mappings":"AAAA,6BAA6B;;;;;;;;;;;;QAkBsBA;eAAAA,gCAAc;;QAO7CC;eAAAA,wBAAU;;QAT5BC;eAAAA,yBAAa;;QAVbC;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;;QAWnBC;eAAAA,uBAAS;;QAC4CC;eAAAA,0CAAmB;;QAX/EC;eAAAA,8BAAkB;;QAQXC;eAAAA,eAAS;;QAFTC;eAAAA,2BAAe;;QAIQC;eAAAA,4BAAc;;;0BARvC;gCACuF;0BAG9D;oBAEN;4BAE4B;qCACmC;qBAC3E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* find-config.ts
|
|
3
|
+
*
|
|
4
|
+
* Find .mcp.json config file by searching up the directory tree.
|
|
5
|
+
* Searches from cwd up to home directory (like Claude Code).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Find .mcp.json by searching up directory tree from cwd to home directory.
|
|
9
|
+
*
|
|
10
|
+
* @param explicitPath - If provided, validates and returns this path (for --config flag)
|
|
11
|
+
* @returns The resolved path to the config file
|
|
12
|
+
* @throws Error if config file not found
|
|
13
|
+
*/
|
|
14
|
+
export declare function findConfigPath(explicitPath?: string): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* find-config.ts
|
|
3
|
+
*
|
|
4
|
+
* Find .mcp.json config file by searching up the directory tree.
|
|
5
|
+
* Searches from cwd up to home directory (like Claude Code).
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Find .mcp.json by searching up directory tree from cwd to home directory.
|
|
9
|
+
*
|
|
10
|
+
* @param explicitPath - If provided, validates and returns this path (for --config flag)
|
|
11
|
+
* @returns The resolved path to the config file
|
|
12
|
+
* @throws Error if config file not found
|
|
13
|
+
*/
|
|
14
|
+
export declare function findConfigPath(explicitPath?: string): string;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* find-config.ts
|
|
3
|
+
*
|
|
4
|
+
* Find .mcp.json config file by searching up the directory tree.
|
|
5
|
+
* Searches from cwd up to home directory (like Claude Code).
|
|
6
|
+
*/ "use strict";
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
Object.defineProperty(exports, "findConfigPath", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function() {
|
|
13
|
+
return findConfigPath;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
var _fs = /*#__PURE__*/ _interop_require_wildcard(require("fs"));
|
|
17
|
+
var _modulerootsync = /*#__PURE__*/ _interop_require_default(require("module-root-sync"));
|
|
18
|
+
var _os = /*#__PURE__*/ _interop_require_wildcard(require("os"));
|
|
19
|
+
var _path = /*#__PURE__*/ _interop_require_wildcard(require("path"));
|
|
20
|
+
function _interop_require_default(obj) {
|
|
21
|
+
return obj && obj.__esModule ? obj : {
|
|
22
|
+
default: obj
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
26
|
+
if (typeof WeakMap !== "function") return null;
|
|
27
|
+
var cacheBabelInterop = new WeakMap();
|
|
28
|
+
var cacheNodeInterop = new WeakMap();
|
|
29
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
30
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
31
|
+
})(nodeInterop);
|
|
32
|
+
}
|
|
33
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
34
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
35
|
+
return obj;
|
|
36
|
+
}
|
|
37
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
38
|
+
return {
|
|
39
|
+
default: obj
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
43
|
+
if (cache && cache.has(obj)) {
|
|
44
|
+
return cache.get(obj);
|
|
45
|
+
}
|
|
46
|
+
var newObj = {
|
|
47
|
+
__proto__: null
|
|
48
|
+
};
|
|
49
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
50
|
+
for(var key in obj){
|
|
51
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
52
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
53
|
+
if (desc && (desc.get || desc.set)) {
|
|
54
|
+
Object.defineProperty(newObj, key, desc);
|
|
55
|
+
} else {
|
|
56
|
+
newObj[key] = obj[key];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
newObj.default = obj;
|
|
61
|
+
if (cache) {
|
|
62
|
+
cache.set(obj, newObj);
|
|
63
|
+
}
|
|
64
|
+
return newObj;
|
|
65
|
+
}
|
|
66
|
+
var CONFIG_NAME = '.mcp.json';
|
|
67
|
+
function findConfigPath(explicitPath) {
|
|
68
|
+
// If explicit path provided, validate it exists
|
|
69
|
+
if (explicitPath) {
|
|
70
|
+
var resolvedPath = _path.resolve(explicitPath);
|
|
71
|
+
if (!_fs.existsSync(resolvedPath)) {
|
|
72
|
+
throw new Error("Config file not found: ".concat(resolvedPath));
|
|
73
|
+
}
|
|
74
|
+
return resolvedPath;
|
|
75
|
+
}
|
|
76
|
+
var cwd = process.cwd();
|
|
77
|
+
var homeDir = _os.homedir();
|
|
78
|
+
// Use module-root-sync with custom file name to search up
|
|
79
|
+
try {
|
|
80
|
+
var configDir = (0, _modulerootsync.default)(cwd, {
|
|
81
|
+
name: CONFIG_NAME
|
|
82
|
+
});
|
|
83
|
+
var configPath = _path.join(configDir, CONFIG_NAME);
|
|
84
|
+
// Ensure we haven't gone above home directory
|
|
85
|
+
if (!configPath.startsWith(homeDir)) {
|
|
86
|
+
throw new Error("Config file not found in directory tree (searched from ".concat(cwd, " to ").concat(homeDir, ")"));
|
|
87
|
+
}
|
|
88
|
+
return configPath;
|
|
89
|
+
} catch (_) {
|
|
90
|
+
throw new Error("Config file not found: ".concat(CONFIG_NAME, "\n\nSearched from ").concat(cwd, " up to ").concat(homeDir));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/* 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/find-config.ts"],"sourcesContent":["/**\n * find-config.ts\n *\n * Find .mcp.json config file by searching up the directory tree.\n * Searches from cwd up to home directory (like Claude Code).\n */\n\nimport * as fs from 'fs';\nimport moduleRoot from 'module-root-sync';\nimport * as os from 'os';\nimport * as path from 'path';\n\nconst CONFIG_NAME = '.mcp.json';\n\n/**\n * Find .mcp.json by searching up directory tree from cwd to home directory.\n *\n * @param explicitPath - If provided, validates and returns this path (for --config flag)\n * @returns The resolved path to the config file\n * @throws Error if config file not found\n */\nexport function findConfigPath(explicitPath?: string): string {\n // If explicit path provided, validate it exists\n if (explicitPath) {\n const resolvedPath = path.resolve(explicitPath);\n if (!fs.existsSync(resolvedPath)) {\n throw new Error(`Config file not found: ${resolvedPath}`);\n }\n return resolvedPath;\n }\n\n const cwd = process.cwd();\n const homeDir = os.homedir();\n\n // Use module-root-sync with custom file name to search up\n try {\n const configDir = moduleRoot(cwd, { name: CONFIG_NAME });\n const configPath = path.join(configDir, CONFIG_NAME);\n\n // Ensure we haven't gone above home directory\n if (!configPath.startsWith(homeDir)) {\n throw new Error(`Config file not found in directory tree (searched from ${cwd} to ${homeDir})`);\n }\n\n return configPath;\n } catch (_) {\n throw new Error(`Config file not found: ${CONFIG_NAME}\\n\\nSearched from ${cwd} up to ${homeDir}`);\n }\n}\n"],"names":["findConfigPath","CONFIG_NAME","explicitPath","resolvedPath","path","resolve","fs","existsSync","Error","cwd","process","homeDir","os","homedir","configDir","moduleRoot","name","configPath","join","startsWith","_"],"mappings":"AAAA;;;;;CAKC;;;;+BAgBeA;;;eAAAA;;;0DAdI;qEACG;0DACH;4DACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtB,IAAMC,cAAc;AASb,SAASD,eAAeE,YAAqB;IAClD,gDAAgD;IAChD,IAAIA,cAAc;QAChB,IAAMC,eAAeC,MAAKC,OAAO,CAACH;QAClC,IAAI,CAACI,IAAGC,UAAU,CAACJ,eAAe;YAChC,MAAM,IAAIK,MAAM,AAAC,0BAAsC,OAAbL;QAC5C;QACA,OAAOA;IACT;IAEA,IAAMM,MAAMC,QAAQD,GAAG;IACvB,IAAME,UAAUC,IAAGC,OAAO;IAE1B,0DAA0D;IAC1D,IAAI;QACF,IAAMC,YAAYC,IAAAA,uBAAU,EAACN,KAAK;YAAEO,MAAMf;QAAY;QACtD,IAAMgB,aAAab,MAAKc,IAAI,CAACJ,WAAWb;QAExC,8CAA8C;QAC9C,IAAI,CAACgB,WAAWE,UAAU,CAACR,UAAU;YACnC,MAAM,IAAIH,MAAM,AAAC,0DAAmEG,OAAVF,KAAI,QAAc,OAARE,SAAQ;QAC9F;QAEA,OAAOM;IACT,EAAE,OAAOG,GAAG;QACV,MAAM,IAAIZ,MAAM,AAAC,0BAAyDC,OAAhCR,aAAY,sBAAiCU,OAAbF,KAAI,WAAiB,OAARE;IACzF;AACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const SCHEMA_URL = "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json";
|
|
2
|
+
/**
|
|
3
|
+
* Get MCP server.json schema (fetches once, then caches)
|
|
4
|
+
*
|
|
5
|
+
* Strategy:
|
|
6
|
+
* 1. Return cached schema if available
|
|
7
|
+
* 2. Try fetching latest schema from URL
|
|
8
|
+
* 3. Fall back to bundled schema if network fails
|
|
9
|
+
*/
|
|
10
|
+
export declare function getSchema(): Promise<object>;
|
|
11
|
+
/**
|
|
12
|
+
* Validate server.json against MCP schema
|
|
13
|
+
*
|
|
14
|
+
* @param serverJson - Parsed server.json content to validate
|
|
15
|
+
* @param serverName - Server name for error messages
|
|
16
|
+
* @throws Error with detailed validation messages if invalid
|
|
17
|
+
*/
|
|
18
|
+
export declare function validateSchema(serverJson: unknown, serverName: string): Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const SCHEMA_URL = "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json";
|
|
2
|
+
/**
|
|
3
|
+
* Get MCP server.json schema (fetches once, then caches)
|
|
4
|
+
*
|
|
5
|
+
* Strategy:
|
|
6
|
+
* 1. Return cached schema if available
|
|
7
|
+
* 2. Try fetching latest schema from URL
|
|
8
|
+
* 3. Fall back to bundled schema if network fails
|
|
9
|
+
*/
|
|
10
|
+
export declare function getSchema(): Promise<object>;
|
|
11
|
+
/**
|
|
12
|
+
* Validate server.json against MCP schema
|
|
13
|
+
*
|
|
14
|
+
* @param serverJson - Parsed server.json content to validate
|
|
15
|
+
* @param serverName - Server name for error messages
|
|
16
|
+
* @throws Error with detailed validation messages if invalid
|
|
17
|
+
*/
|
|
18
|
+
export declare function validateSchema(serverJson: unknown, serverName: string): Promise<void>;
|