add-mcp 1.5.0 → 1.6.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/README.md +9 -0
- package/dist/index.js +77 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,6 +43,9 @@ npx add-mcp "npx -y @org/mcp-server --flag value"
|
|
|
43
43
|
# Node.js script
|
|
44
44
|
npx add-mcp "node /path/to/server.js --port 3000"
|
|
45
45
|
|
|
46
|
+
# Local stdio server with environment variables (repeatable)
|
|
47
|
+
npx add-mcp @modelcontextprotocol/server-filesystem --env "API_KEY=secret" --env "DATABASE_URL=postgres://localhost/app"
|
|
48
|
+
|
|
46
49
|
# Install for Cursor and Claude Code
|
|
47
50
|
npx add-mcp https://mcp.example.com/mcp -a cursor -a claude-code
|
|
48
51
|
|
|
@@ -68,6 +71,7 @@ npx add-mcp https://mcp.example.com/mcp -a cursor -y --gitignore
|
|
|
68
71
|
| `-t, --transport <type>` | Transport type for remote servers: `http` (default), `sse` |
|
|
69
72
|
| `--type <type>` | Alias for `--transport` |
|
|
70
73
|
| `--header <header>` | HTTP header for remote servers (repeatable, `Key: Value`) |
|
|
74
|
+
| `--env <env>` | Env var for local stdio servers (repeatable, `KEY=VALUE`) |
|
|
71
75
|
| `-n, --name <name>` | Server name (auto-inferred if not provided) |
|
|
72
76
|
| `-y, --yes` | Skip all confirmation prompts |
|
|
73
77
|
| `--all` | Install to all agents |
|
|
@@ -132,6 +136,11 @@ Note that some agents like Cursor and opencode do not require the `type` informa
|
|
|
132
136
|
Use `--header` to pass custom headers for remote servers. The flag can be repeated.
|
|
133
137
|
Header support is available for remote installs across all supported agents.
|
|
134
138
|
|
|
139
|
+
## Environment Variables
|
|
140
|
+
|
|
141
|
+
Use `--env` to pass environment variables for local stdio servers (packages/commands). The flag can be repeated and expects `KEY=VALUE`.
|
|
142
|
+
If `--env` is provided for a remote URL install, it is ignored with a warning.
|
|
143
|
+
|
|
135
144
|
## Supported Agents
|
|
136
145
|
|
|
137
146
|
MCP servers can be installed to any of these agents:
|
package/dist/index.js
CHANGED
|
@@ -229,6 +229,25 @@ function transformClineConfig(_serverName, config) {
|
|
|
229
229
|
}
|
|
230
230
|
return localConfig;
|
|
231
231
|
}
|
|
232
|
+
function transformAntigravityConfig(_serverName, config) {
|
|
233
|
+
if (config.url) {
|
|
234
|
+
const remoteConfig = {
|
|
235
|
+
serverUrl: config.url
|
|
236
|
+
};
|
|
237
|
+
if (config.headers && Object.keys(config.headers).length > 0) {
|
|
238
|
+
remoteConfig.headers = config.headers;
|
|
239
|
+
}
|
|
240
|
+
return remoteConfig;
|
|
241
|
+
}
|
|
242
|
+
const localConfig = {
|
|
243
|
+
command: config.command,
|
|
244
|
+
args: config.args || []
|
|
245
|
+
};
|
|
246
|
+
if (config.env && Object.keys(config.env).length > 0) {
|
|
247
|
+
localConfig.env = config.env;
|
|
248
|
+
}
|
|
249
|
+
return localConfig;
|
|
250
|
+
}
|
|
232
251
|
function transformGitHubCopilotCliConfig(_serverName, config, context) {
|
|
233
252
|
if (context?.local) {
|
|
234
253
|
return config;
|
|
@@ -278,11 +297,11 @@ var agents = {
|
|
|
278
297
|
// Global only - no project support
|
|
279
298
|
configKey: "mcpServers",
|
|
280
299
|
format: "json",
|
|
281
|
-
supportedTransports: ["stdio"],
|
|
282
|
-
unsupportedTransportMessage: "Antigravity only supports local (stdio) servers via its config file. Use mcp-remote to connect to remote servers.",
|
|
300
|
+
supportedTransports: ["stdio", "http", "sse"],
|
|
283
301
|
detectGlobalInstall: async () => {
|
|
284
302
|
return existsSync(join2(home, ".gemini"));
|
|
285
|
-
}
|
|
303
|
+
},
|
|
304
|
+
transformConfig: transformAntigravityConfig
|
|
286
305
|
},
|
|
287
306
|
cline: {
|
|
288
307
|
name: "cline",
|
|
@@ -927,28 +946,36 @@ function buildConfigWithKey(configKey, serverName, serverConfig) {
|
|
|
927
946
|
// src/installer.ts
|
|
928
947
|
function buildServerConfig(parsed, options = {}) {
|
|
929
948
|
if (parsed.type === "remote") {
|
|
930
|
-
const
|
|
949
|
+
const config2 = {
|
|
931
950
|
type: options.transport ?? "http",
|
|
932
951
|
url: parsed.value
|
|
933
952
|
};
|
|
934
953
|
if (options.headers && Object.keys(options.headers).length > 0) {
|
|
935
|
-
|
|
954
|
+
config2.headers = options.headers;
|
|
936
955
|
}
|
|
937
|
-
return
|
|
956
|
+
return config2;
|
|
938
957
|
}
|
|
939
958
|
if (parsed.type === "command") {
|
|
940
959
|
const parts = parsed.value.split(" ");
|
|
941
960
|
const command = parts[0];
|
|
942
961
|
const args = parts.slice(1);
|
|
943
|
-
|
|
962
|
+
const config2 = {
|
|
944
963
|
command,
|
|
945
964
|
args
|
|
946
965
|
};
|
|
966
|
+
if (options.env && Object.keys(options.env).length > 0) {
|
|
967
|
+
config2.env = options.env;
|
|
968
|
+
}
|
|
969
|
+
return config2;
|
|
947
970
|
}
|
|
948
|
-
|
|
971
|
+
const config = {
|
|
949
972
|
command: "npx",
|
|
950
973
|
args: ["-y", parsed.value]
|
|
951
974
|
};
|
|
975
|
+
if (options.env && Object.keys(options.env).length > 0) {
|
|
976
|
+
config.env = options.env;
|
|
977
|
+
}
|
|
978
|
+
return config;
|
|
952
979
|
}
|
|
953
980
|
function updateGitignoreWithPaths(paths, options = {}) {
|
|
954
981
|
const cwd = options.cwd || process.cwd();
|
|
@@ -1050,7 +1077,7 @@ function installServer(serverName, serverConfig, agentTypes, options = {}) {
|
|
|
1050
1077
|
// package.json
|
|
1051
1078
|
var package_default = {
|
|
1052
1079
|
name: "add-mcp",
|
|
1053
|
-
version: "1.
|
|
1080
|
+
version: "1.6.0",
|
|
1054
1081
|
description: "Add MCP servers to your favorite coding agents with a single command.",
|
|
1055
1082
|
author: "Andre Landgraf <andre@neon.tech>",
|
|
1056
1083
|
license: "Apache-2.0",
|
|
@@ -1186,6 +1213,25 @@ function parseHeaders(values) {
|
|
|
1186
1213
|
}
|
|
1187
1214
|
return { headers, invalid };
|
|
1188
1215
|
}
|
|
1216
|
+
function parseEnv(values) {
|
|
1217
|
+
const env = {};
|
|
1218
|
+
const invalid = [];
|
|
1219
|
+
for (const entry of values) {
|
|
1220
|
+
const separatorIndex = entry.indexOf("=");
|
|
1221
|
+
if (separatorIndex <= 0) {
|
|
1222
|
+
invalid.push(entry);
|
|
1223
|
+
continue;
|
|
1224
|
+
}
|
|
1225
|
+
const key = entry.slice(0, separatorIndex).trim();
|
|
1226
|
+
const value = entry.slice(separatorIndex + 1);
|
|
1227
|
+
if (!key) {
|
|
1228
|
+
invalid.push(entry);
|
|
1229
|
+
continue;
|
|
1230
|
+
}
|
|
1231
|
+
env[key] = value;
|
|
1232
|
+
}
|
|
1233
|
+
return { env, invalid };
|
|
1234
|
+
}
|
|
1189
1235
|
program.name("add-mcp").description(
|
|
1190
1236
|
"Install MCP servers for coding agents (Claude Code, Cursor, VS Code, OpenCode, Codex, and more \u2014 run list-agents for the full list)"
|
|
1191
1237
|
).version(version).argument("[target]", "MCP server URL (remote) or package name (local stdio)").option(
|
|
@@ -1202,6 +1248,11 @@ program.name("add-mcp").description(
|
|
|
1202
1248
|
"HTTP header for remote servers (repeatable, 'Key: Value')",
|
|
1203
1249
|
collect,
|
|
1204
1250
|
[]
|
|
1251
|
+
).option(
|
|
1252
|
+
"--env <env>",
|
|
1253
|
+
"Environment variable for local stdio servers (repeatable, 'KEY=VALUE')",
|
|
1254
|
+
collect,
|
|
1255
|
+
[]
|
|
1205
1256
|
).option("-y, --yes", "Skip confirmation prompts").option("--all", "Install to all agents").option("--gitignore", "Add generated project config files to .gitignore").action(async (target, options) => {
|
|
1206
1257
|
await main(target, options);
|
|
1207
1258
|
});
|
|
@@ -1302,6 +1353,21 @@ async function main(target, options) {
|
|
|
1302
1353
|
if (hasHeaderValues && !isRemote) {
|
|
1303
1354
|
p2.log.warn("--header is only used for remote URLs, ignoring");
|
|
1304
1355
|
}
|
|
1356
|
+
const envValues = options.env ?? [];
|
|
1357
|
+
const envResult = parseEnv(envValues);
|
|
1358
|
+
if (envResult.invalid.length > 0) {
|
|
1359
|
+
p2.log.error(
|
|
1360
|
+
`Invalid --env value(s): ${envResult.invalid.join(", ")}. Use "KEY=VALUE" format.`
|
|
1361
|
+
);
|
|
1362
|
+
process.exit(1);
|
|
1363
|
+
}
|
|
1364
|
+
const envKeys = Object.keys(envResult.env);
|
|
1365
|
+
const hasEnvValues = envKeys.length > 0;
|
|
1366
|
+
if (hasEnvValues && isRemote) {
|
|
1367
|
+
p2.log.warn(
|
|
1368
|
+
"--env is only used for local/package/command installs, ignoring"
|
|
1369
|
+
);
|
|
1370
|
+
}
|
|
1305
1371
|
const serverName = options.name || parsed.inferredName;
|
|
1306
1372
|
p2.log.info(`Server name: ${chalk.cyan(serverName)}`);
|
|
1307
1373
|
const transportValue = options.transport || options.type;
|
|
@@ -1321,7 +1387,8 @@ async function main(target, options) {
|
|
|
1321
1387
|
}
|
|
1322
1388
|
const serverConfig = buildServerConfig(parsed, {
|
|
1323
1389
|
transport: resolvedTransport,
|
|
1324
|
-
headers: isRemote && hasHeaderValues ? headerResult.headers : void 0
|
|
1390
|
+
headers: isRemote && hasHeaderValues ? headerResult.headers : void 0,
|
|
1391
|
+
env: !isRemote && hasEnvValues ? envResult.env : void 0
|
|
1325
1392
|
});
|
|
1326
1393
|
let targetAgents;
|
|
1327
1394
|
const allAgentTypes = getAgentTypes();
|