Files
PaperClipAI/maps/agent-access-map
Nicky LeachandPaperclip 6f8ad3d77b Add verified session-local stdio MCP transport to Runner (#16526)
## Thinking Path

> - Paperclip manages AI agent runs and their tool authority.
> - Runner supplies provider sessions with assigned MCP connections.
> - The current native connection binding supports an HTTP gateway only.
> - Execution hosts also have private local tools with stdio MCP
interfaces.
> - Those tools need session-local registration and safe concurrency.
> - This pull request adds verified local stdio assignments beside the
existing gateway.
> - Providers receive the existing tool schemas and image content.

## Linked Issues or Issue Description

**Problem or motivation**

Runner can supply a native provider session with an HTTP MCP gateway,
but cannot also assign a verified local stdio MCP server without
persistent provider configuration. Execution hosts need a session-local
transport for local MCP tools, coordination for calls sharing a
resource, and native schema/image delivery. The pinned native Codex
client drops MCP images when `structuredContent` is also present.

**Proposed solution**

Add general stdio MCP transport support using host-assigned executable
digests, arguments, environment and a private Unix socket identifying
the shared resource. Tool implementations supply their own schemas and
responses; Runner forwards their native MCP schemas and content.
Register the transport for the current provider session. Serialize calls
across processes, keep unknown outcomes fenced, and authorize assigned
native Codex tools without a new prompt while routing explicit tool
confirmations through existing PRP permission requests. Retain the HTTP
gateway and applicable permission policy.

**Alternatives considered**

Reimplementing tools or translating their actions into provider-specific
APIs would tie the transport to individual tool implementations. Global
provider config would leak session assignments. Shell commands alone do
not deliver native MCP images or preserve MCP approval requests.

**Roadmap alignment**

This completes the existing Runner transport boundary. Related: #10690
(operator config for the legacy ACPX engine), #11605 (gateway delivery
of installed stdio connections), #16486 (preconfigured provider homes).
This change assigns local tools on the execution host and leaves those
administration paths intact.

## What Changed

- Add reserved, verified stdio bindings for native Codex and through the
shared ACPX runtime. ACPX clients must support stdio MCP assignments.
Read-only sessions omit the binding. No home/project config is
rewritten.
- Run the backend with only its assigned environment through the
verified executable launch path.
- Serialize all calls sharing a private Unix socket across sessions.
Metadata remains responsive. Queued cancellation prevents execution;
active calls remain fenced until acknowledgement. Unknown outcomes
require a resource restart.
- Authorize host-assigned native Codex tools without a new per-call
prompt, matching existing execution-host shell utilities. Preserve
explicit tool deny/prompt rules. Route requested MCP tool confirmations
through one-time PRP approvals, bound to the active thread and turn.
Keep shell escalation disabled and existing tool deny rules effective.
ACPX adapters retain their applicable ACPX permission policy.
- Preserve schemas and image blocks. For native Codex 0.160/0.162,
retain structured metadata as MCP text on image-bearing results to avoid
the client's image-loss bug. ACPX adapters receive the original
response.
- Document transport authority, cancellation and recovery limits.

## Verification

- `pnpm -r typecheck` and `pnpm build` passed with pnpm 9.15.4 and Rust
1.97.1 on macOS arm64.
- Before Apex, full `paperclip-runner-core` Rust tests passed. After the
fixes, all 379 library tests and eight subprocess tests using a generic
stdio MCP fixture pass. Those subprocess tests cover schema/image
passthrough, assigned-only environment, executable drift, call
serialization, cancellation and unknown outcomes. The native Codex suite
passed 91 tests with two intentionally ignored;
`receipt_limit_rejects_the_call_and_keeps_polling_when_interrupt_fails`
timed out waiting for `turn.interrupted`, including an isolated retry.
The unchanged pre-fix commit `80917b301a2309f7966a466cf0c198a2112be2d5`
reproduces the same timeout in isolation; this local native-suite run is
not claimed as fully passing.
- All 252 native controller tests pass against the final narrowed
approval branch. Focused TypeScript transport/permission suites passed
(298 tests); final binding, read-only host, policy and adapter checks
passed (105 tests).
- **Provider-client smoke coverage:** pinned Codex 0.160.0 through
native Runner and Claude SDK 0.3.286 used local stdio MCP servers and
loopback model API fixtures without live model credentials. These
clients define the smoke-test coverage; this is not an exhaustive
adapter compatibility test. Image responses reached the next model
request as typed image blocks. Native Codex checks also verified
unattended execution without approval requests, explicit per-tool prompt
denial without backend execution, disabled-tool rules, and stale-turn
approval rejection.
- Two Greptile concurrency findings were reproduced with failing
subprocess tests and fixed: pending cancellation under output
backpressure, and a ctime-based fence reset after chmod. Initial checks
exposed Codex CLI option-scope and key-quoting errors, which were
corrected. The existing ordinary elicitation regression also exposed an
overly broad request branch; the final branch handles explicit tool
approvals only.
- `pnpm test:run` was attempted. The broad local server suite hit
persistent embedded PostgreSQL startup failures and unrelated local Git
fixture failures; it was stopped with the failure log retained. Those
local results are not claimed as passing. Hosted Linux CI gates passed
on the reviewed runtime commit, as recorded below.
- First Apex review found three additional defects, now fixed with
regressions: keep the resource-lock socket snapshot instead of sampling
the socket twice; project native permission requests with durable
turn/item IDs while retaining provider IDs in details; validate provider
response conversion before marking a request as settling. The retry
regression failed before the fix. Focused Codex request/adapter checks
pass (23 tests), server permission projection passes (16 tests), and all
379 Runner library tests pass. The broader database-backed bridge suite
was attempted but its local PostgreSQL setup timed out; 29 tests did not
execute. This local failure is retained, not claimed as passing.
- Runtime acceptance before the documentation clarification, on
`bd4fccae001157beb5bc76ff17c1920a5db3105a`: standard Greptile 5/5, then
Apex 5/5 with no unresolved threads; all 60 checks complete successfully
or intentionally skip. Ten CI jobs were interrupted by the same runner
shutdown, including one stale job that required cancellation before
retry; the same-commit retry passed. Hosted Rust tests also pass,
including the native suite with the local baseline timeout noted above.
- `git diff --check`, map validation, and pre-push secret/PII scan
passed.

