TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/neon-solutions/add-mcp/llms.txt
Use this file to discover all available pages before exploring further.
add-mcp package ships a fully typed programmatic API that lets you integrate MCP server management directly into your own CLI tools, setup scripts, or Node.js applications — no shell invocation required. Every public function is exported from the add-mcp package entry point and mirrors the behaviour of the CLI commands.
Installation
Public API Reference
upsertServer
Creates or updates an MCP server entry in an agent’s configuration file. If the server already exists it is overwritten with the new config; otherwise it is created. The function is synchronous and never throws — errors are returned in the result object.
The target agent identifier, e.g.
'cursor', 'claude-code', 'vscode'. Accepts any AgentType literal or an arbitrary string that is validated at runtime with a descriptive error message. See AgentType for the full list.The key under which the server is stored in the config file (e.g.
'context7', 'postgres'). Must be unique within the agent’s MCP servers list.The server configuration object. Use
url for remote servers and command / args for local stdio servers. See McpServerConfig for the full shape.Optional install options.
InstallResult:
true if the server was written successfully, false on error.Absolute path to the config file that was written (or attempted).
Human-readable error message. Only present when
success is false.upsertServer and removeServer never throw exceptions. Always inspect the success field before assuming the operation succeeded.removeServer
Removes an MCP server entry from an agent’s configuration file. If the file does not exist, or the server is not present in the config, the function still returns success: true with removed: false — a missing server is not treated as an error.
The target agent identifier.
The server key to remove.
Same
local / cwd options as upsertServer.RemoveServerResult:
true unless an unexpected filesystem error occurred.Absolute path to the config file that was examined.
true if the server existed and was removed. false if the config file did not exist or the server was not present (not an error condition).Error message, only present when
success is false.listInstalledServers
Gathers installed MCP servers across all detected or explicitly specified agents. Detects project-level agents by scanning for config files in cwd, or globally-installed agents by checking known install paths and binaries.
When
true, lists servers from global user configs instead of project-level configs.Explicit list of agents to include. Agents in this list are always returned even if not detected; non-detected agents will have an empty
servers array and detected: false.Working directory for project-level detection. Defaults to
process.cwd().Promise<AgentServers[]>:
The agent identifier string.
Human-readable agent name, e.g.
'Cursor', 'Claude Code'.Whether the agent was detected in the environment (config file or binary present).
Whether the result reflects project-level or global config.
Absolute path to the agent’s config file.
Array of servers found in this agent’s config. Each entry includes
serverName, config, identity, agentType, scope, and configPath.detectProjectAgents
Synchronously returns the list of agent types that have project-level config files in the given directory.
Directory to scan for project-level config files. Defaults to
process.cwd().AgentType[] — agent types whose config files (e.g. .cursor/mcp.json, .mcp.json) exist under cwd.
detectGlobalAgents
Asynchronously returns the list of agent types that are installed globally on the machine. Detection checks for known config directories and binary presence.
Promise<AgentType[]> — agent types detected globally.
agents
An object mapping every AgentType string to its full AgentConfig descriptor — display name, config file paths, supported transports, config format, and more.
getAgentTypes
Returns all supported agent type strings as an array. Useful for building selectors or validation lists.
AgentType[] — all 15 supported agent identifiers.