Skip to main content
RapidDev - Software Development Agency
mcp-tutorial

How to use npx to run MCP servers without installing

npx lets you run npm-distributed MCP servers without installing them globally. Always use the -y flag to auto-confirm installation prompts, which prevents the server from hanging. On Windows, wrap npx calls with cmd /c because GUI applications cannot find npx directly. If npx is not found, use the full absolute path to the npx binary instead.

What you'll learn

  • How to use npx with the -y flag to run MCP servers
  • The Windows cmd wrapper needed for GUI-launched MCP hosts
  • How to fix PATH issues when npx is not found
  • How to configure npx-based servers in Claude Desktop and Cursor
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner6 min read5-10 minNode.js 16+, all MCP hostsMarch 2026RapidDev Engineering Team
TL;DR

npx lets you run npm-distributed MCP servers without installing them globally. Always use the -y flag to auto-confirm installation prompts, which prevents the server from hanging. On Windows, wrap npx calls with cmd /c because GUI applications cannot find npx directly. If npx is not found, use the full absolute path to the npx binary instead.

Running MCP Servers with npx

Many MCP servers are published to npm and designed to be run with npx — a tool that comes with Node.js for executing npm packages without installing them globally. This is the most common way to use community MCP servers like the GitHub, Slack, and filesystem servers. This tutorial covers the setup, the critical -y flag, Windows-specific quirks, and how to troubleshoot PATH issues.

Prerequisites

  • Node.js 16+ installed (which includes npx)
  • An MCP host like Claude Desktop or Cursor installed
  • Basic familiarity with your MCP host's configuration file

Step-by-step guide

1

Verify npx is installed and accessible

npx comes bundled with Node.js (specifically with npm 5.2+). Open your terminal and run npx --version to confirm it is available. If you see a version number, you are good to go. If you get command not found, you need to install or update Node.js. On macOS with Homebrew, run brew install node. On Windows, download from nodejs.org.

typescript
1# Check npx is available
2npx --version
3# Should output something like: 10.2.4
4
5# If not found, check Node.js installation
6node --version
7npm --version

Expected result: npx --version outputs a version number, confirming it is installed.

2

Configure an npx-based MCP server with the -y flag

When npx runs a package for the first time, it prompts the user to confirm the installation. In an MCP server context, there is no terminal to answer this prompt, so the server hangs silently. The -y flag auto-confirms the installation. Always include -y in your args array right after npx. This is the single most important thing to remember when using npx with MCP servers.

typescript
1// claude_desktop_config.json
2{
3 "mcpServers": {
4 "github": {
5 "command": "npx",
6 "args": ["-y", "@modelcontextprotocol/server-github"],
7 "env": {
8 "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token"
9 }
10 }
11 }
12}

Expected result: The MCP server starts automatically without hanging on an installation confirmation prompt.

3

Apply the Windows cmd wrapper

On Windows, GUI applications like Claude Desktop and Cursor do not inherit the shell PATH, so they cannot find npx directly. The fix is to use cmd as the command and pass /c npx as arguments. This launches a cmd.exe shell that resolves npx from the system PATH. This is the most common cause of 'server not found' errors on Windows.

typescript
1// Windows — claude_desktop_config.json
2{
3 "mcpServers": {
4 "github": {
5 "command": "cmd",
6 "args": ["/c", "npx", "-y", "@modelcontextprotocol/server-github"],
7 "env": {
8 "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token"
9 }
10 }
11 }
12}
13
14// macOS/Linux — no wrapper needed
15{
16 "mcpServers": {
17 "github": {
18 "command": "npx",
19 "args": ["-y", "@modelcontextprotocol/server-github"],
20 "env": {
21 "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token"
22 }
23 }
24 }
25}

Expected result: The MCP server starts correctly on Windows using the cmd wrapper.

4

Fix PATH issues with absolute paths

If npx still cannot be found (common on macOS when using nvm or Homebrew), use the absolute path to npx instead of relying on PATH resolution. Run which npx (macOS/Linux) or where npx (Windows) in your terminal to find the full path. Replace the command value with this absolute path. This bypasses all PATH resolution issues.

typescript
1# Find absolute path to npx
2which npx
3# Example output: /opt/homebrew/bin/npx
4
5# Use absolute path in config
6{
7 "mcpServers": {
8 "github": {
9 "command": "/opt/homebrew/bin/npx",
10 "args": ["-y", "@modelcontextprotocol/server-github"],
11 "env": {
12 "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token"
13 }
14 }
15 }
16}

Expected result: The MCP server starts using the absolute path to npx, bypassing PATH resolution issues.

