@getmcp/cli 0.1.4 → 0.1.5
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/bin.js +3 -1
- package/dist/bin.js.map +1 -1
- package/dist/commands/add.d.ts.map +1 -1
- package/dist/commands/add.js +11 -2
- package/dist/commands/add.js.map +1 -1
- package/dist/config-file.d.ts +23 -5
- package/dist/config-file.d.ts.map +1 -1
- package/dist/config-file.js +136 -18
- package/dist/config-file.js.map +1 -1
- package/dist/format.d.ts +15 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +30 -0
- package/dist/format.js.map +1 -0
- package/package.json +8 -3
package/dist/bin.js
CHANGED
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
* getmcp list [--search=query] Search the registry
|
|
10
10
|
* getmcp list [--category=cat] Filter by category
|
|
11
11
|
*/
|
|
12
|
+
import { createRequire } from "node:module";
|
|
12
13
|
import { addCommand } from "./commands/add.js";
|
|
13
14
|
import { removeCommand } from "./commands/remove.js";
|
|
14
15
|
import { listCommand } from "./commands/list.js";
|
|
15
|
-
const
|
|
16
|
+
const require = createRequire(import.meta.url);
|
|
17
|
+
const { version: VERSION } = require("../package.json");
|
|
16
18
|
function printHelp() {
|
|
17
19
|
console.log(`
|
|
18
20
|
getmcp v${VERSION} — Install MCP servers into any AI application
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AAEA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,OAAO,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"m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ACD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAeH,wBAAsB,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAeH,wBAAsB,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAwIpE"}
|
package/dist/commands/add.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* 5. Generate config for each selected app
|
|
10
10
|
* 6. Merge into existing config files (never overwrite)
|
|
11
11
|
*/
|
|
12
|
-
import { select, checkbox, input } from "@inquirer/prompts";
|
|
12
|
+
import { select, checkbox, input, password } from "@inquirer/prompts";
|
|
13
13
|
import { getAllServers, getServer, searchServers, } from "@getmcp/registry";
|
|
14
14
|
import { getGenerator } from "@getmcp/generators";
|
|
15
15
|
import { isStdioConfig } from "@getmcp/core";
|
|
@@ -62,7 +62,8 @@ export async function addCommand(serverIdArg) {
|
|
|
62
62
|
if (entry.requiredEnvVars.length > 0 && isStdioConfig(config)) {
|
|
63
63
|
console.log("This server requires environment variables:\n");
|
|
64
64
|
for (const envVar of entry.requiredEnvVars) {
|
|
65
|
-
const
|
|
65
|
+
const prompt = isSensitiveEnvVar(envVar) ? password : input;
|
|
66
|
+
const value = await prompt({
|
|
66
67
|
message: ` ${envVar}:`,
|
|
67
68
|
validate: (val) => (val.trim() ? true : `${envVar} is required`),
|
|
68
69
|
});
|
|
@@ -142,4 +143,12 @@ function printManualConfig(entry, config) {
|
|
|
142
143
|
};
|
|
143
144
|
console.log(JSON.stringify(canonical, null, 2));
|
|
144
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Heuristic to detect if an environment variable name likely holds a secret.
|
|
148
|
+
* Returns true for names containing common secret-related keywords.
|
|
149
|
+
*/
|
|
150
|
+
const SENSITIVE_PATTERNS = /TOKEN|KEY|SECRET|PASSWORD|CREDENTIAL|AUTH|PAT|PRIVATE/i;
|
|
151
|
+
function isSensitiveEnvVar(name) {
|
|
152
|
+
return SENSITIVE_PATTERNS.test(name);
|
|
153
|
+
}
|
|
145
154
|
//# sourceMappingURL=add.js.map
|
package/dist/commands/add.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EACL,aAAa,EACb,SAAS,EACT,aAAa,GACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAoB,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE3E,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,WAAoB;IACnD,wBAAwB;IACxB,IAAI,KAAwB,C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AAE,CAAC,CACxD,CAAC;IACF,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,8DAA8D,CAAC,CAAC;IAC9E,CAAC;IAED,yDAAyD;IACzD,MAAM,UAAU,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC;IAChE,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CACT,gFAAgF;YAChF,uEAAuE;YACvE,uFAAuF;YACvF,8DAA8D,CAC/D,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CACxB,KAAwB,EACxB,MAA6B;IAE7B,4BAA4B;IAC5B,MAAM,SAAS,GAAG;QAChB,UAAU,EAAE;YACV,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,MAAM;SACnB;KACF,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,kBAAkB,GACtB,wDAAwD,CAAC;AAE3D,SAAS,iBAAiB,CAAC,IAAY;IACrC,OAAO,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/config-file.d.ts
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Config file reading, merging, and writing.
|
|
3
3
|
*
|
|
4
|
+
* Supports JSON, JSONC, YAML, and TOML formats.
|
|
5
|
+
* Format is auto-detected from the file extension.
|
|
6
|
+
*
|
|
4
7
|
* Key principle: NEVER overwrite existing config files.
|
|
5
8
|
* Always read the existing config, merge the new server in, and write back.
|
|
6
9
|
*/
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
+
* Strip JSONC comments (single-line `//` and multi-line `/* ... */`)
|
|
12
|
+
* while respecting JSON string boundaries.
|
|
13
|
+
*
|
|
14
|
+
* Unlike a naive regex replace, this properly handles `//` sequences
|
|
15
|
+
* inside JSON string values (e.g., URLs like "https://example.com").
|
|
16
|
+
*/
|
|
17
|
+
export declare function stripJsoncComments(raw: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Read and parse a config file.
|
|
20
|
+
* Returns an empty object if the file doesn't exist or is empty.
|
|
21
|
+
* Format is auto-detected from the file extension.
|
|
11
22
|
*/
|
|
12
23
|
export declare function readConfigFile(filePath: string): Record<string, unknown>;
|
|
13
24
|
/**
|
|
14
|
-
* Write a config object to a
|
|
25
|
+
* Write a config object to a file.
|
|
15
26
|
* Creates parent directories if they don't exist.
|
|
27
|
+
* Format is auto-detected from the file extension.
|
|
16
28
|
*/
|
|
17
29
|
export declare function writeConfigFile(filePath: string, config: Record<string, unknown>): void;
|
|
18
30
|
/**
|
|
@@ -23,6 +35,9 @@ export declare function writeConfigFile(filePath: string, config: Record<string,
|
|
|
23
35
|
*
|
|
24
36
|
* This function deep-merges the server into the existing file's root key,
|
|
25
37
|
* preserving all other existing servers and config.
|
|
38
|
+
*
|
|
39
|
+
* Format is auto-detected from the file extension at read/write boundaries.
|
|
40
|
+
* The merge logic itself is format-agnostic (operates on plain objects).
|
|
26
41
|
*/
|
|
27
42
|
export declare function mergeServerIntoConfig(filePath: string, generatedConfig: Record<string, unknown>): Record<string, unknown>;
|
|
28
43
|
/**
|
|
@@ -32,11 +47,14 @@ export declare function mergeServerIntoConfig(filePath: string, generatedConfig:
|
|
|
32
47
|
* the server name and removes it.
|
|
33
48
|
*
|
|
34
49
|
* Returns the updated config, or null if the server wasn't found.
|
|
50
|
+
* Format is auto-detected from the file extension.
|
|
35
51
|
*/
|
|
36
52
|
export declare function removeServerFromConfig(filePath: string, serverName: string): Record<string, unknown> | null;
|
|
37
53
|
/**
|
|
38
54
|
* List all server names found in a config file.
|
|
39
|
-
* Scans known root keys: mcpServers, servers, extensions, mcp,
|
|
55
|
+
* Scans known root keys: mcpServers, servers, extensions, mcp,
|
|
56
|
+
* context_servers, mcp_servers.
|
|
57
|
+
* Format is auto-detected from the file extension.
|
|
40
58
|
*/
|
|
41
59
|
export declare function listServersInConfig(filePath: string): string[];
|
|
42
60
|
//# sourceMappingURL=config-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-file.d.ts","sourceRoot":"","sources":["../src/config-file.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config-file.d.ts","sourceRoot":"","sources":["../src/config-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AASH;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA8DtD;AAgDD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAUxE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,IAAI,CASN;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACvC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAsBzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAmBhC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,GACf,MAAM,EAAE,CAoBV"}
|
package/dist/config-file.js
CHANGED
|
@@ -1,15 +1,125 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Config file reading, merging, and writing.
|
|
3
3
|
*
|
|
4
|
+
* Supports JSON, JSONC, YAML, and TOML formats.
|
|
5
|
+
* Format is auto-detected from the file extension.
|
|
6
|
+
*
|
|
4
7
|
* Key principle: NEVER overwrite existing config files.
|
|
5
8
|
* Always read the existing config, merge the new server in, and write back.
|
|
6
9
|
*/
|
|
7
10
|
import * as fs from "node:fs";
|
|
8
11
|
import * as path from "node:path";
|
|
12
|
+
import YAML from "yaml";
|
|
13
|
+
import * as TOML from "smol-toml";
|
|
14
|
+
import { detectConfigFormat } from "./format.js";
|
|
15
|
+
/**
|
|
16
|
+
* Strip JSONC comments (single-line `//` and multi-line `/* ... */`)
|
|
17
|
+
* while respecting JSON string boundaries.
|
|
18
|
+
*
|
|
19
|
+
* Unlike a naive regex replace, this properly handles `//` sequences
|
|
20
|
+
* inside JSON string values (e.g., URLs like "https://example.com").
|
|
21
|
+
*/
|
|
22
|
+
export function stripJsoncComments(raw) {
|
|
23
|
+
let result = "";
|
|
24
|
+
let i = 0;
|
|
25
|
+
const len = raw.length;
|
|
26
|
+
while (i < len) {
|
|
27
|
+
const ch = raw[i];
|
|
28
|
+
// Handle JSON strings — skip through them without stripping
|
|
29
|
+
if (ch === '"') {
|
|
30
|
+
result += ch;
|
|
31
|
+
i++;
|
|
32
|
+
// Walk through the string until the closing unescaped quote
|
|
33
|
+
while (i < len) {
|
|
34
|
+
const sch = raw[i];
|
|
35
|
+
result += sch;
|
|
36
|
+
if (sch === "\\") {
|
|
37
|
+
// Escaped character — copy next char and skip
|
|
38
|
+
i++;
|
|
39
|
+
if (i < len) {
|
|
40
|
+
result += raw[i];
|
|
41
|
+
i++;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else if (sch === '"') {
|
|
45
|
+
i++;
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
i++;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
// Handle single-line comment: //
|
|
55
|
+
if (ch === "/" && i + 1 < len && raw[i + 1] === "/") {
|
|
56
|
+
// Skip until end of line
|
|
57
|
+
i += 2;
|
|
58
|
+
while (i < len && raw[i] !== "\n") {
|
|
59
|
+
i++;
|
|
60
|
+
}
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
// Handle multi-line comment: /* ... */
|
|
64
|
+
if (ch === "/" && i + 1 < len && raw[i + 1] === "*") {
|
|
65
|
+
i += 2;
|
|
66
|
+
while (i < len) {
|
|
67
|
+
if (raw[i] === "*" && i + 1 < len && raw[i + 1] === "/") {
|
|
68
|
+
i += 2;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
i++;
|
|
72
|
+
}
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
// Regular character
|
|
76
|
+
result += ch;
|
|
77
|
+
i++;
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
9
81
|
/**
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
82
|
+
* Parse raw file content according to the detected format.
|
|
83
|
+
*/
|
|
84
|
+
function parseContent(raw, format, filePath) {
|
|
85
|
+
try {
|
|
86
|
+
switch (format) {
|
|
87
|
+
case "json":
|
|
88
|
+
return JSON.parse(raw);
|
|
89
|
+
case "jsonc":
|
|
90
|
+
return JSON.parse(stripJsoncComments(raw));
|
|
91
|
+
case "yaml":
|
|
92
|
+
return YAML.parse(raw) ?? {};
|
|
93
|
+
case "toml":
|
|
94
|
+
return TOML.parse(raw);
|
|
95
|
+
default:
|
|
96
|
+
return JSON.parse(raw);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
throw new Error(`Failed to parse config file: ${filePath}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Serialize a config object to a string in the given format.
|
|
105
|
+
*/
|
|
106
|
+
function serializeContent(config, format) {
|
|
107
|
+
switch (format) {
|
|
108
|
+
case "json":
|
|
109
|
+
case "jsonc":
|
|
110
|
+
return JSON.stringify(config, null, 2) + "\n";
|
|
111
|
+
case "yaml":
|
|
112
|
+
return YAML.stringify(config, { indent: 2 });
|
|
113
|
+
case "toml":
|
|
114
|
+
return TOML.stringify(config) + "\n";
|
|
115
|
+
default:
|
|
116
|
+
return JSON.stringify(config, null, 2) + "\n";
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Read and parse a config file.
|
|
121
|
+
* Returns an empty object if the file doesn't exist or is empty.
|
|
122
|
+
* Format is auto-detected from the file extension.
|
|
13
123
|
*/
|
|
14
124
|
export function readConfigFile(filePath) {
|
|
15
125
|
if (!fs.existsSync(filePath)) {
|
|
@@ -18,27 +128,22 @@ export function readConfigFile(filePath) {
|
|
|
18
128
|
const raw = fs.readFileSync(filePath, "utf-8");
|
|
19
129
|
if (!raw.trim())
|
|
20
130
|
return {};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.replace(/\/\/.*$/gm, "")
|
|
24
|
-
.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
25
|
-
try {
|
|
26
|
-
return JSON.parse(stripped);
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
throw new Error(`Failed to parse config file: ${filePath}`);
|
|
30
|
-
}
|
|
131
|
+
const format = detectConfigFormat(filePath);
|
|
132
|
+
return parseContent(raw, format, filePath);
|
|
31
133
|
}
|
|
32
134
|
/**
|
|
33
|
-
* Write a config object to a
|
|
135
|
+
* Write a config object to a file.
|
|
34
136
|
* Creates parent directories if they don't exist.
|
|
137
|
+
* Format is auto-detected from the file extension.
|
|
35
138
|
*/
|
|
36
139
|
export function writeConfigFile(filePath, config) {
|
|
37
140
|
const dir = path.dirname(filePath);
|
|
38
141
|
if (!fs.existsSync(dir)) {
|
|
39
142
|
fs.mkdirSync(dir, { recursive: true });
|
|
40
143
|
}
|
|
41
|
-
|
|
144
|
+
const format = detectConfigFormat(filePath);
|
|
145
|
+
const content = serializeContent(config, format);
|
|
146
|
+
fs.writeFileSync(filePath, content, "utf-8");
|
|
42
147
|
}
|
|
43
148
|
/**
|
|
44
149
|
* Merge a generated server config into an existing config file.
|
|
@@ -48,6 +153,9 @@ export function writeConfigFile(filePath, config) {
|
|
|
48
153
|
*
|
|
49
154
|
* This function deep-merges the server into the existing file's root key,
|
|
50
155
|
* preserving all other existing servers and config.
|
|
156
|
+
*
|
|
157
|
+
* Format is auto-detected from the file extension at read/write boundaries.
|
|
158
|
+
* The merge logic itself is format-agnostic (operates on plain objects).
|
|
51
159
|
*/
|
|
52
160
|
export function mergeServerIntoConfig(filePath, generatedConfig) {
|
|
53
161
|
const existing = readConfigFile(filePath);
|
|
@@ -75,11 +183,12 @@ export function mergeServerIntoConfig(filePath, generatedConfig) {
|
|
|
75
183
|
* the server name and removes it.
|
|
76
184
|
*
|
|
77
185
|
* Returns the updated config, or null if the server wasn't found.
|
|
186
|
+
* Format is auto-detected from the file extension.
|
|
78
187
|
*/
|
|
79
188
|
export function removeServerFromConfig(filePath, serverName) {
|
|
80
189
|
const existing = readConfigFile(filePath);
|
|
81
190
|
let found = false;
|
|
82
|
-
for (const [
|
|
191
|
+
for (const [, value] of Object.entries(existing)) {
|
|
83
192
|
if (typeof value === "object" &&
|
|
84
193
|
value !== null &&
|
|
85
194
|
!Array.isArray(value)) {
|
|
@@ -94,11 +203,20 @@ export function removeServerFromConfig(filePath, serverName) {
|
|
|
94
203
|
}
|
|
95
204
|
/**
|
|
96
205
|
* List all server names found in a config file.
|
|
97
|
-
* Scans known root keys: mcpServers, servers, extensions, mcp,
|
|
206
|
+
* Scans known root keys: mcpServers, servers, extensions, mcp,
|
|
207
|
+
* context_servers, mcp_servers.
|
|
208
|
+
* Format is auto-detected from the file extension.
|
|
98
209
|
*/
|
|
99
210
|
export function listServersInConfig(filePath) {
|
|
100
211
|
const existing = readConfigFile(filePath);
|
|
101
|
-
const rootKeys = [
|
|
212
|
+
const rootKeys = [
|
|
213
|
+
"mcpServers",
|
|
214
|
+
"servers",
|
|
215
|
+
"extensions",
|
|
216
|
+
"mcp",
|
|
217
|
+
"context_servers",
|
|
218
|
+
"mcp_servers",
|
|
219
|
+
];
|
|
102
220
|
const servers = [];
|
|
103
221
|
for (const rootKey of rootKeys) {
|
|
104
222
|
const section = existing[rootKey];
|
package/dist/config-file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-file.js","sourceRoot":"","sources":["../src/config-file.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config-file.js","sourceRoot":"","sources":["../src/config-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAqB,MAAM,aAAa,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC;IAEvB,OAAO,CAAC,GAAG,GAAG,EAAE,CAAC;QACf,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QAElB,4DAA4D;QAC5D,IAAI,EAAE,KAAK,GAAG,EAAE,CAAC;YACf,MAAM,IAAI,EAAE,CAAC;YACb,CAAC,EAAE,CAAC;YACJ,4DAA4D;YAC5D,OAAO,CAAC,GAAG,GAAG,EAAE,CAAC;gBACf,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;gBACnB,MAAM,IAAI,GAAG,CAAC;gBACd,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;oBACjB,8CAA8C;oBAC9C,CAAC,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AAC;IAE7B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;QAClC,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/E,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,OAAkC,CAAC,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/format.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config file format detection based on file extension.
|
|
3
|
+
*
|
|
4
|
+
* Used by readConfigFile/writeConfigFile to dispatch to the correct
|
|
5
|
+
* parser/serializer for JSON, JSONC, YAML, and TOML formats.
|
|
6
|
+
*/
|
|
7
|
+
export type ConfigFormat = "json" | "jsonc" | "yaml" | "toml";
|
|
8
|
+
/**
|
|
9
|
+
* Detect the config file format from its file extension.
|
|
10
|
+
*
|
|
11
|
+
* @param filePath - Path to the config file
|
|
12
|
+
* @returns The detected format, defaults to "json" for unknown extensions
|
|
13
|
+
*/
|
|
14
|
+
export declare function detectConfigFormat(filePath: string): ConfigFormat;
|
|
15
|
+
//# sourceMappingURL=format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAE9D;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAgBjE"}
|
package/dist/format.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config file format detection based on file extension.
|
|
3
|
+
*
|
|
4
|
+
* Used by readConfigFile/writeConfigFile to dispatch to the correct
|
|
5
|
+
* parser/serializer for JSON, JSONC, YAML, and TOML formats.
|
|
6
|
+
*/
|
|
7
|
+
import * as path from "node:path";
|
|
8
|
+
/**
|
|
9
|
+
* Detect the config file format from its file extension.
|
|
10
|
+
*
|
|
11
|
+
* @param filePath - Path to the config file
|
|
12
|
+
* @returns The detected format, defaults to "json" for unknown extensions
|
|
13
|
+
*/
|
|
14
|
+
export function detectConfigFormat(filePath) {
|
|
15
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
16
|
+
switch (ext) {
|
|
17
|
+
case ".json":
|
|
18
|
+
return "json";
|
|
19
|
+
case ".jsonc":
|
|
20
|
+
return "jsonc";
|
|
21
|
+
case ".yaml":
|
|
22
|
+
case ".yml":
|
|
23
|
+
return "yaml";
|
|
24
|
+
case ".toml":
|
|
25
|
+
return "toml";
|
|
26
|
+
default:
|
|
27
|
+
return "json";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAIlC;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB;IACjD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAC;IAEjD,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,OAAO;YACV,OAAO,MAAM,CAAC;QAChB,KAAK,QAAQ;YACX,OAAO,OAAO,CAAC;QACjB,KAAK,OAAO,CAAC;QACb,KAAK,MAAM;YACT,OAAO,MAAM,CAAC;QAChB,KAAK,OAAO;YACV,OAAO,MAAM,CAAC;QAChB;YACE,OAAO,MAAM,CAAC;IAClB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getmcp/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "CLI tool to install MCP servers into any AI application with one command",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"license": "MIT",
|
|
44
44
|
"repository": {
|
|
45
45
|
"type": "git",
|
|
46
|
-
"url": "https://github.com/RodrigoTomeES/getmcp.git",
|
|
46
|
+
"url": "git+https://github.com/RodrigoTomeES/getmcp.git",
|
|
47
47
|
"directory": "packages/cli"
|
|
48
48
|
},
|
|
49
49
|
"homepage": "https://github.com/RodrigoTomeES/getmcp/tree/main/packages/cli#readme",
|
|
@@ -53,11 +53,16 @@
|
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=22.0.0"
|
|
55
55
|
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
56
59
|
"dependencies": {
|
|
57
60
|
"@getmcp/core": "^0.1.0",
|
|
58
61
|
"@getmcp/generators": "^0.1.0",
|
|
59
62
|
"@getmcp/registry": "^0.1.0",
|
|
60
|
-
"@inquirer/prompts": "^7.0.0"
|
|
63
|
+
"@inquirer/prompts": "^7.0.0",
|
|
64
|
+
"smol-toml": "^1.6.0",
|
|
65
|
+
"yaml": "^2.8.2"
|
|
61
66
|
},
|
|
62
67
|
"devDependencies": {
|
|
63
68
|
"@types/node": "^24.0.0"
|