npmswitch
Provides tools for interacting with the npm registry across multiple npm accounts, routing each call to the correct account/token. It supports account listing and identity checks, package search, package metadata lookup, download statistics, package listing, deprecation, dist-tag management, and safe publishing with dry-run defaults.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@npmswitchpublish the current package to npm using my work account"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
An MCP server and CLI for the npm registry that manages multiple accounts (personal, org, scoped) and routes each call to the right token. It speaks plain MCP over stdio, so it works with any MCP-capable agent: Claude Code and Desktop, Cursor, GitHub Copilot (VS Code), Windsurf, Cline, Gemini CLI, Codex CLI, opencode, Continue, Hermes Agent, Zed and others.
Sibling of Octoswitch, the same idea for GitHub accounts. Not affiliated with or endorsed by npm, Inc. or GitHub.
Why
The npm CLI keeps one login at a time. This keeps several named accounts and picks one per call:
an explicit
accountargument (name or npm username), elsethe account whose username or
--scopesmatch the package scope (@acme/tooluses the account that owns@acme), elsethe default account.
Related MCP server: pkg-booper
Setup
git clone https://github.com/ApiCartOps/npmswitch.git
cd npmswitch
npm install
npm link # puts the `npmswitch` command on your PATH
npmswitch add personal --default
npmswitch add work --scopes=@acme,@tools
npmswitch list NAME LOGIN SCOPES
* personal alice
work bob @acme @toolsWithout npm link, run node src/cli.js in place of npmswitch. From npm, npm install -g @apicartops/npmswitch installs the same npmswitch command (the package is scoped because npm rejects npmswitch as too similar to an existing package).
add asks for the token at a hidden prompt (or reads it from an env var with --token-env=VAR), checks it against the registry and stores the username. Tokens are never passed on the command line, never printed, and never returned by any tool. They are stored in ~/.npmswitch/accounts.json (file mode 600).
Tokens. Create one per account at npmjs.com under Access Tokens. A read-only token is enough for lookups. For deprecate, dist-tags and publish, use a granular token with read and write on the packages, or an automation token. Accounts that require a one-time code work too: pass it as otp.
Connect it to your agent
npmswitch agents # what is supported, and what looks installed
npmswitch install cursor # or: claude-code, vscode, codex, gemini-cli, ... or: all
npmswitch install cursor --dry-run
npmswitch config hermes # print the snippet instead of editing anythinginstall merges one entry into the agent's user-level MCP config and leaves everything else in the file alone. It refuses to touch a file it cannot parse (for example JSON with comments) and prints the snippet instead. uninstall <agent> removes it. Restart the agent afterwards.
Agent | Id | What |
Claude Code |
|
|
Claude Desktop |
|
|
Cursor |
|
|
VS Code / GitHub Copilot |
|
|
Windsurf |
|
|
Cline |
|
|
Gemini CLI |
|
|
opencode |
|
|
Codex CLI |
|
|
Continue |
|
|
Hermes Agent |
| prints a YAML snippet for |
Zed |
| prints a snippet for |
anything else |
| prints the standard |
Config locations differ between versions of these tools, so check the printed path if an agent does not pick it up. Use --npx to register npx -y @apicartops/npmswitch mcp instead of a path to this checkout (once published), and --name=NAME to use a different server name.
Project instructions
npmswitch init # AGENTS.md, plus any of CLAUDE.md / GEMINI.md / copilot / cursor rule that already exist
npmswitch init --all # write all fiveThis adds a short, marked block telling the agent to use the npm_* tools and to confirm before any write. Re-running updates the block in place.
What it exposes
Tools (all agents):
Read | Write (change a public registry; agents are told to confirm first) |
|
|
Publishing is safe by default. npm_publish is a dry run unless dry_run: false is passed, and its description tells agents to show you the account, name, version and file list and to wait for a yes before publishing for real. A published version can never be reused. The token reaches npm through a temporary config file (mode 600) that is deleted afterwards, never on the command line, and is scrubbed from the output. Packages marked "private": true are refused. The package's own lifecycle scripts run, as with npm publish; set ignore_scripts to skip them.
Server instructions: the same guidance is sent in the MCP initialize response, so clients that surface it need no extra setup.
Prompts (commands, for clients that support MCP prompts): npm_accounts, npm_package_health, npm_release_check, npm_deprecate. They take one optional argument such as a package name or a directory.
Resource: npmswitch://accounts (names, usernames and scopes only).
Claude Code extras (installed by install claude-code): the npmswitch skill in ~/.claude/skills/ and the slash commands /npm-accounts, /npm-package-health, /npm-release-check and /npm-deprecate in ~/.claude/commands/. The sources live in content/, including a standard SKILL.md you can copy into any agent that supports Agent Skills.
CLI reference
Command | Description |
| Add or replace an account |
| Show accounts (no tokens) |
| Set the default account |
| Remove an account |
| List supported agents |
| Register the server with an agent |
| Remove it |
| Print the snippet |
| Write project instruction files |
| Run as an MCP server over stdio |
Test
npm testRuns against a fake registry with temporary config and home folders, including a real npm publish to the fake registry; no real accounts or agent configs are touched.
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Provide AI-powered real-time analysis and intelligence on NPM packages, including security, depend…
npm MCP — wraps the npm Registry API (free, no auth)
Dive into the world of npm with our NPM Package Info MCP. Access crucial metadata about any npm
Package intelligence for AI agents across npm, PyPI, crates.io and deps.dev. No API keys.
Related MCP Servers
- AlicenseAqualityAmaintenanceEnables npm registry operations from MCP clients like Claude Code and Cursor, with 64 tools for package intelligence, security audits, dependency analysis, org/team management, and write operations like deprecate and unpublish.6471 npm2MIT
- AlicenseBqualityDmaintenanceProvides AI assistants with tools to check npm package versions and security heuristics, including version lookups, signal-based analysis, and batch analysis of package.json files.52 npmAGPL 3.0
- AlicenseAqualityCmaintenanceEnables AI coding agents to search the npm registry and retrieve package metadata, READMEs, download stats, GitHub details, and usage snippets via the Model Context Protocol.96 npmMIT
- AlicenseNot gradedqualityCmaintenanceProvides a tool to fetch npm package information via MCP. Enables AI agents to retrieve structured package details using the getNpmPackageInfo tool.Apache 2.0