Enterprise code bastion: Claude works on code with no file or shell access | Grigoriy Dobryakov

Grigoriy Dobryakov

Howto · breakdown

Breakdown 18 GitHub · open source

Enterprise code bastion: Claude works on the code with no file or shell access

Native file and shell tools are exactly the leak vector security won't sign off on. An enterprise code bastion removes them entirely (--tools "") and routes every action through a filtering MCP mediator that runs commands in an isolated container: Claude reasons and decides, but never touches code, secrets, or infrastructure directly.

CISO CTO Head of AI Architect

Problem

A large organization cannot hand an AI tool uncontrolled access to source code, secrets, and infrastructure. But it still wants Claude to understand the codebase and do real work in it. The naive setup gives the agent native file and shell tools — and that is exactly the access security cannot sign off on: nothing stops the agent from reading a secret, writing outside the task, or running a destructive command on the host.

Methodology

Don't constrain the agent with a prompt — constrain it with architecture. Strip the native tools entirely and route every interaction through a mediator that executes commands in a sandbox.

  1. 1. Project + task is the unit of work. A projects/ directory and a tasks/ directory. Each pair spins up a dedicated Docker container with only that project mounted at /workspace. Sessions don't see each other.
  2. 2. Claude with no tools. Claude Code launches with --tools "" — native read, write, and command execution are off. On its own the agent cannot read, change, or run anything in the system.
  3. 3. Access only through MCP. Instead of native tools, Claude talks to an MCP server over HTTP (FastMCP, stateless, port 17847). The session resolves from IDP_SESSION_ID; the server looks it up in sessions.csv and operates on its container. Exposed tools: ping, echo, secureBash.
  4. 4. Isolated execution. The command runs via docker exec inside the session container, not on the host, with a timeout (IDP_EXEC_TIMEOUT, default 300s). The result — stdout / stderr / exit_code — goes back to Claude.
  5. 5. Full audit. Every MCP request is written to logs/mcp.log (JSON Lines, body truncated at 16 KB) — a trail for review and compliance.

Starting a session is a real docker run from the launcher, and what's absent from it matters:

# scripts/start_session.py — how the session container comes up
cmd = ["docker", "run", "-d", "--name", session_id,       # session_id = idp-<uuid>
       "-v", f"{project_path}:/workspace", "-w", "/workspace",
       "-e", f"IDP_SESSION_ID={session_id}",
       image, "sleep", "infinity"]                          # image = ubuntu:22.04 (demo)

The launcher also closes path traversal before docker run — the project name can't escape projects/:

if not project or project in (".", "..") or "/" in project or "\\" in project:
    sys.exit(f"Invalid project name: {project!r}")
project_path = (PROJECTS_DIR / project).resolve()
if not str(project_path).startswith(str(projects_root) + os.sep):
    sys.exit(f"Invalid project path: {project!r}")

Launching Claude — note the --tools "":

./scripts/start_session.py demo demo-001      # → idp-<uuid>, container, row in sessions.csv
eval "$(./scripts/claude_command.py demo demo-001)"
# the generated command:
IDP_SESSION_ID=idp-aae519cd... \
  claude --append-system-prompt "<guard rules>" \
         -p "<task text from tasks/demo-001.md>" \
         --tools ""      # native tools off; only MCP left (secureBash, ...)

Artifact

github.com/dobryakov/enterprise-code-bastion (Python, Docker, MCP-over-HTTP). A working skeleton of the bastion: a session launcher with a path guard, a command builder, a FastMCP server with secureBash and docker exec, audit middleware, a CSV session registry. It's an inspectable artifact — which is exactly why it's worth naming honestly what's in it and what isn't yet (see below).

Where it breaks

The honest breakdown matters more than the method here: for a CISO audience, overstating a control that doesn't exist is worse than not having it.

For whom and why

This is the security model for AI-on-code where security has to sign off: isolation, least privilege, a single narrow path, full audit. Not a tutorial on running an agent — the architecture conversation about the line between giving the agent enough to be useful and keeping it physically unable to act outside what's permitted. The artifact shows the skeleton honestly: Claude reasons and decides, but with no tools and no direct access — and the open gaps (the gate, container hardening, auth) are named exactly where a security engineer will look for them.

About the author

Grigoriy Dobryakov — fractional / interim eng + AI leadership

Letting AI agents touch your codebase — safely?

Isolation, least privilege, per-operation filtering, and an audit trail for AI-on-code — with a working artifact, not a policy deck.

Discuss a fractional audit Email me

Other breakdowns

An engineering breakdown series: real task → methodology → working artifact → honest breakdown of where it fails.

Back to series →