Secure workspace library · MCP-native · AGPL-3.0

Your agent's workspace.
Sandboxed. Audited.
MCP-native.

workspacemcp gives AI agents secure, auditable file access. Path sandboxing, DLP secret redaction, immutable audit logs, approval gates, and auto-checkpoints. 20 MCP tools.

agent_workspace.py
from workspacemcp import WorkspaceFactory

ws = WorkspaceFactory.default(root_path="./project")

# Read files — secrets auto-redacted by DLP
entry = await ws.read_file("src/config.py")
# API keys -> [REDACTED:generic_api_key]

# Edit with patch — refuses ambiguous matches
await ws.edit_file(
    "src/main.py",
    old_text='print("hello")',
    new_text='print("hello, world")',
)

# Every action is audited
log = await ws.audit_log(limit=10)

from workspacemcp.mcp_server import WorkspaceMCPServer
WorkspaceMCPServer(ws).run()
Path sandboxingDLP redaction
MCP stdio / SSEImmutable audit
Path sandboxing
DLP redaction
Immutable audit
20 MCP tools
Python 3.11+

Everything your agent needs
to work safely with files

"The Agent is a Guest, not the Master." Least privilege, sandboxed paths, read-only by default.

Path Sandboxing

All file operations confined to workspace root. Symlink traversal, .. escapes, and absolute path breakouts blocked.

SandboxViolationrestricted_paths

DLP (Secret Redaction)

15 built-in patterns: AWS keys, GitHub PATs, JWTs, Stripe keys, passwords, private keys, emails, phone numbers.

ContentFilter15 patterns

Immutable Audit Log

Every read, write, edit, delete logged with timestamp, agent ID, namespace, action, success/failure. Append-only.

InMemorySQLiteexport

Approval Gates

Critical files require human approval before writes. Configurable patterns.

ApprovalGateconfigurable

Auto-Checkpoints

Before every mutation, the current file state is snapshotted. Rollback to any checkpoint by ID.

createrestorelist

Patch-Based Editing

Search-and-replace patches with ambiguity detection. If old_text matches multiple locations, the edit is refused.

DiffEngineAmbiguousPatchError

Semantic Tree

Project structure with descriptions and token estimates per file. Respects .gitignore.

SemanticNodetoken estimates

Fast Search

Regex search across the entire workspace with context lines. Glob filtering, result limits.

regexglob filter

Configure once.
Work safely forever.

1

Configure

Set workspace root, allowed write patterns, restricted paths, approval rules.

ws = WorkspaceFactory.default(".")
2

Sandbox

Every path validated against the sandbox. Symlinks and traversal blocked.

sandbox.validate_write(path)
3

Execute

File operations run through DLP, approval gates, auto-checkpoints.

entry = await ws.read_file("src/app.py")
4

Audit

Every operation immutably logged. Query by action, path, or namespace.

log = await ws.audit_log(limit=50)

Ready to give your agent
a secure workspace?

Read the docs Star on GitHub