Repository navigation
fix(agent-runs): put MCP-bearing agent containers on the API's Docker network - #3422
Conversation
… network Automation runs with propr_mcp (and every acting step) were issued a valid run-scoped MCP grant but could never use it: the grant's default URL is http://api:4000/api/mcp, a Compose service name, while every agent container is started with `--network bridge`, where that name does not resolve. Codex and Claude silently failed to start the `propr` MCP server and the agent reported its tools as unavailable. On this instance no agent-run grant had ever produced a single MCP access-log entry. - A containerized worker discovers its own Compose network (docker inspect of its container) once per process; PROPR_AGENT_DOCKER_NETWORK pins it for a worker outside Compose. The network travels with the issued grant into the tool policy as `dockerNetwork`, and the Claude and Codex builders use it for `--network`. Containers without a grant stay on the default bridge. - The revoke endpoint now reports how many calls the access log recorded for the grant, and the worker logs a warning naming the URL and network when a grant ends with none, so an unreachable endpoint no longer hides behind the agent's prose. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
/review |
|
✅ AI Code Review Complete requested by @integry Posted 1 review: |
🔍 AI Code Review — claude:claude-opus-5-5Overall EvaluationThe PR fixes a real reachability bug. Agent containers were handed
The PR also makes the failure visible: the revoke endpoint now returns The implementation is tidy and well tested. Its core problem is the security impact of putting MCP-bearing containers on the full Compose network, which this PR introduces and neither mitigates nor documents. Status: needs changes before merge. ✅ Fail-safe network resolution — In ✅ Single validation point for both runtimes — ✅ Backward-compatible revoke contract — Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F1: 🔴 MCP-bearing agent containers gain unauthenticated access to every Compose service
SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Deterministic network choice on multi-network workers
S2: 🟢 Zero-call warning is noisy for report runs that legitimately skip MCPA S3: 🟢 Confirm the production
|
|
/fix |
|
✅ Applied the requested follow-up changes in commit 06328b1
Summary of ChangesApplied F1 only.
Focused tests and job tests pass; source lint passes. Full typecheck reports a separate mismatch at Rollout requires recreating the API service to attach the new network. 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
Applied F1 only. - MCP agents now use a dedicated API-only Compose network. - Explicit MCP URLs stay on bridge unless a network is explicitly configured. - Added isolation, override, asynchronous cache, and report/action regressions. - Updated configuration and execution-safety docs. Focused tests and job tests pass; source lint passes. Full typecheck reports a separate mismatch at `src/agentRunScheduler.ts:474`, left unchanged. Live Docker verification was unavailable. Rollout requires recreating the API service to attach the new network. PR: #3422 Comment by: @integry (ID: 6704709381) Model: GPT-6.1 Sol
|
/review |
|
✅ AI Code Review Complete requested by @integry Posted 1 review: |
🔍 AI Code Review — claude:claude-opus-5-5Overall EvaluationThe PR fixes an MCP reachability failure in agent runs. Before this change, agent containers that held a run-scoped ProPR MCP grant launched on Docker's default Approach
The implementation is better than the PR description says. The description talks about "picking the first non- I traced the changed paths:
I found no merge blockers. The PR is ready to merge, conditional on the pending CI shards. ✅ Least-privilege network choice — Agents join an API-only network ( ✅ Explicit endpoint does not imply network access — When ✅ Silent failure becomes observable — The revoke route distinguishes three outcomes:
The client tolerates the legacy response shape, and the warning is tested not to leak the token. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S5: 🟢 Verify the derived network exists
Two cases could hit this:
In either case, A S6: 🟢 Don't cache transient discovery failures forever
S7: 🟢 Align the troubleshooting doc with the isolation modelThe new entry in Both statements conflict with S8: 🟢 Soften the zero-call warning for report runsA report run with Two options:
ScoreThe fix meets the objective with a careful security boundary, consistent propagation through both builders, and focused tests. No verified regressions; the remaining items are hardening and documentation consistency. Merge readiness is conditional on the pending test shards. Score: 8/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
/review astra |
|
✅ AI Code Review Complete requested by @integry Posted 1 review: |
🔍 AI Code Review — astraOverall EvaluationThe PR addresses MCP reachability with a dedicated API network and adds useful diagnostics for unused grants. It needs a localized correction before merge: extension-enabled automations discard the newly selected network. ✅ Network isolation — The Compose change attaches only the API to ✅ Restricted-mode preservation — The existing egress transformation replaces the selected network with ✅ Configuration coverage — Tests cover explicit endpoint overrides, network validation, discovery caching, and both container builders. The supplied checks report 27 passed, none failed, and one pending. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F2: 🔴 Preserve the network through extension preparation
SuggestionsThese are optional follow-ups and are not sent to S9: 🟢 Align troubleshooting with network isolationThe new entry in S10: 🟢 Test recorded and unavailable activityThe revoke-route test verifies only ScoreThe implementation is focused and well covered, but the extension-enabled launch path still loses the essential network selection. The passing checks do not cover that integration gap. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
/fix |
|
✅ Applied the requested follow-up changes in commit cd0cc56
Summary of ChangesI fixed F2: extension preparation no longer drops the Docker network. Report and action containers that use an extension profile now join the API's network instead of falling back to The fix: Same mistake elsewhere: I searched core and the worker for other places that rebuild a tool policy from scratch and found none. The report and action jobs pass the policy through whole, and both container builders read Regression test (
Verification:
This change has nothing visible to a user, so I made no previews. 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…r network. Report and action containers that use an extension profile now join the API's network instead of falling back to `bridge`. I fixed F2: extension preparation no longer drops the Docker network. Report and action containers that use an extension profile now join the API's network instead of falling back to `bridge`. **The fix:** `packages/core/src/extensions/extensionLaunch.ts:92` rebuilds `toolPolicy` from a fixed list of fields and left out `dockerNetwork`. It now copies `options.toolPolicy.dockerNetwork` into the prepared policy when one is set. Nothing else in that rebuild changed. **Same mistake elsewhere:** I searched core and the worker for other places that rebuild a tool policy from scratch and found none. The report and action jobs pass the policy through whole, and both container builders read `dockerNetwork` directly. **Regression test** (`test/extensionLaunchIntegration.test.ts`): - It runs a ProPR MCP policy with `dockerNetwork: 'propr_propr-agent-mcp'` and the default `http://api:4000/api/mcp` URL through the real extension preparation, under open networking. - It checks that the prepared policy still has both the network and the `propr` server. - It then builds the Claude and Codex container arguments from that prepared policy and checks they get `--network propr_propr-agent-mcp` and never `bridge`. - To support this, `test/fixtures/extensionLaunchIntegration.ts` now takes an optional `inspect` callback and an expected `networkMode`. It still defaults to `restricted`, so the existing tests behave as before. **Verification:** - **The test catches the bug:** with the old `extensionLaunch.ts` swapped back in, the new test fails. With the fix it passes. - **Related suites pass:** `extensionLaunchIntegration`, `processAgentRunJob`, `processAgentActionJob`, `agentToolPolicy`, and `packages/core/test/extensionProfiles`. - **Lint and types:** ESLint is clean on the three touched files, and `tsc --noEmit` on `packages/core` reports no errors in `extensionLaunch.ts`. This change has nothing visible to a user, so I made no previews. PR: #3422 Comment by: @integry (ID: 6705216616) Model: Claude Opus 5.5
|
/review |
|
✅ AI Code Review Complete requested by @integry Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR addresses MCP reachability by carrying a dedicated API network through grant issuance and container launch, and adds diagnostics for grants with no recorded activity. It is merge-ready within the supplied scope, conditional on the pending Validate Changes check completing successfully. ✅ Network isolation — The bundled Compose configuration attaches only the API to ✅ Policy propagation — Both Claude and Codex use the selected network, and extension preparation preserves it. The existing restricted-mode rewrite still replaces it with ✅ Compatible diagnostics — Revocation distinguishes unavailable activity data from zero calls, and the client tolerates older responses without This assessment is based on static review of the supplied diff and context. No commands were run. The authoritative checks report 27 passed, none failed, and one pending. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S11: 🟢 Align troubleshooting network guidanceIn S12: 🟢 Keep unused-grant diagnosis tentativeThe same troubleshooting entry treats unavailable tools as proof that the container never reached MCP. Zero recorded activity can also mean the agent chose not to call it; the warning in S13: 🟢 Exercise actual Docker reachabilityThe new tests verify network naming, Compose membership, argument construction, and extension propagation. A Docker integration test that resolves ScoreThe implementation is focused, preserves restricted-network enforcement, and has relevant regression coverage. No merge-blocking defect was demonstrated; final readiness remains conditional on the pending check. Score: 9/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
CI failed: Validate Changes Please investigate and fix this CI failure.
Failure evidence
|
Checks FailedValidation failed during setup, tests, CLI packaging, linting, or build checks. View Logs |
|
✅ Applied the requested follow-up changes in commit 3f4c0bf Processed 2 comments:
Summary of ChangesI fixed the Validate Changes failure. It was the Core Source Build ( Cause: Fix: In revoke = async (runId, phase, { expiredBy }) => { await revokeAgentRunMcpGrant(runId, { phase, expiredBy }); },How cleanup behaves doesn't change. It never used the return value, and it still awaits the revoke, so errors still propagate. Checks:
The 10.2-minute 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…e Build (`tsc`) error at `src/agentRunScheduler.ts:474`.
I fixed the Validate Changes failure. It was the Core Source Build (`tsc`) error at `src/agentRunScheduler.ts:474`.
**Cause:** `revokeAgentRunMcpGrant` returns `Promise<RevokedAgentRunMcpGrant>` now, so the revoke result can carry `calls` for the unused-grant warning. But `cleanupAgentRunGrants` still uses it directly as its default `revoke`, and that dependency is typed to return `Promise<void>`.
**Fix:** In `src/agentRunScheduler.ts:462`, the default `revoke` now awaits the call and drops the result:
```ts
revoke = async (runId, phase, { expiredBy }) => { await revokeAgentRunMcpGrant(runId, { phase, expiredBy }); },
```
How cleanup behaves doesn't change. It never used the return value, and it still awaits the revoke, so errors still propagate.
**Checks:**
- Root `tsc -p . --noEmit` passes.
- ESLint with `--max-warnings 0` is clean on the file.
- `test/agentRunScheduler.test.ts` passes: 42 of 42 tests.
The 10.2-minute `creation-short-window.pw.ts` entry in the failure evidence is a "Slow Test" note, not a failure, so I left it alone. Nothing here is visible in the UI, so there are no previews.
PR: #3422
Comment by: @propr-dev[bot] (ID: 6705840817)
Comment by: @github-actions[bot] (ID: 6705841107)
Model: Claude Opus 5.5
…PR label tool The acting step of an automation was always told "never merge" and held no merge scope, so an automation whose prompt asks for merges could only leave TODOs. A new `merge` capability on the definition adds the `merge` MCP scope to the action-phase grant alone; the report step stays read-only. The grant response now lists the scopes actually held, the worker derives the prompt's merge rule from them, and it warns when the instance scope ceiling withholds a scope the capability asked for, so the prompt never promises what the tools refuse. The merge tool keeps its own preconditions (exact head, passing checks, protection rules). `update_pull_request_labels` (execute scope) lets an acting step add or remove plain labels, such as the trigger label that hands a PR to ProPR. It never creates a label and leaves the managed `llm-*` and `ultrafix` labels to their own tools. The automation editor gets a "Merge pull requests" toggle, which is locked alongside ProPR tools for agents that cannot use MCP. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
CI failed: Full Test Suite Shard 3/4 Please investigate and fix this CI failure.
Failure evidence
|
|
✅ Applied the requested follow-up changes in commit 0a6fbfd Summary of ChangesI fixed the Shard 3/4 failure; it was a single test, and both related test files now pass locally. Cause: in Fix (test only): the check now skips tools whose names contain Verification:
I didn't re-run the full shard. There are no previews because nothing visible changed. 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…th related test files now pass locally. I fixed the Shard 3/4 failure; it was a single test, and both related test files now pass locally. **Cause:** in `packages/api/test/settingsCatalog.test.ts`, the "settings catalog MCP references and configuration-tool coverage do not drift" test failed with `update_pull_request_labels must appear in SETTINGS_CATALOG`. That test guesses which MCP tools are settings tools from their names, using a pattern like `^(get|update)_.*(…|labels|label|…)$`. The new PR label tool from this branch matches that pattern only because its name ends in `labels`. It changes labels on one pull request; it isn't a setting, so it doesn't belong in the settings catalog. **Fix (test only):** the check now skips tools whose names contain `_pull_request_`. I checked the other `*_pull_request_*` tools and none of them matched the pattern before, so in practice this only excludes the new tool. I also added an assertion that the pattern still matches at least one settings tool, so the check can't quietly end up testing nothing. **Verification:** - `node scripts/run-test-suite.mjs packages/api/test/settingsCatalog.test.ts packages/api/test/mcpPullRequests.test.ts`: 7/7 and 49/49 pass. - ESLint with `--max-warnings 0` is clean on the changed file. I didn't re-run the full shard. There are no previews because nothing visible changed. PR: #3422 Comment by: @propr-dev[bot] (ID: 6712117567) Model: Claude Opus 5.5
An acting step could comment on, label, fix or (with the merge capability) merge a submission, but not close one that should not proceed at all. The new execute-scope tool posts the reason as a comment first, closes only the exact head the caller examined, and refuses merged or already closed pull requests. The branch is kept, so the close is reversible in GitHub. The acting prompt limits it to duplicates, out-of-scope, invalid or harmful pull requests and prefers a comment when the submitter could fix the PR. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
CI failed: Validate Changes Please investigate and fix this CI failure.
Failure evidence
|
Checks FailedValidation failed during setup, tests, CLI packaging, linting, or build checks. View Logs |
|
✅ Applied the requested follow-up changes in commit a670313 Processed 2 comments:
Summary of ChangesNow run the API PR tests (they use core dist, so check how the suite runs). 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…ges**. The other evidence lines (`.github:8`, `.github:415`, the 10-minute `creation-short-window.pw.ts` note) were just the job's exit lines and a slow-test note; the cause was these warnings. I fixed the three lint warnings that failed **Validate Changes**. The other evidence lines (`.github:8`, `.github:415`, the 10-minute `creation-short-window.pw.ts` note) were just the job's exit lines and a slow-test note; the cause was these warnings. - **`packages/api/mcp/toolsPullRequests.ts`** was 420 lines, over the 400 limit. I moved the two new tools from this PR, `update_pull_request_labels` and `close_pull_request`, into a new file, `packages/api/mcp/toolsPullRequestTriage.ts`. `addPullRequestTools` now calls it at the same point as before, so the order of the tool list is unchanged. The tools' code is moved as-is. - **`packages/api/test/mcpPullRequests.test.ts`**: the mock GitHub `request` function was too complex (23, limit 20). I moved its four label routes into a separate `labelRequest` helper that it calls. The mock responses are the same. - **`propr-ui/src/components/Agents/AgentEditor.test.tsx`** was 407 lines. I fitted the API import list and the `vi.mock` stubs onto fewer lines. No test changed. Verification: - `eslint . --max-warnings 0` passes in `packages/api` and `propr-ui`. - `tsc --noEmit` reports no errors in either package. - `AgentEditor.test.tsx`: 25 of 25 tests pass. - `mcpPullRequests`, `mcpToolInputBudget`, `mcpObservableSurface` and `mcpOperatorSurface`: 61 of 61 tests pass. I didn't make previews because nothing visible changed. PR: #3422 Comment by: @propr-dev[bot] (ID: 6712951654) Comment by: @github-actions[bot] (ID: 6712951691) Model: Claude Opus 5.5
The acting step of run f4dd7c96 could neither request a /review (the comment tool rejects slash commands and review_pull_request, run_ultrafix and start_ultrafix all need the review scope) nor approve the CI runs waiting on fork pull requests. - Acting grants now carry read, plan, execute and review; the report grant stays read-only and deploy, publish and manage stay out. - New approve_pull_request_workflow_runs tool (execute scope): approves the action_required runs on the examined head only, refuses a PR that changes .github/workflows or .github/actions with CI_CONFIGURATION_CHANGED, and reports ACTIONS_WRITE_REQUIRED when GitHub refuses the approval. - Acting prompt rules for requesting reviews and approving CI after reading the diff. - Docs: agents.md, execution-safety.md, mcp.md and the MCP reference. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Problem
Automation run
8aa47fc1(definition "MCPTest.io submissions", capabilitiesrepository_read,web,propr_mcp) completed with "theproprMCP server's tools were unavailable" in both its report and its action summary, so it could take no action.The grant side worked: run-scoped MCP grants were issued for both phases (token records expiring exactly 2h after each phase start). What failed was reachability:
http://api:4000/api/mcpby default (agentContainerMcpUrl), a Compose service name.--network bridge. On Docker's default bridge there is no DNS for Compose services, soapidoes not resolve (verified with the runtime image: fails onbridge, resolves to the API ongitfix_propr-net).propr-agent-runsclient across all fivepropr_mcpruns on this instance. The feature had never worked here, and nothing said so except the agent's prose.Fix
Join the API's network when a grant is present
src/jobs/agentRuns/mcpNetwork.ts: a containerized worker resolves its own Compose network once per process (docker inspectof its own container, picking the first non-bridge/host/nonenetwork).PROPR_AGENT_DOCKER_NETWORKpins it, which also serves a worker outside Compose. Any failure logs a warning and keepsbridge.IssuedAgentRunMcpGrant.network) into the tool policy as a newAgentToolPolicy.dockerNetwork.packages/core/src/agents/agentContainerNetwork.tsvalidates the name and returnsbridgewithout one. The Claude (dockerArgsBuilder) and Codex (codexDockerArgsBuilder) builders use it for--network. Containers without a grant are unchanged. Restricted-network runs are unaffected: the egress layer already replaces whatever network is named withnone.Stop failing silently
POST .../mcp-grants/revokenow returnscalls, the number of access-log rows recorded for the revoked grant (null when the log cannot be read).revokeGrantQuietlylogs a warning naming the MCP URL and network when a grant ends with zero recorded calls, so an unreachable endpoint shows up in the worker log instead of only in the report text.Docs and
.env.exampledescribePROPR_AGENT_DOCKER_NETWORKand the new troubleshooting entry.Tests
test/agentRunMcpNetwork.test.ts: Compose network discovery, env pin, invalid pin / native worker / failed inspect fall back to bridge, per-process caching.test/agentToolPolicy.test.ts: Claude and Codex containers stay onbridgeby default and joindockerNetworkwhen set; invalid names are rejected;agentRunToolPolicycarries the grant's network.test/agentRunMcpGrantClient.test.ts: the grant carries the resolved network; revoke parsescalls(and tolerates the old response shape); the unused-grant warning fires only for zero calls and never includes the token.packages/api/test/agentRunGrants.test.ts: revoke response reportscalls: 0for an unused grant (fixture now includes the access-log table).16 test files pass (the four above plus
processAgentRunJob,processAgentActionJob, and the ten other files that build agent container arguments). ESLint clean on the changed sources;tsc --noEmithas no errors in the touched files.Rollout note
After deploy, existing
propr_mcpautomations should start reaching ProPR with no config change on Compose installs. The worker log lineAgent run MCP grant ended without a single recorded callis the signal to watch if they still don't.Follow-up: opt-in merging and a PR label tool
Even with MCP reachable, the acting step was told "never merge" and held no
mergescope, so an automation whose prompt asks for merges could only leave TODOs (and it had no way to add labels or hand a PR to ProPR).mergecapability on automation definitions. When on, the action-phase grant also asks for themergeMCP scope; the report step stays read-only. The grant response now lists the scopes actually held, the worker derives the prompt's merge rule from them, and it warns when the instance scope ceiling withholdsmerge, so the prompt never promises what the tools refuse.merge_pull_requestkeeps its own preconditions (exact head, passing checks, protection rules).update_pull_request_labels(execute scope): add or remove plain labels on an open PR, such as the instance trigger label. Only labels the repository already defines are added; managedllm-*andultrafixlabels stay with their own tools.close_pull_request(execute scope): close a PR that should not proceed at all (duplicate, out of scope, invalid, harmful). The reason is posted as a comment first, only the examined head is closed, and merged or already closed PRs are refused. The acting prompt limits it to those cases and prefers a comment when the submitter could fix the PR.reviewscope for every acting step. Runf4dd7c96could not request a/reviewon two PRs that needed a fresh score: the comment tool rejects slash commands by design, andreview_pull_request,run_ultrafixandstart_ultrafixall require thereviewscope, which the acting grant never held. The acting grant now carriesread,plan,executeandreview; the report grant staysread, anddeploy,publishandmanagestay out. The acting prompt tells the agent to use the review and fix tools rather than typing commands.approve_pull_request_workflow_runs(execute scope): approve the GitHub Actions runs waiting on a fork or first-time-contributor PR, which the same run reported it could not do. Pinned toexpectedHead, so only the runs waiting on the examined head are approved; runs on other heads or already started are left alone. A PR that changes anything under.github/workflowsor.github/actionsis refused withCI_CONFIGURATION_CHANGED, since that is what the maintainer gate is for. GitHub refusing for lack of Actions write access fails withACTIONS_WRITE_REQUIRED. The prompt allows it only after the agent has read the whole diff.Tests: grant scopes per phase and capability (API), the label tool's add/remove/refusal paths, the close tool's reason-then-close order and refusals, and the CI approval tool's head pin, workflow-change refusal and run selection (API), the prompt rule following the grant and the ceiling warning (worker), and the editor toggle (UI). Existing automations are unchanged until the capability is switched on.
🤖 Generated with Claude Code