add-mcp 0.1.0 → 0.1.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.
Files changed (3) hide show
  1. package/README.md +110 -91
  2. package/dist/index.js +69 -26
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,132 +2,151 @@
2
2
 
3
3
  Install MCP servers onto coding agents with a single command.
4
4
 
5
- ```bash
6
- npx add-mcp <target>
7
- ```
8
-
9
- Supports Opencode, Claude Code, Codex, Cursor, and [more](https://github.com/neondatabase/add-mcp/blob/main/README.md#supported-agents).
5
+ <!-- agent-list:start -->
10
6
 
11
- ## Features
7
+ Supports **OpenCode**, **Claude Code**, **Codex**, **Cursor**, and [5 more](#supported-agents).
12
8
 
13
- - Install MCP servers to multiple AI coding agents at once
14
- - Supports both remote (HTTP/SSE) and local (stdio) MCP servers
15
- - Handles different config formats (JSON, YAML, TOML)
16
- - Supports project-level and global installation
9
+ <!-- agent-list:end -->
17
10
 
18
- ## Usage
19
-
20
- ### Remote MCP Server (HTTP)
11
+ ## Install an MCP Server
21
12
 
22
13
  ```bash
23
- # Install a remote MCP server
24
- npx add-mcp https://mcp.example.com/api
25
-
26
- # With custom name
27
- npx add-mcp https://mcp.example.com/api --name my-server
14
+ npx add-mcp https://mcp.example.com/sse
28
15
  ```
29
16
 
30
- ### Local MCP Server (Package)
17
+ ### Source Formats
31
18
 
32
19
  ```bash
33
- # Install from npm package
34
- npx add-mcp @modelcontextprotocol/server-postgres
20
+ # Remote MCP server (HTTP streamable - default)
21
+ npx add-mcp https://mcp.example.com/mcp
35
22
 
36
- # Install with custom name
37
- npx add-mcp mcp-server-github --name github
38
- ```
23
+ # Remote MCP server (SSE transport)
24
+ npx add-mcp https://mcp.example.com/sse --transport sse
39
25
 
40
- ### Local MCP Server (Command)
26
+ # npm package (runs via npx)
27
+ npx add-mcp @modelcontextprotocol/server-postgres
41
28
 
42
- ```bash
43
- # Install with full command
29
+ # Full command with arguments
44
30
  npx add-mcp "npx -y @org/mcp-server --flag value"
45
31
 
46
32
  # Node.js script
47
33
  npx add-mcp "node /path/to/server.js --port 3000"
48
34
  ```
49
35
 
50
- ## Options
36
+ ### Options
51
37
 
38
+ | Option | Description |
39
+ | ------------------------ | ------------------------------------------------------------------------ |
40
+ | `-g, --global` | Install to user directory instead of project |
41
+ | `-a, --agent <agent>` | Target specific agents (e.g., `cursor`, `claude-code`). Can be repeated. |
42
+ | `-t, --transport <type>` | Transport type for remote servers: `http` (default), `sse` |
43
+ | `--type <type>` | Alias for `--transport` |
44
+ | `-n, --name <name>` | Server name (auto-inferred if not provided) |
45
+ | `-y, --yes` | Skip all confirmation prompts |
46
+ | `--all` | Install to all agents without prompts |
47
+
48
+ ### Examples
49
+
50
+ ```bash
51
+ # Install to specific agents
52
+ npx add-mcp https://mcp.example.com/mcp -a cursor -a claude-code
53
+
54
+ # Install with SSE transport
55
+ npx add-mcp https://mcp.neon.tech/sse --transport sse
56
+
57
+ # Install with custom server name
58
+ npx add-mcp @modelcontextprotocol/server-postgres --name postgres
59
+
60
+ # Non-interactive installation (CI/CD friendly)
61
+ npx add-mcp https://mcp.example.com/mcp -g -a claude-code -y
62
+
63
+ # Install to all agents without prompts
64
+ npx add-mcp mcp-server-github --all
52
65
  ```
53
- Usage: add-mcp [options] [target]
54
-
55
- Arguments:
56
- target MCP server URL (remote) or package name (local stdio)
57
-
58
- Options:
59
- -V, --version output the version number
60
- -g, --global Install globally (user-level) instead of project-level
61
- -a, --agent <agents...> Specify agents to install to
62
- -n, --name <name> Server name (auto-inferred from target if not provided)
63
- -y, --yes Skip confirmation prompts
64
- -l, --list List supported agents
65
- --all Install to all agents without prompts (implies -y -g)
66
- -h, --help display help for command
67
- ```
66
+
67
+ ### Installation Scope
68
+
69
+ | Scope | Flag | Location | Use Case |
70
+ | ----------- | --------- | ----------------------- | --------------------------------------------- |
71
+ | **Project** | (default) | `.cursor/mcp.json` etc. | Committed with your project, shared with team |
72
+ | **Global** | `-g` | `~/.cursor/mcp.json` | Available across all projects |
73
+
74
+ ## Transport Types
75
+
76
+ MCP supports different transport mechanisms for remote servers:
77
+
78
+ | Transport | Flag | Description |
79
+ | --------- | ------------------ | ---------------------------------------------- |
80
+ | **HTTP** | `--transport http` | Streamable HTTP (default, modern standard) |
81
+ | **SSE** | `--transport sse` | Server-Sent Events (legacy, still widely used) |
82
+
83
+ Local servers (npm packages, commands) always use **stdio** transport.
68
84
 
69
85
  ## Supported Agents
70
86
 
71
- <!-- AGENTS_TABLE_START -->
87
+ MCP servers can be installed to any of these agents:
72
88
 
73
- | Agent | CLI Key | Format | Local Support |
74
- | -------------- | ---------------- | ------ | ------------- |
75
- | Claude Code | `claude-code` | JSON | Yes |
76
- | Claude Desktop | `claude-desktop` | JSON | No |
77
- | Codex | `codex` | TOML | No |
78
- | Cursor | `cursor` | JSON | Yes |
79
- | Gemini CLI | `gemini-cli` | JSON | Yes |
80
- | Goose | `goose` | YAML | No |
81
- | OpenCode | `opencode` | JSON | Yes |
82
- | VS Code | `vscode` | JSON | Yes |
83
- | Zed | `zed` | JSON | No |
89
+ <!-- supported-agents:start -->
84
90
 
85
- <!-- AGENTS_TABLE_END -->
91
+ | Agent | `--agent` | Project Path | Global Path |
92
+ | -------------- | ---------------- | ----------------------- | ----------------------------------------------------------------- |
93
+ | Claude Code | `claude-code` | `.mcp.json` | `~/.claude.json` |
94
+ | Claude Desktop | `claude-desktop` | - | `~/Library/Application Support/Claude/claude_desktop_config.json` |
95
+ | Codex | `codex` | - | `~/.codex/config.toml` |
96
+ | Cursor | `cursor` | `.cursor/mcp.json` | `~/.cursor/mcp.json` |
97
+ | Gemini CLI | `gemini-cli` | `.gemini/settings.json` | `~/.gemini/settings.json` |
98
+ | Goose | `goose` | - | `~/.config/goose/config.yaml` |
99
+ | OpenCode | `opencode` | `.opencode.json` | `~/.config/opencode/opencode.json` |
100
+ | VS Code | `vscode` | `.vscode/mcp.json` | `~/Library/Application Support/Code/User/mcp.json` |
101
+ | Zed | `zed` | - | `~/.config/zed/settings.json` |
102
+
103
+ <!-- supported-agents:end -->
86
104
 
87
105
  **Aliases:** `github-copilot` → `vscode`
88
106
 
89
- ## Examples
107
+ The CLI automatically detects which coding agents you have installed. If none are detected, you'll be prompted to select which agents to install to.
90
108
 
91
- ### Install to specific agents
109
+ ### Transport Support
92
110
 
93
- ```bash
94
- # Install to Cursor and Claude Code only
95
- npx add-mcp https://mcp.example.com/api -a cursor claude-code
111
+ Not all agents support all transport types:
96
112
 
97
- # Install to VS Code (using alias)
98
- npx add-mcp mcp-server -a github-copilot
99
- ```
113
+ | Agent | stdio | http | sse |
114
+ | -------------- | ----- | ---- | --- |
115
+ | Claude Code | ✓ | ✓ | ✓ |
116
+ | Claude Desktop | ✓ | ✓ | ✓ |
117
+ | Codex | ✓ | ✓ | ✓ |
118
+ | Cursor | ✓ | ✓ | ✓ |
119
+ | Gemini CLI | ✓ | ✓ | ✓ |
120
+ | Goose | ✓ | ✓ | ✗ |
121
+ | OpenCode | ✓ | ✓ | ✓ |
122
+ | VS Code | ✓ | ✓ | ✓ |
123
+ | Zed | ✓ | ✓ | ✓ |
100
124
 
101
- ### Project vs Global installation
125
+ ## What are MCP Servers?
102
126
 
103
- ```bash
104
- # Project-level (creates .cursor/mcp.json, .mcp.json, etc.)
105
- npx add-mcp mcp-server
127
+ [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) servers extend your coding agent's capabilities by providing tools, resources, and context. MCP servers can:
106
128
 
107
- # Global (installs to ~/.cursor/mcp.json, ~/.claude.json, etc.)
108
- npx add-mcp mcp-server --global
109
- ```
129
+ - Connect to databases (PostgreSQL, MySQL, etc.)
130
+ - Integrate with external services (GitHub, Linear, Notion)
131
+ - Provide file system access
132
+ - Offer specialized tools for your workflow
110
133
 
111
- ### Non-interactive mode
134
+ ## Troubleshooting
112
135
 
113
- ```bash
114
- # Skip all prompts, install globally to all detected agents
115
- npx add-mcp https://mcp.example.com/api -y -g
136
+ ### Transport mismatch error
116
137
 
117
- # Install to all agents without any prompts
118
- npx add-mcp mcp-server --all
119
- ```
138
+ If you get an error about transport not being supported, check that the agent supports your chosen transport type. For example, Goose doesn't support SSE transport.
139
+
140
+ ### Server not loading
141
+
142
+ - Verify the server URL is correct and accessible
143
+ - Check the agent's MCP configuration file for syntax errors
144
+ - Ensure the server name doesn't conflict with existing servers
145
+
146
+ ### Permission errors
147
+
148
+ Ensure you have write access to the target configuration directory.
149
+
150
+ ## License
120
151
 
121
- ## Config File Locations
122
-
123
- | Agent | Global | Local |
124
- | -------------- | ----------------------------------------------------------------- | ----------------------- |
125
- | Claude Code | `~/.claude.json` | `.mcp.json` |
126
- | Claude Desktop | `~/Library/Application Support/Claude/claude_desktop_config.json` | - |
127
- | Codex | `~/.codex/config.toml` | - |
128
- | Cursor | `~/.cursor/mcp.json` | `.cursor/mcp.json` |
129
- | Gemini CLI | `~/.gemini/settings.json` | `.gemini/settings.json` |
130
- | Goose | `~/.config/goose/config.yaml` | - |
131
- | OpenCode | `~/.config/opencode/opencode.json` | `.opencode.json` |
132
- | VS Code | `~/Library/Application Support/Code/User/mcp.json` | `.vscode/mcp.json` |
133
- | Zed | `~/.config/zed/settings.json` | - |
152
+ Apache 2.0
package/dist/index.js CHANGED
@@ -42,11 +42,9 @@ function transformGooseConfig(serverName, config) {
42
42
  if (config.url) {
43
43
  return {
44
44
  name: serverName,
45
- cmd: "echo",
46
- args: [`Remote MCP servers not directly supported. URL: ${config.url}`],
47
- enabled: false,
48
- envs: {},
49
- type: "stdio",
45
+ type: "streamable_http",
46
+ url: config.url,
47
+ enabled: true,
50
48
  timeout: 300
51
49
  };
52
50
  }
@@ -115,6 +113,7 @@ var agents = {
115
113
  localConfigPath: ".mcp.json",
116
114
  configKey: "mcpServers",
117
115
  format: "json",
116
+ supportedTransports: ["stdio", "http", "sse"],
118
117
  detectInstalled: async () => {
119
118
  return existsSync(join(home, ".claude"));
120
119
  }
@@ -125,6 +124,7 @@ var agents = {
125
124
  configPath: join(appSupport, "Claude", "claude_desktop_config.json"),
126
125
  configKey: "mcpServers",
127
126
  format: "json",
127
+ supportedTransports: ["stdio", "http", "sse"],
128
128
  detectInstalled: async () => {
129
129
  return existsSync(join(appSupport, "Claude"));
130
130
  }
@@ -138,6 +138,7 @@ var agents = {
138
138
  ),
139
139
  configKey: "mcp_servers",
140
140
  format: "toml",
141
+ supportedTransports: ["stdio", "http", "sse"],
141
142
  detectInstalled: async () => {
142
143
  return existsSync(join(home, ".codex"));
143
144
  },
@@ -150,6 +151,7 @@ var agents = {
150
151
  localConfigPath: ".cursor/mcp.json",
151
152
  configKey: "mcpServers",
152
153
  format: "json",
154
+ supportedTransports: ["stdio", "http", "sse"],
153
155
  detectInstalled: async () => {
154
156
  return existsSync(join(home, ".cursor"));
155
157
  }
@@ -161,6 +163,7 @@ var agents = {
161
163
  localConfigPath: ".gemini/settings.json",
162
164
  configKey: "mcpServers",
163
165
  format: "json",
166
+ supportedTransports: ["stdio", "http", "sse"],
164
167
  detectInstalled: async () => {
165
168
  return existsSync(join(home, ".gemini"));
166
169
  }
@@ -171,6 +174,8 @@ var agents = {
171
174
  configPath: join(home, ".config", "goose", "config.yaml"),
172
175
  configKey: "extensions",
173
176
  format: "yaml",
177
+ supportedTransports: ["stdio", "http"],
178
+ // Goose does not support SSE
174
179
  detectInstalled: async () => {
175
180
  return existsSync(join(home, ".config", "goose"));
176
181
  },
@@ -183,6 +188,7 @@ var agents = {
183
188
  localConfigPath: ".opencode.json",
184
189
  configKey: "mcp",
185
190
  format: "json",
191
+ supportedTransports: ["stdio", "http", "sse"],
186
192
  detectInstalled: async () => {
187
193
  return existsSync(join(home, ".config", "opencode"));
188
194
  },
@@ -195,6 +201,7 @@ var agents = {
195
201
  localConfigPath: ".vscode/mcp.json",
196
202
  configKey: "mcpServers",
197
203
  format: "json",
204
+ supportedTransports: ["stdio", "http", "sse"],
198
205
  detectInstalled: async () => {
199
206
  return existsSync(vscodePath);
200
207
  }
@@ -209,6 +216,7 @@ var agents = {
209
216
  ) : join(home, ".config", "zed", "settings.json"),
210
217
  configKey: "context_servers",
211
218
  format: "json",
219
+ supportedTransports: ["stdio", "http", "sse"],
212
220
  detectInstalled: async () => {
213
221
  return existsSync(join(home, ".config", "zed")) || existsSync(join(process.env.APPDATA || "", "Zed"));
214
222
  },
@@ -227,6 +235,9 @@ async function detectInstalledAgents() {
227
235
  }
228
236
  return installed;
229
237
  }
238
+ function isTransportSupported(agentType, transport) {
239
+ return agents[agentType].supportedTransports.includes(transport);
240
+ }
230
241
 
231
242
  // src/source-parser.ts
232
243
  function isUrl(input) {
@@ -532,10 +543,10 @@ function buildConfigWithKey(configKey, serverName, serverConfig) {
532
543
  }
533
544
 
534
545
  // src/installer.ts
535
- function buildServerConfig(parsed) {
546
+ function buildServerConfig(parsed, options = {}) {
536
547
  if (parsed.type === "remote") {
537
548
  return {
538
- type: "http",
549
+ type: options.transport ?? "http",
539
550
  url: parsed.value
540
551
  };
541
552
  }
@@ -607,7 +618,7 @@ function getAgentsWithLocalSupport() {
607
618
  // package.json
608
619
  var package_default = {
609
620
  name: "add-mcp",
610
- version: "0.1.0",
621
+ version: "0.1.1",
611
622
  description: "Install MCP servers onto coding agents (Claude Code, Cursor, VS Code, OpenCode, Codex)",
612
623
  author: "Andre Landgraf <andre@neon.tech>",
613
624
  license: "Apache-2.0",
@@ -692,15 +703,21 @@ function resolveAgentType(input) {
692
703
  }
693
704
  return null;
694
705
  }
706
+ function collect(value, previous) {
707
+ return previous.concat([value]);
708
+ }
695
709
  program.name("add-mcp").description(
696
710
  "Install MCP servers onto coding agents (Claude Code, Cursor, VS Code, OpenCode, Codex)"
697
711
  ).version(version).argument("[target]", "MCP server URL (remote) or package name (local stdio)").option(
698
712
  "-g, --global",
699
713
  "Install globally (user-level) instead of project-level"
700
- ).option("-a, --agent <agents...>", "Specify agents to install to").option(
714
+ ).option("-a, --agent <agent>", "Specify agents to install to", collect, []).option(
701
715
  "-n, --name <name>",
702
716
  "Server name (auto-inferred from target if not provided)"
703
- ).option("-y, --yes", "Skip confirmation prompts").option("-l, --list", "List supported agents").option("--all", "Install to all agents without prompts (implies -y -g)").action(async (target, options) => {
717
+ ).option(
718
+ "-t, --transport <type>",
719
+ "Transport type for remote servers (http, sse)"
720
+ ).option("--type <type>", "Alias for --transport").option("-y, --yes", "Skip confirmation prompts").option("--all", "Install to all agents without prompts (implies -y -g)").action(async (target, options) => {
704
721
  await main(target, options);
705
722
  });
706
723
  program.parse();
@@ -711,21 +728,6 @@ async function main(target, options) {
711
728
  }
712
729
  console.log();
713
730
  p.intro(chalk.bgCyan.black(" add-mcp "));
714
- if (options.list) {
715
- console.log();
716
- p.log.step(chalk.bold("Supported Agents"));
717
- const allTypes = getAgentTypes();
718
- for (const type of allTypes) {
719
- const agent = agents[type];
720
- const hasLocal = agent.localConfigPath ? chalk.dim(" (supports local)") : "";
721
- p.log.message(` ${chalk.cyan(type)} - ${agent.displayName}${hasLocal}`);
722
- }
723
- console.log();
724
- p.log.info(chalk.dim("Aliases: github-copilot \u2192 vscode"));
725
- console.log();
726
- p.outro("Use -a/--agent to specify agents");
727
- return;
728
- }
729
731
  if (!target) {
730
732
  p.log.error("Missing required argument: target");
731
733
  console.log();
@@ -752,7 +754,24 @@ async function main(target, options) {
752
754
  spinner2.stop(`Source: ${chalk.cyan(parsed.value)} (${sourceType})`);
753
755
  const serverName = options.name || parsed.inferredName;
754
756
  p.log.info(`Server name: ${chalk.cyan(serverName)}`);
755
- const serverConfig = buildServerConfig(parsed);
757
+ const transportValue = options.transport || options.type;
758
+ let resolvedTransport;
759
+ if (transportValue) {
760
+ const validTransports = ["http", "sse"];
761
+ if (!validTransports.includes(transportValue)) {
762
+ p.log.error(
763
+ `Invalid transport: ${transportValue}. Valid options: ${validTransports.join(", ")}`
764
+ );
765
+ process.exit(1);
766
+ }
767
+ resolvedTransport = transportValue;
768
+ if (!isRemoteSource(parsed)) {
769
+ p.log.warn("--transport is only used for remote URLs, ignoring");
770
+ }
771
+ }
772
+ const serverConfig = buildServerConfig(parsed, {
773
+ transport: resolvedTransport
774
+ });
756
775
  let targetAgents;
757
776
  const allAgentTypes = getAgentTypes();
758
777
  if (options.agent && options.agent.length > 0) {
@@ -827,6 +846,30 @@ async function main(target, options) {
827
846
  targetAgents = selected;
828
847
  }
829
848
  }
849
+ const requiredTransport = isRemoteSource(parsed) ? resolvedTransport ?? "http" : "stdio";
850
+ const unsupportedAgents = targetAgents.filter(
851
+ (a) => !isTransportSupported(a, requiredTransport)
852
+ );
853
+ if (unsupportedAgents.length > 0) {
854
+ const unsupportedNames = unsupportedAgents.map((a) => agents[a].displayName).join(", ");
855
+ if (options.all) {
856
+ p.log.warn(
857
+ `Skipping agents that don't support ${requiredTransport} transport: ${unsupportedNames}`
858
+ );
859
+ targetAgents = targetAgents.filter(
860
+ (a) => isTransportSupported(a, requiredTransport)
861
+ );
862
+ if (targetAgents.length === 0) {
863
+ p.log.error("No agents support this transport type");
864
+ process.exit(1);
865
+ }
866
+ } else {
867
+ p.log.error(
868
+ `The following agents don't support ${requiredTransport} transport: ${unsupportedNames}`
869
+ );
870
+ process.exit(1);
871
+ }
872
+ }
830
873
  let installGlobally = options.global ?? false;
831
874
  if (options.global === void 0 && !options.yes) {
832
875
  const localSupported = getAgentsWithLocalSupport();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "add-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Install MCP servers onto coding agents (Claude Code, Cursor, VS Code, OpenCode, Codex)",
5
5
  "author": "Andre Landgraf <andre@neon.tech>",
6
6
  "license": "Apache-2.0",