# VcodeR native-agent MCP contract v2

VcodeR sells a remote workspace, not model access. The native agent owns provider authentication, session lifecycle, execution and permissions. VcodeR's stdio MCP server reads no provider credentials or raw transcripts and never launches app-server. A remote approval expresses a human decision; it does not override native permissions.

## Connection and selected conversations

Configure the bundled `mcp/vcoder-mcp.mjs` with the bundled Electron executable and `ELECTRON_RUN_AS_NODE=1`. The public origin is `https://getvcoder.com`; the browser workspace is `/workspace/`. Preserve other MCP servers. The Mac setup helper checks and reads back only `mcp_servers.vcoder`; an existing different entry is left unchanged.

`vcoder_connect({clientId})` selects a stable identity on first use, so multiple native processes can share the same MCP configuration. For a per-chat native process use a provider prefix plus its real native chat UUID; reuse it when resuming. A shared host process uses one clientId and multiplexes conversationIds. `VCODER_CLIENT_ID` can pin the identity explicitly; otherwise an omitted clientId falls back to a hash of provider and workspace. Do not give concurrent processes the same identity; the local state writer lock fails closed. `VCODER_AGENT_PROVIDER` and `VCODER_AGENT_NAME` label the connection. `VCODER_CONNECTION_DIRECTORY` is private local state, not a provider credential store. `VCODER_AGENT_WORKSPACE` optionally registers a selected project with the account service.

1. `vcoder_connect({clientId})` returns `{clientId,state,contractVersion:2}` and starts normal VcodeR browser approval. Use the returned identity in every subsequent call.
2. Let the customer select existing native chats and projects. From the native client, call `vcoder_sync_conversation({clientId,conversationId,projectId,cwd,title,context,messages})` for each selected chat. `conversationId` must be its real stable native ID. `cwd` is its existing checkout/worktree, never a newly substituted directory. `context` contains the public retained task summary. Each selected message is `{id,role:'user'|'assistant',text,createdAt}`. Never send secrets, system prompts, private reasoning or unselected chats.
3. The server returns a stable remote `threadId` derived from client and conversation IDs. Updating the same conversation preserves and deduplicates public messages by ID. Changing its project or worktree is rejected; a deliberate fork needs a different native conversation ID.
4. Call `vcoder_next_assignment({clientId,conversationId,waitSeconds:20})` **from that exact native conversation**. One call waits at most 25 seconds. Only assignments addressed to that identity are returned. A server connection without current native polling is not ready to execute.

The current mirror retains the most recent 80 public messages per selected chat and marks bounded history as truncated. It supports 100 selected conversations. It is not a native full-history export.

## Task continuity and execution

Assignments include request ID, native client/conversation IDs, remote thread ID, project ID, existing cwd, public retained context/history, prompt and optional spatial context. The native client continues its own original session. Follow-ups retain the same worktree. The server never creates a new worktree per message and never switches sessions on the client's behalf.

During execution:

- `vcoder_assignment_status({clientId,conversationId,requestId})` returns cancellation, task state and human approval decisions. Check before consequential actions and during long work.
- `vcoder_report({...identity,requestId,phase,text,diff?,terminal?})` accepts progress/completed/failed/cancelled, public output and structured review data. A cancelled request cannot report completion.
- `vcoder_request_approval({...identity,requestId,action,target,riskCategory})` publishes the full proposed action and target. Poll status until approved or denied. Pending, expired, denied and cancelled actions must not run. Approval does not bypass any native permission prompt. No agent-callable tool can approve itself.
- Stop is cooperative. A cancellation flag is durable; queued tasks cancel immediately, running clients must stop at their next check. VcodeR cannot forcibly terminate arbitrary native tools from MCP.

## Readiness and recovery

Thread summaries include `connectionState`: `connected` means transport exists; `listening` means that conversation recently polled; `working` means it claimed a task; `blocked` means human approval or interrupted work needs attention; `offline` means transport disconnected. `canAcceptDirectInput` is true only while listening. Readiness expires after the polling wait plus five seconds, and disconnect clears all listeners. The native client must keep polling while the customer wants remote access.

Claims, public history, results, approvals and receipts are written privately and fsynced before delivery. Completed receipts are compacted, while request fingerprints remain; the ledger fails closed at 20,000 requests instead of pruning unfinished work or replay protection. Duplicate request IDs replay receipts without re-execution; reusing an ID for different content is rejected. After a process restart, unfinished tasks become blocked and cancelled, pending approvals expire, and no assignment is reissued. The client must inspect the native session, files and external receipts, then explicitly call `vcoder_resolve_interrupted({...identity,requestId,note})`. This closes the interrupted request and never reruns it; the customer must request any further work separately.

## Codex capability and acceptance boundary

The official [Codex MCP documentation](https://developers.openai.com/codex/mcp) describes client-invoked tools and shared native configuration. MCP alone does not switch, resume or wake arbitrary existing Codex conversations. Each selected chat needs a native listener, or a supported native client controller that resumes its exact ID. `codex exec resume <UUID>` is a native CLI capability, but the product must separately prove its permission/approval and idle behavior; a server simulation is not that proof.

Release acceptance requires two existing native chats imported and remotely selected, useful execution in each, correct follow-ups and worktrees, diffs, human approve/deny, stop, idle, reconnect and restart without duplicates. Contract/unit tests and tool discovery do not satisfy physical-device or independent-customer acceptance. The previous direct app-server adapter remains an explicitly selected legacy alpha path and cannot supply paid MCP acceptance evidence.
