fix: resolve Windows compatibility issue in MCP server execution#2
Merged
fix: resolve Windows compatibility issue in MCP server execution#2
Conversation
Fixes issue #1 where Windows users encountered "Error executing Codex CLI" when using the codex-bridge MCP server. Changes: - Add platform detection utilities (_is_windows(), _get_codex_command()) - Enhanced CLI detection to handle Windows executable extensions (.exe, .bat, .cmd) - Created _run_codex_command() helper with Windows-specific subprocess handling - Remove start_new_session=True parameter on Windows (not supported) - Updated all three MCP tool functions to use new helper Maintains backward compatibility with macOS/Linux while adding proper Windows support. Resolves: #1
There was a problem hiding this comment.
Pull Request Overview
This PR fixes Windows compatibility issues in the MCP server by addressing problems with executable detection and subprocess execution. The changes enable cross-platform support while maintaining backward compatibility for macOS/Linux systems.
- Added platform-specific executable detection with Windows extensions (.exe, .bat, .cmd)
- Implemented conditional subprocess handling to remove
start_new_session=Trueon Windows - Created helper functions to centralize platform detection and command execution logic
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Configure publishing settings to eliminate the need for a password.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🐛 Bug Fix
Resolves issue #1 where Windows users encountered "Error executing Codex CLI" when using the codex-bridge MCP server.
🔧 Problem Analysis
The original issue was caused by:
shutil.which("codex")not properly finding executables with Windows extensionssubprocess.run()usingstart_new_session=Truewhich is not supported on Windows✅ Solution Implemented
Platform Detection:
_is_windows()utility function for OS detection_get_codex_command()with Windows-specific executable detection (.exe, .bat, .cmd)Subprocess Handling:
_run_codex_command()helper functionstart_new_session=Trueparameter on WindowsUpdated Functions:
consult_codex()- Updated CLI detection and subprocess executionconsult_codex_with_stdin()- Applied same fixesconsult_codex_batch()- Applied same fixes🧪 Testing
💻 Compatibility
Before: ❌ Windows users got "Error executing Codex CLI"
After: ✅ Cross-platform support for Windows, macOS, and Linux
📋 Files Changed
src/mcp_server.py- Added platform detection and Windows-compatible subprocess handlingCloses #1