Skip to main content
Glama
Prakhar021-hub

Local Sandbox MCP Environment

Local Sandbox MCP Environment

An MCP server that gives an LLM a secure local workspace: it can write files, run code in a locked-down Docker container, and query an isolated SQLite database, with no access to the rest of your machine.

The problem

An AI that only suggests code is limited. An AI that runs code directly on your computer is dangerous: it could delete files, read secrets, use the network, or loop forever. This project lets the model write, run, see errors, and fix its own code, safely.

Related MCP server: Agent Workspace MCP Server

Demo

Claude using the sandbox

Architecture

flowchart LR
    A[Claude Desktop<br/>MCP client] -- stdio --> B[MCP Server<br/>FastMCP]
    B --> C[Workspace<br/>safe_path checks]
    B --> D[Executor]
    B --> E[(SQLite<br/>read-only)]
    D -- docker run --> F[Container<br/>no network, limited,<br/>read-only]
    F -. mounts read-only .-> C

Tools

Tool

Purpose

list_files, read_file, write_file

Manage files inside workspace/

run_python

Run a workspace script in an isolated container

describe_schema

Show the database tables

query_db

Run read-only SELECT queries

Threat model

Threat

Defense

Tested by

Path traversal (../, absolute paths)

safe_path resolves paths and checks they stay inside workspace/

tests/test_workspace.py

Destructive SQL (DROP, DELETE, ...)

SELECT/WITH-only check plus SQLite mode=ro

tests/test_database.py

Stacked SQL statements

sqlite3 rejects multiple statements

test_multiple_statements_rejected

Infinite loops / CPU hogging

10s timeout; container force-removed

test_infinite_loop_times_out

Orphaned containers

Unique --name + docker rm -f in finally

test_no_orphan_container_after_timeout

Network access / data exfiltration

--network none

test_network_blocked

Modifying host files

Workspace mounted :ro, --read-only root filesystem

test_workspace_is_read_only

Memory / fork bombs

--memory, --cpus, --pids-limit

Manual

Privilege escalation

Non-root user, --cap-drop ALL, no-new-privileges

Configuration

Output flooding

Output truncated at 10,000 characters

Manual

Setup

Requirements: Python 3.10+, uv, Docker (running).

git clone https://github.com/Prakhar021-hub/local-sandbox-mcp.git
cd local-sandbox-mcp
uv sync
docker build -t sandbox-mcp-runner docker/
uv run pytest -v

Try it in the MCP Inspector

PYTHONPATH=src uv run mcp dev dev_server.py

Connect to Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json under mcpServers:

"local-sandbox": {
  "command": "/path/to/uv",
  "args": ["--directory", "/path/to/local-sandbox-mcp",
           "run", "python", "-m", "local_sandbox_mcp.server"],
  "env": {
    "PYTHONPATH": "src",
    "PATH": "/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin"
  }
}

Restart Claude Desktop (Cmd+Q) and try: "Write a script that prints the first 10 Fibonacci numbers, run it, and show me the output."

Project structure

src/local_sandbox_mcp/   server, executor, database, workspace, config, logging
docker/Dockerfile        minimal non-root Python runner image
tests/                   pytest suite that attacks the sandbox

Limitations

Docker containers share the host kernel, so this is strong isolation for local development, but not a substitute for a VM-level sandbox against a determined attacker. Intended for local, single-user use.

License

MIT

Available Tools

6 tools
describe_schemaB

Show the SQLite database schema.

NameRequiredDescriptionDefault

No parameters

Output Schema

NameRequiredDescription
resultYes

TDQS

B3.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It does not state that the operation is read-only, what scope of schema is returned (tables only, or indexes/triggers/views too), or whether any permissions are required. The verb "Show" implies non-mutation, but that is the only implicit signal.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single front-loaded sentence with no filler. It is exactly as short as it can be while still identifying the verb and resource.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With an output schema present, the return format is covered elsewhere, and the zero-parameter schema means invocation is trivial. However, the description omits the read-only nature and scope of the schema, leaving behavioral gaps that matter for a database inspection tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool takes zero parameters, which is the baseline-4 case in the rubric. The empty schema is self-explanatory, so no additional parameter meaning is required from the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

