add-mcp 1.9.1 → 1.10.2

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/lib.d.ts ADDED
@@ -0,0 +1,102 @@
1
+ type AgentType = "antigravity" | "cline" | "cline-cli" | "claude-code" | "claude-desktop" | "codex" | "cursor" | "gemini-cli" | "goose" | "github-copilot-cli" | "mcporter" | "opencode" | "vscode" | "zed";
2
+ type ConfigFormat = "json" | "yaml" | "toml";
3
+ interface AgentConfig {
4
+ /** Internal name */
5
+ name: string;
6
+ /** Display name for UI */
7
+ displayName: string;
8
+ /** Global config file path */
9
+ configPath: string;
10
+ /** Local (project-level) config file path, if supported */
11
+ localConfigPath?: string;
12
+ /** Paths to check for project-level detection (relative to cwd) */
13
+ projectDetectPaths: string[];
14
+ /** Key in config file where MCP servers are stored (supports dot notation) */
15
+ configKey: string;
16
+ /** Optional key for project-level config when different from global configKey */
17
+ localConfigKey?: string;
18
+ /** Config file format */
19
+ format: ConfigFormat;
20
+ /** Supported transport types for this agent */
21
+ supportedTransports: ("stdio" | "sse" | "http")[];
22
+ /** Shown when a user tries to use an unsupported transport */
23
+ unsupportedTransportMessage?: string;
24
+ /** Function to detect if agent is installed globally */
25
+ detectGlobalInstall: () => Promise<boolean>;
26
+ /** Optional function to dynamically resolve config path */
27
+ resolveConfigPath?: (agent: AgentConfig, options: {
28
+ local: boolean;
29
+ cwd: string;
30
+ }) => string;
31
+ /** Optional function to transform server config to agent-specific format */
32
+ transformConfig?: (serverName: string, config: McpServerConfig, context?: {
33
+ local: boolean;
34
+ }) => unknown;
35
+ }
36
+ type TransportType = "sse" | "http";
37
+ interface McpServerConfig {
38
+ /** For remote servers */
39
+ type?: TransportType;
40
+ url?: string;
41
+ headers?: Record<string, string>;
42
+ /** For local stdio servers */
43
+ command?: string;
44
+ args?: string[];
45
+ env?: Record<string, string>;
46
+ }
47
+
48
+ interface InstallOptions {
49
+ /** Install to local (project-level) config instead of global */
50
+ local?: boolean;
51
+ /** Current working directory for local installs */
52
+ cwd?: string;
53
+ }
54
+ interface InstallResult {
55
+ success: boolean;
56
+ path: string;
57
+ error?: string;
58
+ }
59
+
60
+ declare const agents: Record<AgentType, AgentConfig>;
61
+ declare function getAgentTypes(): AgentType[];
62
+ declare function detectProjectAgents(cwd?: string): AgentType[];
63
+ declare function detectGlobalAgents(): Promise<AgentType[]>;
64
+
65
+ interface InstalledServer {
66
+ serverName: string;
67
+ config: Record<string, unknown>;
68
+ identity: string;
69
+ agentType: AgentType;
70
+ scope: "local" | "global";
71
+ configPath: string;
72
+ }
73
+ interface AgentServers {
74
+ agentType: AgentType;
75
+ displayName: string;
76
+ detected: boolean;
77
+ scope: "local" | "global";
78
+ configPath: string;
79
+ servers: InstalledServer[];
80
+ }
81
+ /**
82
+ * Gather installed servers across detected (or explicitly specified) agents.
83
+ * When `agents` is provided, those agents are included even if not detected
84
+ * (with detected=false).
85
+ */
86
+ declare function listInstalledServers(options: {
87
+ global?: boolean;
88
+ agents?: AgentType[];
89
+ cwd?: string;
90
+ }): Promise<AgentServers[]>;
91
+
92
+ type AgentInput = AgentType | (string & {});
93
+ declare function upsertServer(agentType: AgentInput, serverName: string, serverConfig: McpServerConfig, options?: InstallOptions): InstallResult;
94
+ interface RemoveServerResult {
95
+ success: boolean;
96
+ path: string;
97
+ removed: boolean;
98
+ error?: string;
99
+ }
100
+ declare function removeServer(agentType: AgentInput, serverName: string, options?: InstallOptions): RemoveServerResult;
101
+
102
+ export { type AgentConfig, type AgentInput, type AgentServers, type AgentType, type InstallOptions, type InstallResult, type InstalledServer, type McpServerConfig, type RemoveServerResult, agents, detectGlobalAgents, detectProjectAgents, getAgentTypes, listInstalledServers, removeServer, upsertServer };
package/dist/lib.js ADDED
@@ -0,0 +1,79 @@
1
+ import {
2
+ agents,
3
+ detectGlobalAgents,
4
+ detectProjectAgents,
5
+ getAgentTypes,
6
+ getConfigKey,
7
+ getConfigPath2 as getConfigPath,
8
+ getNestedValue,
9
+ installServerForAgent,
10
+ listInstalledServers,
11
+ readConfig,
12
+ removeServerFromConfig
13
+ } from "./chunk-B27GVIBZ.js";
14
+
15
+ // src/lib.ts
16
+ import { existsSync } from "fs";
17
+ function isKnownAgent(agentType) {
18
+ return Object.prototype.hasOwnProperty.call(agents, agentType);
19
+ }
20
+ function validate(agentType, local) {
21
+ if (!isKnownAgent(agentType)) {
22
+ return `Unknown agent type: ${String(agentType)}`;
23
+ }
24
+ if (local && !agents[agentType].localConfigPath) {
25
+ return `${agentType} does not support project-level config`;
26
+ }
27
+ return null;
28
+ }
29
+ function upsertServer(agentType, serverName, serverConfig, options = {}) {
30
+ const error = validate(agentType, options.local);
31
+ if (error) return { success: false, path: "", error };
32
+ return installServerForAgent(
33
+ serverName,
34
+ serverConfig,
35
+ agentType,
36
+ options
37
+ );
38
+ }
39
+ function hasServer(serversObj, serverName) {
40
+ return !!serversObj && typeof serversObj === "object" && !Array.isArray(serversObj) && Object.prototype.hasOwnProperty.call(serversObj, serverName);
41
+ }
42
+ function doRemove(agentType, serverName, options) {
43
+ const agent = agents[agentType];
44
+ const configPath = getConfigPath(agent, options);
45
+ const configKey = getConfigKey(agent, options);
46
+ if (!existsSync(configPath)) {
47
+ return { success: true, path: configPath, removed: false };
48
+ }
49
+ const fullConfig = readConfig(configPath, agent.format);
50
+ if (!hasServer(getNestedValue(fullConfig, configKey), serverName)) {
51
+ return { success: true, path: configPath, removed: false };
52
+ }
53
+ removeServerFromConfig(configPath, agent.format, configKey, serverName);
54
+ return { success: true, path: configPath, removed: true };
55
+ }
56
+ function removeServer(agentType, serverName, options = {}) {
57
+ const error = validate(agentType, options.local);
58
+ if (error) return { success: false, path: "", removed: false, error };
59
+ const known = agentType;
60
+ try {
61
+ return doRemove(known, serverName, options);
62
+ } catch (e) {
63
+ return {
64
+ success: false,
65
+ path: getConfigPath(agents[known], options),
66
+ removed: false,
67
+ error: e instanceof Error ? e.message : "Unknown error"
68
+ };
69
+ }
70
+ }
71
+ export {
72
+ agents,
73
+ detectGlobalAgents,
74
+ detectProjectAgents,
75
+ getAgentTypes,
76
+ listInstalledServers,
77
+ removeServer,
78
+ upsertServer
79
+ };
package/package.json CHANGED
@@ -1,10 +1,19 @@
1
1
  {
2
2
  "name": "add-mcp",
3
- "version": "1.9.1",
3
+ "version": "1.10.2",
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
+ "main": "./dist/lib.js",
9
+ "types": "./dist/lib.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/lib.d.ts",
13
+ "import": "./dist/lib.js"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
8
17
  "bin": {
9
18
  "add-mcp": "dist/index.js"
10
19
  },
@@ -14,10 +23,10 @@
14
23
  ],
15
24
  "scripts": {
16
25
  "fmt": "prettier --write .",
17
- "build": "tsup src/index.ts --format esm --dts --clean",
26
+ "build": "tsup src/index.ts src/lib.ts --format esm --dts --clean",
18
27
  "dev": "tsx src/index.ts",
19
- "test": "tsx tests/source-parser.test.ts && tsx tests/agents.test.ts && tsx tests/config.test.ts && tsx tests/installer.test.ts && tsx tests/find.test.ts && tsx tests/package-arguments.test.ts && tsx tests/template.test.ts && tsx tests/reader.test.ts && tsx tests/formats-remove.test.ts && tsx tests/e2e/install.test.ts && tsx tests/e2e/cli.test.ts",
20
- "test:unit": "tsx tests/source-parser.test.ts && tsx tests/agents.test.ts && tsx tests/config.test.ts && tsx tests/installer.test.ts && tsx tests/find.test.ts && tsx tests/package-arguments.test.ts && tsx tests/template.test.ts && tsx tests/reader.test.ts && tsx tests/formats-remove.test.ts",
28
+ "test": "tsx tests/source-parser.test.ts && tsx tests/agents.test.ts && tsx tests/config.test.ts && tsx tests/installer.test.ts && tsx tests/find.test.ts && tsx tests/package-arguments.test.ts && tsx tests/template.test.ts && tsx tests/reader.test.ts && tsx tests/formats-remove.test.ts && tsx tests/lib.test.ts && tsx tests/e2e/install.test.ts && tsx tests/e2e/cli.test.ts",
29
+ "test:unit": "tsx tests/source-parser.test.ts && tsx tests/agents.test.ts && tsx tests/config.test.ts && tsx tests/installer.test.ts && tsx tests/find.test.ts && tsx tests/package-arguments.test.ts && tsx tests/template.test.ts && tsx tests/reader.test.ts && tsx tests/formats-remove.test.ts && tsx tests/lib.test.ts",
21
30
  "registry:sort": "tsx scripts/sort-registry.ts",
22
31
  "registry:verify": "tsx scripts/verify-registry.ts",
23
32
  "test:e2e": "tsx tests/e2e/install.test.ts && tsx tests/e2e/cli.test.ts",