From 125db929385fb1e87124ae46edcb841576ce6996 Mon Sep 17 00:00:00 2001 From: Jonathan Wang Date: Fri, 6 Jun 2025 20:18:42 +0800 Subject: [PATCH] fix: npx path in windows is npx.cmd --- src/mcpm/cli.py | 2 +- src/mcpm/commands/client.py | 3 ++- src/mcpm/commands/inspector.py | 6 ++++-- src/mcpm/utils/platform.py | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/mcpm/cli.py b/src/mcpm/cli.py index 2c026838..a5ec0c75 100644 --- a/src/mcpm/cli.py +++ b/src/mcpm/cli.py @@ -98,7 +98,7 @@ def main(ctx, help_flag, version): # Check if a command is being executed (and it's not help, no command, or the client command) if ( ctx.invoked_subcommand - and ctx.invoked_subcommand not in ["target", "client", "profile", "router", "share"] + and ctx.invoked_subcommand not in ["target", "client", "profile", "router", "share", "inspector"] and not help_flag ): # Check if active client is set diff --git a/src/mcpm/commands/client.py b/src/mcpm/commands/client.py index 152c92b0..36fba4a2 100644 --- a/src/mcpm/commands/client.py +++ b/src/mcpm/commands/client.py @@ -15,6 +15,7 @@ from mcpm.clients.client_config import ClientConfigManager from mcpm.clients.client_registry import ClientRegistry from mcpm.utils.display import print_client_error, print_error, print_server_config +from mcpm.utils.platform import NPX_CMD console = Console() client_config_manager = ClientConfigManager() @@ -111,7 +112,7 @@ def edit_client(): basic_config = { "mcpServers": { "filesystem": { - "command": "npx", + "command": NPX_CMD, "args": [ "-y", "@modelcontextprotocol/server-filesystem", diff --git a/src/mcpm/commands/inspector.py b/src/mcpm/commands/inspector.py index e736aaa8..6fe9032f 100644 --- a/src/mcpm/commands/inspector.py +++ b/src/mcpm/commands/inspector.py @@ -11,6 +11,8 @@ from rich.console import Console from rich.panel import Panel +from mcpm.utils.platform import NPX_CMD + console = Console() # Define context settings to handle help flag properly @@ -48,7 +50,7 @@ def inspector(args, yes): if args: # Pass all arguments directly to the inspector arg_string = " ".join(args) - cmd = f"npx @modelcontextprotocol/inspector {arg_string}" + cmd = f"{NPX_CMD} @modelcontextprotocol/inspector {arg_string}" console.print(f"[bold]Running MCPM Inspector with arguments:[/] {arg_string}") else: # No arguments provided, prompt for confirmation @@ -59,7 +61,7 @@ def inspector(args, yes): console.print("[yellow]Inspector cancelled.[/]") return - cmd = "npx @modelcontextprotocol/inspector" + cmd = f"{NPX_CMD} @modelcontextprotocol/inspector" console.print("[cyan]Starting MCPM Inspector...[/]") console.print("The Inspector UI will open in your web browser.") diff --git a/src/mcpm/utils/platform.py b/src/mcpm/utils/platform.py index 921056ca..10628712 100644 --- a/src/mcpm/utils/platform.py +++ b/src/mcpm/utils/platform.py @@ -103,3 +103,6 @@ def get_frpc_directory(app_name: str = "mcpm") -> Path: # Default to ~/.local/share if XDG_DATA_HOME is not defined return Path.home() / ".local" / "share" / app_name / "frpc" + + +NPX_CMD = "npx" if sys.platform != "win32" else "npx.cmd"