A specific verb ("Show") and resource ("SQLite database schema") make the tool's function unambiguous. It distinguishes itself from query_db by targeting schema rather than data, though it never explicitly contrasts with the sibling that could be confused for it.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The purpose implies when to use it — when you need to inspect the database structure — but there is no explicit guidance, no exclusions, and no mention of query_db as the alternative for reading data. Usage is left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_filesB

List all files in the workspace.

NameRequiredDescriptionDefault

No parameters

Output Schema

NameRequiredDescription
resultYes

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full behavioral burden, yet it discloses almost nothing: no statement about recursion depth, hidden files, pagination, or whether the listing is workspace-wide only. The existence of an output schema covers the return shape, which limits some of the gap, but the behavioral traits of the listing itself remain undisclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single short sentence with no waste, front-loaded with the verb. It is arguably under-specified rather than verbose, but nothing in it fails to earn its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With an output schema present, return values need not be described, and there are no parameters to document. However, the key ambiguity for a listing tool — recursive vs top-level, and whether hidden or non-file entries appear — is left unresolved, so the description is only minimally sufficient.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool takes zero parameters and the schema is empty, so there is no parameter semantics to explain; the baseline of 4 applies. The description does not misleadingly imply parameters that do not exist.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

A clear verb+resource pair ("List all files") that an agent can immediately distinguish from read_file/write_file operations in the sibling set. It stops short of stating scope details like recursion or whether directories are included, so it is clear but not fully differentiated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives no guidance on when to use this versus read_file or run_python for discovery, and states no prerequisites. Usage must be inferred entirely from the tool name.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

query_dbA

Run a read-only SELECT query against the sample database.

NameRequiredDescriptionDefault
sqlYes

Output Schema

NameRequiredDescription
resultYes

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It does usefully disclose that execution is read-only and SELECT-based against the sample database, but it omits permissions, row limits, timeout behavior, and error handling for unsafe SQL.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single front-loaded sentence with no filler. Every phrase, especially read-only, SELECT, and sample database, contributes directly to selection and invocation.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The output schema exists, so the description need not explain return values. For a simple one-parameter query tool, the core operation is covered, but the description leaves gaps around how to discover the schema, what SQL dialect is accepted, and how the read-only restriction is enforced.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% for the single required sql parameter, so the description must add meaning. It does indicate that the input should be a SELECT query, which constrains the parameter beyond the bare schema type, but it gives no syntax, dialect, example, or length/limit guidance.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states a specific verb and resource: run a read-only SELECT query against the sample database. It is distinguishable from file tools and write tools, but it does not explicitly distinguish itself from sibling run_python or describe_schema, which could also be used to inspect data indirectly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The read-only SELECT phrasing implies the tool is for querying rather than mutating or exploring files. However, it gives no explicit guidance on when to use this instead of describe_schema, run_python, or other siblings, nor does it state prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

read_fileC

Read a file from the workspace.

NameRequiredDescriptionDefault
pathYes

Output Schema

NameRequiredDescription
resultYes

TDQS

C2.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description carries the full behavioral burden, yet it says nothing about binary/large file handling, encoding, permission requirements, or error behavior on a missing path. Only the implicit non-destructive nature of "Read" is conveyed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One short sentence with the operation front-loaded and no wasted wording. Brevity here borders on under-specification rather than bloat, but nothing is redundant.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return values need not be described, and the tool is structurally simple (one required param). However, with zero annotations and zero schema descriptions, the definition leaves the agent without any behavioral or path-format guidance needed to call it reliably.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The single path parameter has 0% schema description coverage (schema only says type string, title "Path"). The phrase "from the workspace" adds useful scoping (suggesting workspace-relative paths), but there is no guidance on absolute vs relative form, extension conventions, or path separators.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ("Read a file") plus the scope ("from the workspace"), so the basic operation is unambiguous. It never distinguishes itself from siblings such as list_files (enumerate) or write_file (mutate), so an agent must infer the boundary.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no statement of when to use this versus list_files, run_python, or query_db, and no prerequisites or exclusions. Usage is only implied by the verb "Read".

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

