Skip to content

fix(proxy): fix Windows URL truncation at & in exec and browser open#245

Merged
TarasSpashchenko merged 2 commits intomainfrom
feat/mcp-auth-proxy-plugin
Apr 10, 2026
Merged

fix(proxy): fix Windows URL truncation at & in exec and browser open#245
TarasSpashchenko merged 2 commits intomainfrom
feat/mcp-auth-proxy-plugin

Conversation

@TarasSpashchenko
Copy link
Copy Markdown
Collaborator

Summary

Two Windows-specific bugs where & characters in URLs were silently truncated, breaking the codemie mcp add command and the MCP OAuth authorization flow.

Changes

  • src/utils/exec.ts: When shell: true on Windows, CMD treats &, |, <, >, ^, % as metacharacters. Extended the argument quoting predicate to wrap args containing these characters in double quotes, preventing URL truncation when spawning claude mcp add with a URL that contains query parameters.

  • src/mcp/auth/mcp-oauth-provider.ts: cmd /c start "" url passes the OAuth authorization URL unquoted to CMD, which splits on &, so ?response_type=code&client_id=...&redirect_uri=... became just ?response_type=code. Replaced with powershell -NoProfile -Command "Start-Process 'url'" which passes the URL directly to the OS shell handler, bypassing CMD metacharacter parsing entirely.

  • src/cli/commands/mcp/index.ts: Removed unused ensureProxyCommandExists function and simplified the error handling block.

Impact

Before: codemie mcp add registered MCP servers with a truncated URL (missing everything after the first &). The OAuth browser auth page showed {"error": "validation_failed"} because client_id and redirect_uri were stripped from the authorization URL.

After: Full URLs are preserved on Windows for both the MCP server registration and the browser-based OAuth authorization flow.

Checklist

  • Self-reviewed
  • Manual testing performed
  • Documentation updated (if needed)
  • No breaking changes (or clearly documented)

TarasSpashchenko and others added 2 commits April 10, 2026 14:51
- exec.ts: quote args containing CMD metacharacters (& | < > ^ %)
  when shell:true on Windows, preventing codemie mcp add URL truncation
- mcp-oauth-provider.ts: replace cmd /c start with PowerShell Start-Process
  to preserve & in OAuth authorization URLs opened in the browser
- mcp/index.ts: remove unused ensureProxyCommandExists, simplify error handling

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
The function was removed in the previous commit to silence a lint error
caused by the call being commented out. Restore both the function and
the call so codemie mcp add fails fast with a clear error when
codemie-mcp-proxy is not on PATH.

Generated with AI

Co-Authored-By: codemie-ai <codemie.ai@gmail.com>
@TarasSpashchenko TarasSpashchenko merged commit 55b3c9c into main Apr 10, 2026
5 checks passed
@TarasSpashchenko TarasSpashchenko deleted the feat/mcp-auth-proxy-plugin branch April 10, 2026 14:08
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