chore: refactor exec-server to prepare it for standalone MCP use #6944
+108
−118
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.
This PR reorganizes things slightly so that:
codex-exec-server, we now have two executables:codex-exec-mcp-serverto launch the MCP servercodex-execve-wrapperis theexecve(2)wrapper to use with theBASH_EXEC_WRAPPERenvironment variableBASH_EXEC_WRAPPERmust be a single executable: it cannot be a command string composed of an executable with args (i.e., it no longer adds theescalatesubcommand, as before)codex-exec-mcp-servertakes--bashand--execveas options. Though if--execveis not specified, the MCP server will check the directory containingstd::env::current_exe()and attempt to use the file namedcodex-execve-wrapperwithin it. In development, this works out since these executables are side-by-side in thetarget/debugfolder.With respect to testing, this also fixes an important bug in
dummy_exec_policy(), as I was usingends_with()as if it applied to aString, but in this case, it is used with a&Path, so the semantics are slightly different.Putting this all together, I was able to test this by running the following:
If I try to run
git statusin/Users/mbolin/code/codexvia theshelltool from the MCP server:then I get prompted with the following elicitation, as expected:
Though a current limitation is that the
shelltool defaults to a timeout of 10s, which means I only have 10s to respond to the elicitation. Ideally, the time spent waiting for a response from a human should not count against the timeout for the command execution. I will address this in a subsequent PR.Note
~/code/bash/bashwas created by doing:The patch: