add-mcp 1.1.0 → 1.2.1
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/README.md +4 -0
- package/dist/index.js +66 -10
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -54,6 +54,9 @@ npx add-mcp mcp-server-github --all
|
|
|
54
54
|
|
|
55
55
|
# Install to all agents, globally, without prompts
|
|
56
56
|
npx add-mcp mcp-server-github --all -g -y
|
|
57
|
+
|
|
58
|
+
# Add generated config files to .gitignore
|
|
59
|
+
npx add-mcp https://mcp.example.com/mcp -a cursor -y --gitignore
|
|
57
60
|
```
|
|
58
61
|
|
|
59
62
|
### Options
|
|
@@ -68,6 +71,7 @@ npx add-mcp mcp-server-github --all -g -y
|
|
|
68
71
|
| `-n, --name <name>` | Server name (auto-inferred if not provided) |
|
|
69
72
|
| `-y, --yes` | Skip all confirmation prompts |
|
|
70
73
|
| `--all` | Install to all agents |
|
|
74
|
+
| `--gitignore` | Add generated config files to `.gitignore` |
|
|
71
75
|
|
|
72
76
|
### Additional Commands
|
|
73
77
|
|
package/dist/index.js
CHANGED
|
@@ -160,11 +160,14 @@ function transformOpenCodeConfig(_serverName, config) {
|
|
|
160
160
|
}
|
|
161
161
|
function transformCodexConfig(_serverName, config) {
|
|
162
162
|
if (config.url) {
|
|
163
|
-
|
|
163
|
+
const remoteConfig = {
|
|
164
164
|
type: config.type || "http",
|
|
165
|
-
url: config.url
|
|
166
|
-
headers: config.headers
|
|
165
|
+
url: config.url
|
|
167
166
|
};
|
|
167
|
+
if (config.headers && Object.keys(config.headers).length > 0) {
|
|
168
|
+
remoteConfig.http_headers = config.headers;
|
|
169
|
+
}
|
|
170
|
+
return remoteConfig;
|
|
168
171
|
}
|
|
169
172
|
return {
|
|
170
173
|
command: config.command,
|
|
@@ -642,8 +645,8 @@ function isRemoteSource(parsed) {
|
|
|
642
645
|
}
|
|
643
646
|
|
|
644
647
|
// src/installer.ts
|
|
645
|
-
import { existsSync as existsSync5, mkdirSync as mkdirSync4 } from "fs";
|
|
646
|
-
import { join as join3, dirname as dirname6 } from "path";
|
|
648
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "fs";
|
|
649
|
+
import { join as join3, dirname as dirname6, isAbsolute, relative, sep } from "path";
|
|
647
650
|
|
|
648
651
|
// src/formats/json.ts
|
|
649
652
|
import { readFileSync, writeFileSync, existsSync as existsSync2, mkdirSync } from "fs";
|
|
@@ -844,6 +847,41 @@ function buildServerConfig(parsed, options = {}) {
|
|
|
844
847
|
args: ["-y", parsed.value]
|
|
845
848
|
};
|
|
846
849
|
}
|
|
850
|
+
function updateGitignoreWithPaths(paths, options = {}) {
|
|
851
|
+
const cwd = options.cwd || process.cwd();
|
|
852
|
+
const gitignorePath = join3(cwd, ".gitignore");
|
|
853
|
+
const existingContent = existsSync5(gitignorePath) ? readFileSync4(gitignorePath, "utf-8") : "";
|
|
854
|
+
const existingEntries = new Set(
|
|
855
|
+
existingContent.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0)
|
|
856
|
+
);
|
|
857
|
+
const entriesToAdd = [];
|
|
858
|
+
for (const filePath of paths) {
|
|
859
|
+
const relativePath = isAbsolute(filePath) ? relative(cwd, filePath) : filePath;
|
|
860
|
+
if (!relativePath || relativePath.startsWith("..") || isAbsolute(relativePath)) {
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
const normalizedPath = relativePath.split(sep).join("/");
|
|
864
|
+
const cleanPath = normalizedPath.startsWith("./") ? normalizedPath.slice(2) : normalizedPath;
|
|
865
|
+
if (!cleanPath || cleanPath === ".gitignore" || existingEntries.has(cleanPath)) {
|
|
866
|
+
continue;
|
|
867
|
+
}
|
|
868
|
+
existingEntries.add(cleanPath);
|
|
869
|
+
entriesToAdd.push(cleanPath);
|
|
870
|
+
}
|
|
871
|
+
if (entriesToAdd.length > 0) {
|
|
872
|
+
let nextContent = existingContent;
|
|
873
|
+
if (nextContent.length > 0 && !nextContent.endsWith("\n")) {
|
|
874
|
+
nextContent += "\n";
|
|
875
|
+
}
|
|
876
|
+
nextContent += `${entriesToAdd.join("\n")}
|
|
877
|
+
`;
|
|
878
|
+
writeFileSync4(gitignorePath, nextContent, "utf-8");
|
|
879
|
+
}
|
|
880
|
+
return {
|
|
881
|
+
path: gitignorePath,
|
|
882
|
+
added: entriesToAdd
|
|
883
|
+
};
|
|
884
|
+
}
|
|
847
885
|
function getConfigPath(agent, options = {}) {
|
|
848
886
|
if (options.local && agent.localConfigPath) {
|
|
849
887
|
const cwd = options.cwd || process.cwd();
|
|
@@ -905,13 +943,13 @@ function installServer(serverName, serverConfig, agentTypes, options = {}) {
|
|
|
905
943
|
// package.json
|
|
906
944
|
var package_default = {
|
|
907
945
|
name: "add-mcp",
|
|
908
|
-
version: "1.1
|
|
946
|
+
version: "1.2.1",
|
|
909
947
|
description: "Add MCP servers to your favorite coding agents with a single command.",
|
|
910
948
|
author: "Andre Landgraf <andre@neon.tech>",
|
|
911
949
|
license: "Apache-2.0",
|
|
912
950
|
type: "module",
|
|
913
951
|
bin: {
|
|
914
|
-
"add-mcp": "
|
|
952
|
+
"add-mcp": "dist/index.js"
|
|
915
953
|
},
|
|
916
954
|
files: [
|
|
917
955
|
"dist",
|
|
@@ -921,9 +959,9 @@ var package_default = {
|
|
|
921
959
|
fmt: "prettier --write .",
|
|
922
960
|
build: "tsup src/index.ts --format esm --dts --clean",
|
|
923
961
|
dev: "tsx src/index.ts",
|
|
924
|
-
test: "tsx tests/source-parser.test.ts && tsx tests/agents.test.ts && tsx tests/mcp-lock.test.ts && tsx tests/installer.test.ts && tsx tests/e2e/install.test.ts",
|
|
962
|
+
test: "tsx tests/source-parser.test.ts && tsx tests/agents.test.ts && tsx tests/mcp-lock.test.ts && tsx tests/installer.test.ts && tsx tests/e2e/install.test.ts && tsx tests/e2e/cli.test.ts",
|
|
925
963
|
"test:unit": "tsx tests/source-parser.test.ts && tsx tests/agents.test.ts && tsx tests/mcp-lock.test.ts && tsx tests/installer.test.ts",
|
|
926
|
-
"test:e2e": "tsx tests/e2e/install.test.ts",
|
|
964
|
+
"test:e2e": "tsx tests/e2e/install.test.ts && tsx tests/e2e/cli.test.ts",
|
|
927
965
|
typecheck: "tsc --noEmit",
|
|
928
966
|
prepublishOnly: "npm run build"
|
|
929
967
|
},
|
|
@@ -1054,7 +1092,10 @@ program.name("add-mcp").description(
|
|
|
1054
1092
|
"HTTP header for remote servers (repeatable, 'Key: Value')",
|
|
1055
1093
|
collect,
|
|
1056
1094
|
[]
|
|
1057
|
-
).option("-y, --yes", "Skip confirmation prompts").option("--all", "Install to all agents").
|
|
1095
|
+
).option("-y, --yes", "Skip confirmation prompts").option("--all", "Install to all agents").option(
|
|
1096
|
+
"--gitignore",
|
|
1097
|
+
"Add generated project config files to .gitignore"
|
|
1098
|
+
).action(async (target, options) => {
|
|
1058
1099
|
await main(target, options);
|
|
1059
1100
|
});
|
|
1060
1101
|
program.command("list-agents").description("List all supported coding agents").action(() => {
|
|
@@ -1463,6 +1504,21 @@ async function main(target, options) {
|
|
|
1463
1504
|
);
|
|
1464
1505
|
}
|
|
1465
1506
|
}
|
|
1507
|
+
if (options.gitignore && options.global) {
|
|
1508
|
+
p2.log.warn(
|
|
1509
|
+
"--gitignore is only supported for project-scoped installations; ignoring."
|
|
1510
|
+
);
|
|
1511
|
+
} else if (options.gitignore) {
|
|
1512
|
+
const successfulPaths = successful.map(([_, result]) => result.path);
|
|
1513
|
+
const gitignoreUpdate = updateGitignoreWithPaths(successfulPaths);
|
|
1514
|
+
if (gitignoreUpdate.added.length > 0) {
|
|
1515
|
+
p2.log.info(
|
|
1516
|
+
`Added ${gitignoreUpdate.added.length} entr${gitignoreUpdate.added.length === 1 ? "y" : "ies"} to .gitignore`
|
|
1517
|
+
);
|
|
1518
|
+
} else {
|
|
1519
|
+
p2.log.info("No new local config paths to add to .gitignore");
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1466
1522
|
console.log();
|
|
1467
1523
|
p2.outro(chalk.green("Done!"));
|
|
1468
1524
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "add-mcp",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Add MCP servers to your favorite coding agents with a single command.",
|
|
5
5
|
"author": "Andre Landgraf <andre@neon.tech>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|
|
9
|
-
"add-mcp": "
|
|
9
|
+
"add-mcp": "dist/index.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"fmt": "prettier --write .",
|
|
17
17
|
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
18
18
|
"dev": "tsx src/index.ts",
|
|
19
|
-
"test": "tsx tests/source-parser.test.ts && tsx tests/agents.test.ts && tsx tests/mcp-lock.test.ts && tsx tests/installer.test.ts && tsx tests/e2e/install.test.ts",
|
|
19
|
+
"test": "tsx tests/source-parser.test.ts && tsx tests/agents.test.ts && tsx tests/mcp-lock.test.ts && tsx tests/installer.test.ts && tsx tests/e2e/install.test.ts && tsx tests/e2e/cli.test.ts",
|
|
20
20
|
"test:unit": "tsx tests/source-parser.test.ts && tsx tests/agents.test.ts && tsx tests/mcp-lock.test.ts && tsx tests/installer.test.ts",
|
|
21
|
-
"test:e2e": "tsx tests/e2e/install.test.ts",
|
|
21
|
+
"test:e2e": "tsx tests/e2e/install.test.ts && tsx tests/e2e/cli.test.ts",
|
|
22
22
|
"typecheck": "tsc --noEmit",
|
|
23
23
|
"prepublishOnly": "npm run build"
|
|
24
24
|
},
|