## Risks

- No live model account or deployment isolation qualification was run.
The loopback fixture proves the actual vendor-client request format, not
model interpretation.
- Stdio MCP support uses the current host-assignment contract: each
binding requires a verified executable and a private Unix socket
identifying the serialized resource. Other platforms retain the HTTP
path. No provider version was upgraded.
- A lost acknowledgement blocks subsequent calls until the host restarts
the assigned resource. Direct shell calls are outside this MCP fence and
retain the existing shell policy.
- Preconfigured Claude remains unattended and denies interactive
approval requests. Host assignment authorizes native Codex local tools;
it must be supplied only for sessions already authorized to use the
resource.

## Model Used

OpenAI Codex, GPT-6, with reasoning and repository/tool execution. The
session does not expose a more specific model identifier or
context-window size.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [ ] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-10-16 10:39:38 -07:00
..
…
…
…

Paperclip agent access map

This map accompanies the feature map. It records APIs, agent entry points, permission boundaries and verification for the same capability IDs. The shared contract defines the format and maintenance rules.

Browse access contracts

The same-named feature recipes define navigation and capability IDs. Run node scripts/storybook-catalog.mjs for the generated maps/generated/agent-access-map.md index, or browse the published feature guide. Add or update the affected companion; there is no central registration or count.

Existing baseline source references describe the original inspection, not current verification. Record new executed evidence in the PR, issue, or CI artifact with its revision and scope. Do not refresh unrelated headers as bookkeeping.

Using an entry

Read its Policy and Gaps before selecting an agent path. Native fallback, legacy REST/CLI, stdio MCP and a personal assistant connection can have different authority and availability. Use a real admitted production binding; a scenario declaration is not an installed tool. A restricted entry records current enforcement and leaves any unresolved delegation decision visible.

For API catalog disagreements, follow the route/service authorization and record discovery drift. For not-applicable, retain the concrete exception and local path. Split shared business operations from client-only presentation.

Use maintain-verification-skill to reconcile changed source and both maps. Use verify-paperclip and existing API/runner/MCP fixtures to collect the permitted-agent and denial evidence; report blocked/not-run coverage honestly. Run node scripts/check-maps.mjs after editing. The structural check does not certify permissions, API catalog coverage, tool admission or live behavior.

Native REST transport

The call_api parity change reconciles affected baselines against 58e16dbddfc9c8d0cf60867f9d9847f0feda055b and the changes in this PR. Ordinary REST operations use the same route authorization as legacy agent REST. Dedicated tools remain optional for those operations; protocol endpoints still need their existing clients. Board-only routes remain restricted for agent identity.

Native search_api / call_api requires operator rollout admission, a running authorized native run, current task assignment and execution-run binding, company and budget authority, task privacy, and a permitted work mode. Ask and Plan retain mutation restrictions, and runs retain their admitted JWT scope during restart recovery even when task mode changes. A waiting agent does not gain independent native control just because a REST route exists.

Credential-bearing replies, including company exports and their legacy alias, stay inline under a 10 MiB limit and use encrypted mutation receipts. Other saved API snapshots are limited to the issuing actor and responsible user, plus authorized administrators. Artifact uploads enforce the same access checks as downloads; private snapshots are excluded from company exports and public company logos. Explicit deliverables use the existing sharing path. Native event history, checkpoints and completion records omit API bodies while preserving receipt metadata and replay digests. Restored webhook secrets use the same encrypted receipt and inline response policy as newly created webhook secrets. Task image access requires the company boundary and the task permission; skill-test and low-trust agents do not need company-wide browsing authority. Completion replay applies the same idempotent projection to stored and expected payloads; the run-log guide describes its fields.

Sources: API client, catalog, native authority, credential storage classification, snapshot access, and history redaction. The affected entries remain baseline and source-only; this reconciliation does not certify every operation. Targeted real-route proof lives in the API integration suite, including owned routines, skill tests, scoped secrets, proposals and private export replay.