Skip to content

fix: normalize MCP home-relative paths on all platforms#127

Merged
TomProkop merged 2 commits into
masterfrom
issue/125-windows-mcp-paths
May 25, 2026
Merged

fix: normalize MCP home-relative paths on all platforms#127
TomProkop merged 2 commits into
masterfrom
issue/125-windows-mcp-paths

Conversation

@TomProkop
Copy link
Copy Markdown
Member

Summary

  • normalize MCP operational paths before using them as workspace roots or subprocess paths
  • handle home-relative inputs like ~, ~/..., ~\\..., and file:///~/... against the current user profile
  • add regression tests for MCP root conversion and path normalization

Details

This fixes #125 by keeping ~ handling inside the MCP host's execution boundary instead of relying on shell expansion behavior.

The fix is applied in:

  • RootsService.ConvertFileUriToPath
  • CliSubprocessRunner
  • new McpPathNormalizer helper

Validation

  • dotnet build TALXIS.CLI.sln --configuration Debug
  • dotnet test tests/TALXIS.CLI.Tests/TALXIS.CLI.Tests.csproj --configuration Debug --filter "FullyQualifiedName~RootsServiceTests|FullyQualifiedName~McpPathNormalizerTests|FullyQualifiedName~LogRedactionFilterTests"
  • dotnet test TALXIS.CLI.sln --configuration Debug --no-build

Repo scan

I scanned the repo for similar cross-platform path-boundary issues around:

  • Uri.LocalPath / file URI conversion
  • Assembly.Location / process startup paths
  • ProcessStartInfo.WorkingDirectory
  • home-directory rewriting / %USERPROFILE%

I did not find another same-shape internal bug beyond the MCP root + subprocess path boundary fixed here.

Closes #125

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes MCP path handling by normalizing “operational paths” (workspace roots and subprocess paths) across platforms, with explicit support for home-relative inputs (~, ~/..., ~\..., and file:///~/...) so MCP behavior doesn’t depend on shell expansion.

Changes:

  • Introduces McpPathNormalizer to expand home-relative paths and normalize them via Path.GetFullPath.
  • Updates MCP root URI conversion and CLI subprocess startup to use the new normalization behavior.
  • Adds regression tests covering file:///~/... root conversion and ~ path normalization.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/TALXIS.CLI.Tests/MCP/RootsServiceTests.cs Adds regression coverage for file:///~/... resolving against the user profile.
tests/TALXIS.CLI.Tests/MCP/McpPathNormalizerTests.cs Adds unit tests for ~ / ~/... / ~\... expansion and Uri.LocalPath-shaped /~/... inputs.
src/TALXIS.CLI.MCP/RootsService.cs Uses McpPathNormalizer when converting file:// roots into a working directory path.
src/TALXIS.CLI.MCP/McpPathNormalizer.cs New helper implementing home-relative expansion + normalization for MCP operational paths.
src/TALXIS.CLI.MCP/CliSubprocessRunner.cs Normalizes working directory and resolved CLI host paths before launching subprocesses.

Comment thread tests/TALXIS.CLI.Tests/MCP/RootsServiceTests.cs Outdated
Comment thread tests/TALXIS.CLI.Tests/MCP/McpPathNormalizerTests.cs
Comment thread tests/TALXIS.CLI.Tests/MCP/McpPathNormalizerTests.cs Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@TomProkop
Copy link
Copy Markdown
Member Author

Addressed the review comments in 8455b37. The new MCP path tests no longer assume UserProfile is always available; they now assert the same fallback behavior as production when the profile directory is empty.

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.

Bug: TALXIS CLI MCP fails on Windows due to invalid ~ path expansion in process path / working directory

2 participants