Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

Safe-inputs MCP server handlers were spawning processes in their default working directory rather than the repository root, causing path resolution issues for tools expecting to run from the workspace root.

Changes

  • Handler updates: Added cwd option to execFile calls in all handler types (shell, Python, Go, JavaScript)
  • Fallback pattern: Uses process.env.GITHUB_WORKSPACE || process.cwd() for local compatibility
  • Test coverage: Added tests verifying cwd behavior with and without GITHUB_WORKSPACE set

Implementation

execFile(
  scriptPath,
  [],
  {
    env,
    cwd: process.env.GITHUB_WORKSPACE || process.cwd(),
    timeout: timeoutSeconds * 1000,
    maxBuffer: 10 * 1024 * 1024,
  },
  // ...
);

Applied consistently across mcp_handler_shell.cjs, mcp_handler_python.cjs, mcp_handler_go.cjs, and mcp_handler_javascript.cjs.

Original prompt

In the safe-inputs MCP server, when spawning processes, make sure they execute from the GitHub workspace root folder.


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

Set working directory to GITHUB_WORKSPACE for all handler types (shell, python, go, javascript) to ensure processes execute from workspace root. Falls back to process.cwd() if GITHUB_WORKSPACE is not set. Added test cases for JavaScript and Go handlers to verify cwd behavior.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Ensure processes spawn from GitHub workspace root Set working directory to GITHUB_WORKSPACE for safe-inputs MCP handlers Jan 23, 2026
Copilot AI requested a review from pelikhan January 23, 2026 12:52
@pelikhan pelikhan marked this pull request as ready for review January 23, 2026 14:14
@pelikhan pelikhan merged commit 44b4355 into main Jan 23, 2026
@pelikhan pelikhan deleted the copilot/ensure-processes-execute-root branch January 23, 2026 14:14
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.

2 participants