Repository navigation
mcpx: supervised stdio transport behind a flag (#1385, Phase 1 of #1384) #1495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package cli | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "fmt" | ||
|
|
||
| "github.com/dezren39/mcpx/internal/mcpclient" | ||
| ) | ||
|
|
||
| // CmdSupervise runs one stdio MCP server child under a supervisor | ||
| // (#1385, Phase 1 of #1384). It is the re-exec target of the supervised | ||
| // transport: the daemon spawns it detached, it owns the child's pipes | ||
| // for the child's whole life, and daemons attach to its unix socket | ||
| // one at a time. The supervisor process's environment and working | ||
| // directory are the child's — the spawning transport sets them — so | ||
| // the child is spawned with InheritEnv and no extra env of its own. | ||
| // | ||
| // Usage: mcpx supervise --socket <path> -- <command> [args...] | ||
| func (a *App) CmdSupervise(ctx context.Context, args []string) error { | ||
| var socket string | ||
| var child []string | ||
| for i := 0; i < len(args); i++ { | ||
| switch { | ||
| case args[i] == "--socket" && i+1 < len(args): | ||
| socket = args[i+1] | ||
| i++ | ||
| case args[i] == "--": | ||
| child = args[i+1:] | ||
| i = len(args) | ||
| default: | ||
| return fmt.Errorf("supervise: unexpected argument %q (want --socket <path> -- <command> [args...])", args[i]) | ||
| } | ||
| } | ||
| if socket == "" { | ||
| return errors.New("supervise: --socket is required") | ||
| } | ||
| if len(child) == 0 { | ||
| return errors.New("supervise: no child command after --") | ||
| } | ||
| return mcpclient.RunSupervisor(mcpclient.SupervisorOptions{ | ||
| SocketPath: socket, | ||
| Command: child[0], | ||
| Args: child[1:], | ||
| InheritEnv: true, | ||
| }) | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
mcpx.supervisedis changed on configuration reload,Resolved.PoolID()remains unchanged because it does not include this field.Registry.Reloadmatches existing pools usingProcessID()and retains the original pool configuration, so enabling supervision continues using the direct transport, while disabling it continues using supervision. Servers otherwise identical except for this flag also incorrectly share a pool. Include the effective supervision setting in the process/pool identity so reload and alias deduplication respect the selected transport.Useful? React with 👍 / 👎.