Skip to content

Comments

Fix MCP compile tool false-positive npm PATH error#17795

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/fix-mcp-compile-tool-error
Closed

Fix MCP compile tool false-positive npm PATH error#17795
Copilot wants to merge 4 commits intomainfrom
copilot/fix-mcp-compile-tool-error

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

The agenticworkflows-compile MCP tool fails with exec: "npm": executable file not found in $PATH when compiling workflows that use npx packages (e.g. mcp-inspector.md), even though direct CLI invocation succeeds. The MCP server starts with a restricted PATH from its client, so subprocesses it spawns can't find npm at /usr/local/bin.

Changes

  • pkg/cli/mcp_server_path_unix.goaugmentEnvPath() (Unix only, //go:build !windows) appends /usr/local/bin to PATH if not already present; applied to every subprocess spawned via execCmd, so all MCP tools benefit.

  • pkg/cli/mcp_server_path_windows.go — No-op implementation for Windows; PATH augmentation is not needed on Windows.

  • pkg/workflow/npm_validation.go — Implement GH_AW_SKIP_NPX_VALIDATION=true support, which was already referenced in error messages as a workaround but never actually checked.

  • pkg/cli/mcp_server_path_test.go — Unit tests for augmentEnvPath (Unix only): nil env, existing PATH augmentation, duplicate prevention.

  • pkg/workflow/npm_validation_test.go — Unit tests for skip-env-var fast path and empty package list.

// Before: subprocesses inherited the MCP server's restricted PATH
cmd = exec.CommandContext(ctx, cmdPath, args...)

// After: /usr/local/bin is appended when missing (Unix only)
cmd = exec.CommandContext(ctx, cmdPath, args...)
cmd.Env = augmentEnvPath(cmd.Env)  // ensures /usr/local/bin is reachable on Unix
Original prompt

This section details on the original issue you should resolve

<issue_title>[cli-tools-test] MCP compile tool fails npm validation due to restricted PATH (mcp-inspector.md compiles directly but fails via MCP)</issue_title>
<issue_description>## Problem Description

The compile MCP tool (agenticworkflows-compile) reports a false-positive compilation failure for mcp-inspector.md with the error exec: "npm": executable file not found in $PATH, while running ./gh-aw compile .github/workflows/mcp-inspector.md directly succeeds without any errors.

Tool

  • Tool: compile (agenticworkflows MCP server)
  • Workflow: mcp-inspector.md

Steps to Reproduce

  1. Verify npm is available: which npm/usr/local/bin/npm
  2. Run directly: ./gh-aw compile .github/workflows/mcp-inspector.md → ✅ Compiles successfully
  3. Run via MCP: Use agenticworkflows-compile with workflows: ["mcp-inspector"] → ❌ Fails

Expected Behavior

The MCP compile tool should compile mcp-inspector.md successfully, just like the direct CLI invocation.

Actual Behavior

The MCP compile tool returns:

error: runtime package validation failed
Underlying error: exec: "npm": executable file not found in $PATH

Root Cause Analysis

The gh-aw MCP server appears to start with a restricted PATH that does not include /usr/local/bin (or wherever npm is installed). When the MCP server spawns the compilation subprocess, it cannot locate the npm binary, even though it is available in the user's shell environment.

The direct CLI invocation inherits the full shell PATH and can find npm.

Environment

  • Repository: github/gh-aw
  • Run ID: 22288022720
  • Date: 2026-02-22
  • npm location: /usr/local/bin/npm (Node.js v20)
  • gh-aw version: 0.0.414

Impact

  • Severity: High
  • Frequency: Always (reproducible 100%)
  • Effect: mcp-inspector.md always shows as invalid when compiling via MCP, giving a false-positive failure. This breaks the daily compile check which reports mcp-inspector.md as invalid.

Workaround

Run GH_AW_SKIP_NPX_VALIDATION=true gh-aw compile directly. The MCP compile tool does not support this environment variable override.

Suggested Fix

Ensure the MCP server inherits a full PATH when starting, or explicitly add common binary paths (like /usr/local/bin) to the subprocess environment used for compilation.

Generated by Daily CLI Tools Exploratory Tester

  • expires on Mar 1, 2026, 11:55 PM UTC

Comments on the Issue (you are @copilot in this section)

Custom agent used: agentic-workflows
GitHub Agentic Workflows (gh-aw) - Create, debug, and upgrade AI-powered workflows with intelligent prompt routing


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Implement GH_AW_SKIP_NPX_VALIDATION env var in npm_validation.go
- Augment PATH in MCP subprocess creation to include common binary dirs
- Add unit tests for augmentEnvPath and GH_AW_SKIP_NPX_VALIDATION

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix MCP compile tool validation issues due to PATH restrictions Fix MCP compile tool false-positive npm PATH error Feb 23, 2026
@pelikhan
Copy link
Contributor

@copilot only add /usr/local/bin

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 23, 2026

@copilot only add /usr/local/bin

Done — augmentEnvPath now only appends /usr/local/bin (d84410f).

Copy link
Contributor

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot is only added on unix architecture.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 23, 2026

@copilot is only added on unix architecture.

Done — split into mcp_server_path_unix.go (//go:build !windows) with the real implementation and mcp_server_path_windows.go (no-op). The test file also carries //go:build !integration && !windows (68ab15c).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cli-tools-test] MCP compile tool fails npm validation due to restricted PATH (mcp-inspector.md compiles directly but fails via MCP)

2 participants