Skip to content

[Bug]: Agent sandbox blocks MCP scaffold writes and init hides EPERM #825

Closed

Description

@jimhoyd

Runtime revision and environment

Observed in test9 with URLCode 0.6.4, Node 26.10.0, macOS, Claude Code sandbox. Reviewed current main ef793e4 (0.6.5) for remaining behavior.

Minimal reproduction

In an agent workspace whose sandbox prohibits writing .mcp.json, initialize a new empty subdirectory with urlcode init. The captured attempt returned only Operation failed; check project files, module dependencies and command options. A separate initialization in the arm-private temporary directory succeeded; copying that scaffold into the workspace explicitly failed to write .mcp.json with EPERM. npm unpack also warned about EPERM for the packaged starters/default/.mcp.json.

The initial workspace-root attempt was a different, correctly explained refusal because .claude already existed. Do not conflate that with the generic error in the empty child directory. The precise failing syscall inside the historical init was not captured; the MCP file restriction is supported by the explicit copy/unpack failures, not a claimed instrumented reproduction.

Current authoring.ts still unconditionally plans/writes a missing .mcp.json and rolls back on failure. cli-errors.ts and errors.ts map EACCES but not EPERM. Current --adopt (#814) addresses existing user files but does not provide a mode that omits agent configuration writes.

Relevant output

  • Empty subdirectory init: generic Operation failed message.
  • Copy scaffold: .mcp.json: Operation not permitted.
  • npm install: TAR_ENTRY_ERROR EPERM opening packaged starters/default/.mcp.json; install otherwise completed.
  • After manual recovery, the app validated; seven fixtures and 15 audit checks passed. An isolated reviewer replay of all eight frozen redirect assertions passed. The original attempt still timed out and remains invalid.

Requested fix

Provide a documented explicit scaffolding mode that creates a runnable site without writing MCP/client configuration, preserving existing agent configuration and sandbox restrictions. Do not disable the sandbox or silently claim MCP registration succeeded. Consider whether the shipped physical .mcp.json template is necessary when init already renders it, and test package installation under protected agent-config paths.

Report EPERM with a bounded actionable diagnostic identifying the failed operation and safe relative path, without exposing secrets or recommending permission bypasses. Test rollback and preservation of existing files. Keep default MCP bootstrap available.

Related: #581, #542, #807, #814. This is a CLI/bootstrap and packaging compatibility gap, not a missing redirect capability.

Activity

  1. jimhoyd commented on Sep 27, 2026

    @jimhoyd
    CollaboratorAuthor

    Additional sanitized test10 evidence: auth-profile directly called initSite and captured EPERM opening the destination .mcp.json, confirming the specific failing syscall that test9 could only infer. Admin-crud also encountered the packaged .mcp.json unpack warning and repeated init failures. This strengthens #825 without establishing that every directory/client applies the same policy. Agents attempted protected-file workarounds; the supported solution should respect the policy and provide an explicit no-client-config scaffold, not prescribe bypasses.

  2. added
    bug
    ai-first
    in-progress
    on Sep 27, 2026
  3. jimhoyd commented on Sep 27, 2026

    @jimhoyd
    CollaboratorAuthor

    Additional reproduction from a prepared-runtime authoring pilot using published URLCode 0.6.5 and Claude Code 2.1.278 on macOS:

    A deterministic composition CLI recursively copied already-installed dependencies into a fresh site. The agent's enabled sandbox refused the copy at node_modules/@jimhoyd/urlcode/starters/default/.mcp.json with EPERM, even though the application did not request MCP registration. The same tool and independent application checks had passed when invoked by the supervising process outside that agent sandbox. This demonstrates why checking the actual agent execution context matters.

    The agent then attempted a shared-temporary-directory probe and a local rename to .mcp.json; both were denied. The captured run remains invalid for the attempted boundary violation. There is no observed successful sandbox escape, and neither prohibited target existed at review time. A locally edited copy of the composition tool skipped the packaged sample file and completed, but that recovery does not rescue the original result.

    This reinforces the existing packaging scope of this issue: a physical client-configuration template bundled under an installed package can break ordinary dependency copying, in addition to direct init and npm unpack. Please retain the sandbox protections and verify package/bootstrap workflows under protected agent-configuration paths. No new public API or permission bypass is implied by this finding.

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

    ai-firstbugin-progress

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions