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/README.md CHANGED
@@ -359,6 +359,47 @@ npx add-mcp sync -g -y
359
359
 
360
360
  `unify` is an alias for `sync`.
361
361
 
362
+ ## Programmatic API
363
+
364
+ ```ts
365
+ import {
366
+ detectProjectAgents,
367
+ detectGlobalAgents,
368
+ upsertServer,
369
+ removeServer,
370
+ listInstalledServers,
371
+ } from "add-mcp";
372
+
373
+ const project = detectProjectAgents("/path/to/project");
374
+ const global = await detectGlobalAgents();
375
+
376
+ // Remote server
377
+ upsertServer(
378
+ "claude-code",
379
+ "example",
380
+ { type: "http", url: "https://mcp.example.com/api" },
381
+ { local: true, cwd: "/path/to/project" },
382
+ );
383
+
384
+ // Stdio (npm package)
385
+ upsertServer("claude-code", "postgres", {
386
+ command: "npx",
387
+ args: ["-y", "@modelcontextprotocol/server-postgres"],
388
+ });
389
+
390
+ const projectServers = await listInstalledServers({
391
+ cwd: "/path/to/project",
392
+ });
393
+ const globalServers = await listInstalledServers({ global: true });
394
+
395
+ removeServer("claude-code", "example", {
396
+ local: true,
397
+ cwd: "/path/to/project",
398
+ });
399
+ ```
400
+
401
+ `upsertServer` and `removeServer` return `{ success, path, error? }` rather than throwing.
402
+
362
403
  ## Troubleshooting
363
404
 
364
405
  ### Server not loading