@@ -342,8 +342,19 @@ func (r *SourceResolver) Resolve(ctx context.Context, info ServerInfo) (*Resolve
342342// `bun server.ts` as a runner by name alone would route a local invocation into
343343// the package cache/fetch path and scan the wrong token. We decide this up front
344344// rather than relying on a later parser failure.
345- func isPackageRunnerCommand (command string , args []string ) bool {
345+ // runnerBase returns a command's lowercased base name without a Windows
346+ // executable suffix, so npx.cmd and uvx.exe classify as npx and uvx.
347+ func runnerBase (command string ) string {
346348 base := strings .ToLower (filepath .Base (command ))
349+ switch filepath .Ext (base ) {
350+ case ".exe" , ".cmd" , ".bat" :
351+ base = strings .TrimSuffix (base , filepath .Ext (base ))
352+ }
353+ return base
354+ }
355+
356+ func isPackageRunnerCommand (command string , args []string ) bool {
357+ base := runnerBase (command )
347358 switch base {
348359 case "npx" , "uvx" , "bunx" :
349360 return true
@@ -853,7 +864,7 @@ func extractNpxPackageDir(path, targetPkg string) string {
853864// stripped) that an npx-based server launches. Returns "" if the command is
854865// not npx or no package name can be determined.
855866func npxTargetPackage (info ServerInfo ) string {
856- if info .Command == "" || filepath . Base (info .Command ) != "npx" {
867+ if info .Command == "" || runnerBase (info .Command ) != "npx" {
857868 return ""
858869 }
859870 name , _ := parsePackageSpec (runnerPackageSpec ("npx" , info .Args ))
@@ -865,7 +876,7 @@ func npxTargetPackage(info ServerInfo) string {
865876// Git URLs (git+https://...) are reduced to the repo name. Returns "" if the
866877// command is not uvx or no package name can be determined.
867878func uvxTargetPackage (info ServerInfo ) string {
868- if info .Command == "" || filepath . Base (info .Command ) != "uvx" {
879+ if info .Command == "" || runnerBase (info .Command ) != "uvx" {
869880 return ""
870881 }
871882 // runnerPackageSpec skips `--with <dep>` / `-p <python>` values so the target
@@ -1364,7 +1375,7 @@ func (r *SourceResolver) EnrichWithFileList(resolved *ResolvedSource) {
13641375// resolveFromPackageCache attempts to find server source in local package manager caches.
13651376// Supports npx (npm), uvx (uv/pip), and pipx.
13661377func (r * SourceResolver ) resolveFromPackageCache (ctx context.Context , info ServerInfo ) (* ResolvedSource , error ) {
1367- cmdBase := filepath . Base (info .Command )
1378+ cmdBase := runnerBase (info .Command )
13681379
13691380 switch cmdBase {
13701381 case "npx" :
@@ -1380,7 +1391,7 @@ func (r *SourceResolver) resolveFromPackageCache(ctx context.Context, info Serve
13801391func (r * SourceResolver ) resolveNpxCache (info ServerInfo ) (* ResolvedSource , error ) {
13811392 // Extract the target package spec (handles `npx -p <pkg>`, `pnpm dlx <pkg>`,
13821393 // version pins, etc.) then split name from any exact version pin.
1383- spec := runnerPackageSpec (strings . ToLower ( filepath . Base ( info .Command ) ), info .Args )
1394+ spec := runnerPackageSpec (runnerBase ( info .Command ), info .Args )
13841395 if spec == "" {
13851396 return nil , fmt .Errorf ("no package name found in npx args" )
13861397 }
@@ -1563,7 +1574,7 @@ func (r *SourceResolver) resolveUvxCache(info ServerInfo) (*ResolvedSource, erro
15631574 // `uvx --from <pkg> <cmd>`, `uvx git+<url>`, and crucially skips `--with <dep>`
15641575 // / `-p <python>` values so the additional dependency or python version is not
15651576 // mistaken for the target (MCP-2445).
1566- pkgName := runnerPackageSpec (strings . ToLower ( filepath . Base ( info .Command ) ), info .Args )
1577+ pkgName := runnerPackageSpec (runnerBase ( info .Command ), info .Args )
15671578 if pkgName == "" {
15681579 return nil , fmt .Errorf ("no package name found in uvx args" )
15691580 }
0 commit comments