Skip to documentation
Early accessOpen Fork
Docs/Build

Build

Local agents and MCP

Connect Codex or Claude Code on your computer to an authorized Fork space.

Connect your agent

Run this setup in a terminal on your own computer. It installs Fork’s remote MCP endpoint for Codex or Claude Code, starts the OAuth sign-in flow, and deliberately refuses to run from inside a Fork sandbox.

Terminal
# Run this in a terminal on your computer, not inside Fork chat.

if [ -f /opt/fork-agent/fork_agent.py ] || [ -n "$FORK_WORKSPACE" ]; then
  echo "Run this setup on your computer, not inside the Fork sandbox."
  exit 2
elif command -v codex >/dev/null 2>&1 && codex --version >/dev/null 2>&1; then
  if ! codex mcp get fork 2>/dev/null | grep -Fq 'https://agent.fork.site/mcp'; then
    codex mcp remove fork >/dev/null 2>&1 || true
    codex mcp add fork --url https://agent.fork.site/mcp || exit
  fi
  codex mcp login fork || exit
elif command -v claude >/dev/null 2>&1 && claude --version >/dev/null 2>&1; then
  if ! claude mcp get fork 2>/dev/null | grep -Fq 'https://agent.fork.site/mcp'; then
    claude mcp remove fork -s user >/dev/null 2>&1 || true
    claude mcp add --transport http --scope user fork https://agent.fork.site/mcp || exit
  fi
  claude mcp login fork || exit
else
  echo "No working Codex or Claude Code CLI was found."
  echo "Repair Codex with: npm install -g @openai/codex@latest"
  echo "Repair Claude Code with its native installer: https://claude.ai/install.sh"
  exit 1
fi

printf '\nFork is connected. In your agent, use only workspace: main\nVerify it with fork_workspace_status and {"workspace":"main"}.\n'

What the MCP can do

After authorization, the connected agent can work only in spaces the signed-in account currently controls. Tools include:

  • list and inspect authorized spaces and runtime health;
  • list, read, search, edit, move, and delete bounded workspace files;
  • run bounded shell commands inside the space and read app or agent logs;
  • open, inspect, interact with, and screenshot the space preview;
  • manage allowed application-secret lifecycle operations;
  • list, create, and restore snapshots, or bootstrap short-lived native SSH access.

Safe edits

Fork file tools use SHA-256 preconditions. Read an existing file, make an exact edit with the returned hash, then read it again. Secret files are excluded or redacted, and UI work should finish with a preview inspection.

Agent instruction
Use only workspace: main.
Call fork_workspace_status with {"workspace":"main"} before making changes.
Read each existing file before editing it, and verify the rendered result afterward.
Fork documentationBuilt from the current control plane