Repository navigation
factory-server: mcp: let a project append stdio arguments - #242
Merged
Merged
Conversation
A project's page for a stdio server has the enabled switch, the stages, the server's command and base arguments read-only, and an Extra arguments list stored per project and server. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Decode extra arguments only for a stdio server, fail on a malformed stored list, show whitespace in the command line preview, and say that saved arguments take effect once worker support lands. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
moonthebot
added a commit
that referenced
this pull request
Nov 23, 2026
## Why Stdio MCP servers could be registered and enabled per project, but runs ignored them. This change makes a run start them. It is PR 4 of the stdio MCP series (#240 to #242 came first). The agent starts the server as a child process inside the worker, so it reaches `/work` and the worker's localhost. That bypasses the proxy, so there are no stored secrets, no enforced tool toggles and no connection check. Tool calls are read from the agent's output instead. What changed: - The scheduler passes each active stdio server's command, base arguments and the project's extra arguments to the runner. It reads them on every run, so a change applies at the next run. - `McpConfig` now holds an optional proxy. A run with only stdio servers issues no run token and passes no `FACTORY_MCP_TOKEN`. Remote entries are unchanged. - A run with a stdio server writes its MCP config to a file in the job's agent config directory, which the run already mounts. One argv element over 128 KiB makes the kernel refuse to start the container, and 64 arguments of 4096 bytes exceed that. Claude reads `--mcp-config /claude/factory-mcp.json`. Copilot reads `--additional-mcp-config @/copilot/factory-mcp.json`. Codex reads `[mcp_servers.<name>]` tables in its `config.toml`. The podman flags do not change. - The runner writes those files to a temporary file in the same directory and renames it into place. A previous worker can leave a symlink at the name in the reused config directory, and the rename replaces the link where an in-place write would follow it out of the job directory. - Claude sets `MCP_TIMEOUT=120000` through `--settings`. Codex sets `startup_timeout_sec = 120`. Copilot has no startup timeout setting. - A failed start becomes an `mcp-unavailable` warning. Claude reports it in the `init` line. Copilot is parsed from `session.mcp_server_status_changed` and `session.mcp_servers_loaded`. - The scheduler records a stdio tool call from the agent's output as an `mcp-tool-call` row under its job. Remote calls stay recorded by the proxy alone. Checked against the pinned CLIs (copilot 1.0.114, codex 0.165.0, claude 2.1.330): - Claude `MCP_TIMEOUT` through the settings `env` works. - Codex reads a stdio table from `config.toml`, and escaped `"`, `\` and spaces round-trip. It emits no event for a failed stdio server, so it gets no warning. `docs/design.md` says so. - Copilot's help documents `@path` for `--additional-mcp-config`. Its failed-status events come from the SDK types, and I did not confirm that `-p` JSON output emits them live. That needs a check on moon. ## Docs `docs/design.md`: the MCP stdio servers, MCP project settings, MCP proxy, MCP unavailable servers, Job MCP tool calls and Credentials rows, a new MCP stdio isolation row, the Architecture block, and the Claude, Codex and Copilot sections. The playwright-mcp recipe waits for the worker packages PR. ## Verification - `nix develop -c just lint`: passed. - `nix develop -c cargo test --workspace --locked`: passed. It includes tests for each agent that pass 64 arguments of 4096 bytes through the file, and tests that a preexisting symlink is replaced and its target stays unchanged. - `nix develop -c just check-tests`: passed. Signed-off-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: moonthebot <289833623+moonthebot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Why
A stdio MCP server runs inside the worker, so a project needs a way to tune it, such as adding
--headlessto playwright-mcp. This is PR 3 of 5. Runs do not start stdio servers yet, so a saved list takes effect once worker support lands in a later change.A project's page for a stdio server has the enabled switch and the five stage checkboxes. It shows the server's command and base arguments read-only. It adds an Extra arguments list for the project, edited one box per argument, with the full command line shown under it. The preview keeps whitespace, quotes an argument that has spaces, and writes line breaks as
$'...'escapes. The page has no header fields, no Refresh connection button and no tool list. The project's pipeline panels and MCP servers card list a stdio server too.The list is stored per project and server in a new
project_mcp_argstable. Reading it returns an empty list only when no row exists, and a malformed stored list is a store error. Any collaborator of the project may edit it. The arguments reach only that project's workers, and a collaborator already sets the checks command, which is arbitrary bash in the same workers. Turning the server off keeps the list, and a pipeline save leaves it alone. Deleting the server or removing the project deletes it.The save handler reads the posted pairs in order, and only for a stdio server, then checks them with the registry's argument rules before any write. A violation returns 400 and changes nothing, not the list, the enabled flag or the stages. Posted
argandarg_escapedfields for a remote server are ignored, even when malformed. The check route answers a stdio server with a 400. A login that collaborates on another project alone gets 404 on the page and on a post to it.Docs
Updated the MCP project settings, MCP connection check, MCP tool toggles and Settings layout rows in docs/design.md. The two rows say a stdio server has neither the check nor tool toggles, and that both need a throwaway container and are a follow-up.
Verification
nix develop -c just lint: passednix develop -c just test: passed, with new store and dashboard tests for order, isolation between projects, keeping the list when off, cleanup on delete and project removal, the 400 cases, the check 4xx and the cross-project 404nix develop -c just check-tests: passednix develop -c just e2e tests/project-settings.spec.ts: 21 passed, including a test that edits the extra arguments, checks a whitespace-sensitive argument in the preview, keeps the list when the server is toggled off and on, and uses the pipeline panel switchSigned-off-by: moonthebot tchavadar+moon@protonmail.com