run_pythonA

Run a Python file from the workspace in an isolated Docker container (no network, limited CPU/memory, 10s timeout).

NameRequiredDescriptionDefault
pathYes

TDQS

A3.9/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does well: it discloses the isolation model (Docker), the absence of network, CPU/memory limits, and a 10s timeout — all traits an agent needs before invoking. It stops short of saying what happens on timeout (killed? error returned?) or what gets returned (stdout, exit code), which matters for a process-execution tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single sentence, front-loaded with the action and then the environment constraints. Every clause carries information; nothing is padding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The invocation-side context (sandbox, network, limits, timeout) is complete, but there is no output schema and the description says nothing about return values — an agent cannot tell whether it gets stdout, stderr, an exit code, or just success/failure, which is a meaningful gap for an execution tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Only one parameter exists and schema coverage is 0%, so the description must compensate. 'From the workspace' implies the path is workspace-relative, which is a useful hint, but it never clarifies whether absolute paths are accepted or whether the file must already exist.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (Run) plus resource (a Python file from the workspace) and immediately scopes it to an isolated Docker container. No sibling does execution, so it is trivially distinguishable from list_files/read_file/write_file/query_db.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied by 'Python file from the workspace' and by the sandbox constraints (no network, 10s), which hint at what is appropriate to run. However, it never says when to prefer this over alternatives or what preconditions apply (file must already exist; use write_file first).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

write_fileC

Create or overwrite a file in the workspace.

NameRequiredDescriptionDefault
pathYes
contentYes

Output Schema

NameRequiredDescription
resultYes

TDQS

C2.9/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden, and it does disclose the key destructive trait: existing files are overwritten. It says nothing about parent-directory creation, encoding, size limits, or failure behavior on missing paths, which are the remaining risks for a write tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single front-loaded sentence with no filler. It is efficient, though the brevity comes at the cost of the missing detail noted elsewhere rather than being purely a virtue.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists so return values needn't be explained, but for a two-required-param mutation tool with no annotations and zero schema descriptions, the description leaves path semantics, overwrite side effects on directories, and error conditions unaddressed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so neither parameter is documented anywhere. The description doesn't clarify whether path is absolute or workspace-relative, nor whether content is treated as UTF-8 text or raw bytes — both material to invoking it correctly.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Names a specific verb pair (create/overwrite) and resource (file in the workspace), which is enough to separate it from read_file and list_files. It stops short of explicitly differentiating itself from run_python, which could also write files.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to use this versus run_python or other write paths, and no prerequisites stated. The only implied usage cue is the word 'overwrite', which hints at caution but doesn't route the agent anywhere.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 6 tool updatesv0.1.0
    • First observeddescribe_schema
    • First observedlist_files
    • First observedquery_db
    • First observedread_file
    • First observedrun_python
    • First observedwrite_file

TDQS

A3.6/5.0

Scored across 6 tools

Disambiguation5/5

Each tool targets a clearly distinct resource and action: file CRUD, Python execution, and read-only database access are cleanly separated. The only adjacent pair, describe_schema and query_db, is well differentiated by one returning metadata and the other returning query results.

Naming Consistency5/5

All six tools follow a consistent snake_case verb_noun pattern (run_python, describe_schema, query_db, list_files, write_file, read_file). No mixed conventions or vague verbs.

Tool Count5/5

Six tools is a tight, well-scoped surface for a sandbox environment; every tool earns its place with no redundancy. Nothing feels padded or thin.

Completeness4/5

File read/write/list, code execution, and DB inspection cover the core sandbox workflow, but there is no delete_file or directory-creation operation, which agents may need when cleaning up or organizing the workspace. A way to pass arguments/stdin to run_python is also absent but workable.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides a secure, containerized Python sandbox for executing LLM-generated code with multi-layer isolation, along with JSON/CSV validation and workspace state snapshots.
    -
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI coding agents to understand, run, test, diagnose, review, benchmark, and validate real local software projects through the Model Context Protocol. It provides workspace-confined safe execution, structured evidence instead of raw logs, and Git checkpoints with guarded rollback that never destroys user work.
    3 npm
    MIT