5

Pass arguments to the MCP server

Some npx-based MCP servers accept additional command-line arguments after the package name. Add these to the args array after the package name. For example, the filesystem server takes directory paths as arguments to specify which directories it can access. If you run into configuration challenges with multiple servers or complex argument setups, the RapidDev team can help you design an optimal MCP configuration.

typescript
1{
2 "mcpServers": {
3 "filesystem": {
4 "command": "npx",
5 "args": [
6 "-y",
7 "@modelcontextprotocol/server-filesystem",
8 "/Users/yourname/projects",
9 "/Users/yourname/documents"
10 ]
11 }
12 }
13}

Expected result: The MCP server receives the additional arguments and configures itself accordingly.

Complete working example

claude_desktop_config.json
1{
2 "mcpServers": {
3 "github": {
4 "command": "npx",
5 "args": ["-y", "@modelcontextprotocol/server-github"],
6 "env": {
7 "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_your_token_here"
8 }
9 },
10 "filesystem": {
11 "command": "npx",
12 "args": [
13 "-y",
14 "@modelcontextprotocol/server-filesystem",
15 "/Users/yourname/projects",
16 "/Users/yourname/documents"
17 ]
18 },
19 "slack": {
20 "command": "npx",
21 "args": ["-y", "@modelcontextprotocol/server-slack"],
22 "env": {
23 "SLACK_BOT_TOKEN": "xoxb-your-token",
24 "SLACK_TEAM_ID": "T01234567"
25 }
26 },
27 "memory": {
28 "command": "npx",
29 "args": ["-y", "@modelcontextprotocol/server-memory"]
30 }
31 }
32}

Common mistakes when using npx to run MCP servers without installing

Why it's a problem: Forgetting the -y flag with npx

How to avoid: Always include -y as the first argument after npx. Without it, npx prompts for installation confirmation and the server hangs indefinitely since there is no terminal to answer.

Why it's a problem: Not using cmd wrapper on Windows

How to avoid: On Windows, use "command": "cmd" with "args": ["/c", "npx", "-y", ...]. GUI applications on Windows cannot find npx without the cmd shell.

Why it's a problem: Using a relative path to npx that depends on PATH

How to avoid: If npx is not found, use the absolute path from which npx (macOS/Linux) or where npx (Windows) as the command value.

Why it's a problem: Putting the package name before -y

How to avoid: The -y flag must come before the package name: ["npx", "-y", "@scope/package"], not ["npx", "@scope/package", "-y"].

Best practices

  • Always use -y flag with npx in MCP configurations to prevent hanging on confirmation prompts
  • Use absolute paths to npx when PATH resolution fails in GUI-launched applications
  • On Windows, always wrap npx with cmd /c to ensure proper PATH resolution
  • Check the MCP server's npm page or README for required environment variables before configuring
  • Test the npx command in your terminal first before adding it to the host config
  • Pin package versions when stability is critical: npx -y @scope/package@1.2.3

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I want to configure an MCP server in [Claude Desktop / Cursor] using npx. The package is [package-name] and it needs these environment variables: [list]. Show me the complete JSON configuration for [macOS / Windows].

MCP Prompt

Help me set up npx-based MCP servers in my Claude Desktop config. I want to add the GitHub server (needs GITHUB_PERSONAL_ACCESS_TOKEN) and the filesystem server (needs access to /Users/me/projects). Show me the configuration.

Frequently asked questions

Does npx install the package permanently?

No, npx caches packages temporarily. When you run npx -y @scope/package, it downloads the package to a cache directory and runs it. The package stays in the cache but is not added to any project's node_modules.

Can I use a specific version of an MCP server with npx?

Yes, append the version after the package name: npx -y @modelcontextprotocol/server-github@1.2.3. This is useful when a newer version introduces breaking changes.

Why does my npx-based server take a long time to start?

The first run downloads the package, which can take 5-30 seconds depending on package size and network speed. Subsequent runs use the cached version and start faster. If it takes more than 60 seconds, the download may be failing silently.

Can I use npx with private npm packages?

Yes, but you need to be authenticated with npm first. Run npm login in your terminal, and npx will use your credentials to download private packages.

What if the npx cache is corrupted?

Clear the npx cache by running npx --cache-clear or deleting the cache directory manually. On macOS, it is usually at ~/.npm/_npx/. Then restart your MCP host to re-download the packages.

Is npx slower than a globally installed package?

Only on the first run. After the package is cached, npx starts just as fast as a globally installed package. The tradeoff is convenience — you do not need to manage global installations.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.