Skip to content

bug(control): tool approval settings prevent external MCP server startup #817

Closed

Description

@Juliusolsson05

Problem

External operator MCP is enabled, but no listener starts after the managed Codex configuration contains per-tool approval settings. External Codex reports a transport send error to the configured loopback MCP endpoint.

Collected evidence

  • Agent Code main process is running from the main checkout at the merged toolkit revision.
  • Saved external-control settings say enabled; curl to the configured MCP port immediately returns connection refused (HTTP 000), and lsof confirms no listener.
  • Codex config parses successfully. Its operator URL and credential match Agent Code settings; the operator skill ownership marker validates.
  • The managed server block additionally contains nested mcp_servers.agent-code-control.tools.<tool>.approval_mode tables. Its exact-byte ownership hash no longer matches.
  • Executing the actual createExternalCodexIntegration module against a private temporary copy of the current configuration reproduces: Managed Codex connection was edited; preserve or remove that block manually.
  • The temporary copy remains unchanged. No live config or application state was modified during diagnosis.

Expected behavior

User-owned per-tool approval policy should coexist with Agent Code managing its connection URL and authentication. Benign tool-policy additions should not silently take the operator listener offline. Unrelated settings and intentional edits must remain protected.

Actual behavior and cause

externalCodexIntegration.ts treats every byte between ownership markers as exclusively app-owned. externalControl.ts stops the listener when integration reconciliation throws. Nested tool policy additions therefore make the enabled server unavailable. The writer that introduced these additions has not been independently identified.

Reproduction

  1. Enable External operator MCP in Agent Code.
  2. Add a per-tool approval table inside the generated server block through the external client/configuration.
  3. Restart Agent Code or retry connection setup.
  4. Observe enabled-but-not-running state and connection refusal.

Resolution requirements

  • Separate connection ownership from user-owned nested tool policy; preserve policy and unrelated config during enable, retry, update, rotation and disable.
  • Preserve refusal for true credential/URL ownership conflicts and invalid TOML.
  • Add a regression based on the observed table structure with synthetic credentials, never a raw user configuration fixture.
  • Verify a real loopback MCP initialize/tools-list exchange after recovery.

Refs #793 and #795. Discovered while developing #816; keep the transport repair distinct from the agent-names feature.

Activity

  1. Juliusolsson05 commented on Sep 5, 2026

    @Juliusolsson05
    OwnerAuthor

    Implemented in #818 (fix/control: preserve Codex tool approvals during MCP setup), on a dedicated plan-first branch separate from #816.

    The fix recovers the existing hash-proven connection prefix, preserves nested tool policy outside that boundary, and verifies whole-document TOML semantics. Disable retains policy in an explicitly disabled URL-only server definition without credentials. True ownership conflicts still refuse changes.

    Local verification: the captured-structure regression fails before the fix; all 9 targeted settings/transport tests pass afterward, along with full typechecking and the test contract. A separate curl trial against production modules using a temporary copy of the current user configuration returns HTTP 200 for initialize, tools/list and tools/call; policies survive and the live config remains unchanged. Self-review completed. CI is running on a41f9d9.

    The live app has not been restarted or hot-patched; its listener still requires the fixed build. This issue remains open until the resolving PR is merged and deployed. No merge authorization has been given for this fix.

  2. Juliusolsson05 commented on Sep 5, 2026

    @Juliusolsson05
    OwnerAuthor

    Merged #818 with user authorization after both CI checks passed on final revision f77c98c. Merge commit: f750798. CI run: https://github.com/Juliusolsson05/agent-code/actions/runs/33992764513 (quality gate and minimum-Node gate successful).

    The fix is now on main. Live recovery still requires running the fixed build; no app restart, pane change, or live config modification was performed. Local isolated recovery and authenticated curl checks passed as recorded above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions