Filesystem isolation firewall confining agent operations to designated workspace while blocking directory traversal attacks (../, /etc, .env).
In strictly regulated enterprise R&D environments (such as Tier-1 automotive and industrial engineering), commercial cloud-based AI code assistants (like commercial GitHub Copilot) are frequently restricted due to proprietary IP leakage, strict network proxy constraints, and compliance mandates.
FastMCP Code Copilot was architected to bridge internal enterprise AI chatbots and desktop assistants (such as Claude Desktop, Cursor, or custom LLM gateways) directly to local codebases with institutional-grade cybersecurity rigor:
- Zero Data Egress: Operates entirely over local network transports (HTTP/SSE or standard I/O) without transmitting repository contents to unverified third parties.
- Hardware-Level Containment: Enforces strict directory containment, symlink escape checks, and path normalization.
- High-Throughput Engineering Context: Delivers 6 consolidated poly-tools cutting token overhead by 83%, multi-file atomic transactions with automatic rollback, line-scoped reading, and AST symbol extraction.
- Enterprise Web Interoperability: Starlette ASGI dual-transport (
/mcpand/sse) with CORS Private Network Access (allow_private_network=True) and FastMCP OriginGuard bypass for corporate HTTPS chatbots. - Zero-Clutter Reverse-Patch Undo: Centralized SQLite reverse-patch undo in
.copilot/history.dbwith zero.bakfiles created on disk.
The server operates as an asynchronous Starlette application exposing the standard Model Context Protocol (MCP) specification:
flowchart TD
Client["AI Assistant (Claude Desktop / Cursor / Internal Chatbot)"] -->|JSON-RPC via MCP| Server["Starlette ASGI Application (Uvicorn)"]
subgraph "Security Containment Middleware"
Server --> CORS["CORS & Request Logging Middleware"]
CORS --> PathValidator{"Path Sandbox Validator (security.py)"}
PathValidator -->|Absolute Path| Reject1["REJECT: Absolute paths forbidden"]
PathValidator -->|Traversal Attempt '../'| Reject2["REJECT: Directory traversal detected"]
PathValidator -->|Symlink Escape| Reject3["REJECT: Target outside PROJECT_ROOT"]
PathValidator -->|Normalized Safe Relative Path| ToolDispatcher["MCP Tool Dispatcher"]
end
subgraph "Consolidated Poly-Tools"
ToolDispatcher --> T1["file_ops (read, write, patch, delete, batch, atomic transactions)"]
ToolDispatcher --> T2["code_search (grep, symbol, fulltext, file-tree glob)"]
ToolDispatcher --> T3["run_command (sandboxed execution, pytest, git, npm)"]
ToolDispatcher --> T4["git_ops (status, compacted diff, shadow checkpoint, rollback)"]
ToolDispatcher --> T5["inspect_ast (structural symbol outlines, ~60 tokens)"]
ToolDispatcher --> T6["diagnostics (telemetry summary, token quota tracker)"]
end
ToolDispatcher --> SandboxWorkspace[("Designated Project Sandbox Root")]
- Root Boundary Enclosure: Every operation is strictly relative to the designated
PROJECT_ROOT. Attempting to access parent paths (../../) raises an immediate validation exception. - Symlink Traversal Protection: Evaluates
Path.resolve()against the physical filesystem. If a symlink resolves to an inode outside the project root, access is terminated immediately. - Internal State Concealment: Persistent search indexes (
.mcp_index) and telemetry databases (.copilot/) are excluded from file listings and search queries. - Controlled Execution Whitelist: Command execution is restricted to safe, verified developer toolchains (
pytest,git,python,npm,cargo,go) with Windows.cmdresolution and process-tree termination.
Instead of 25+ fine-grained schemas that bloat system prompts, operations are consolidated into 6 high-performance poly-tools:
- Actions:
read,write,patch,delete,info,batch_read, andtransaction. - Features: Sliced line reading, Windows CRLF line-ending preservation without double-newlines, atomic temp-file replacement, and multi-file atomic transactions with automatic rollback on error.
- Modes:
grep(regex with context lines),symbol(functions/classes across languages),fulltext(SQLite FTS5 indexing with<<<match>>>snippets), andfiles(glob file tree). - Features: Native Ripgrep integration with Python fallback and guaranteed
.git,.venv, andnode_modulesignore pruning.
- Features: Sandboxed execution of whitelisted CLIs, environment credential scrubbing (hiding API keys), hard timeouts, and process-tree cleanup via
psutil.
- Actions:
status,diff(compacted),checkpoint(Git shadow commit), androllback(safe revert without deleting untracked files).
- Features: Multi-language structural outlines (Python AST and Tree-sitter for JS/TS) returning classes, methods, and line spans in under 60 tokens.
- Features: System health checks, structured error telemetry (
.copilot/logs/trace.jsonl), and token quota tracker (session://token-usage).
MCP-Code-Copilot/
βββ assets/ # Architectural diagrams and figures
βββ copilot/ # Core modular engine
β βββ core/
β β βββ security.py # Strict path jail & credential sanitization
β β βββ sandbox.py # Process execution sandbox & timeouts
β β βββ history.py # SQLite reverse-patch undo engine (.copilot/history.db)
β βββ services/
β β βββ ast_service.py # Structural AST symbol extraction (~60 tokens)
β β βββ search_service.py # SQLite FTS5 & Ripgrep code search
β β βββ telemetry.py # Structured JSONL tracing & 1M token budget tracker
β βββ tools/
β β βββ __init__.py # FastMCP tool registry
β β βββ file_ops.py # Atomic file operations & transactions
β β βββ code_search.py # Unified code search
β β βββ run_command.py # Sandboxed command execution
β β βββ git_ops.py # Git status, shadow stash & rollback
β β βββ inspect_ast.py # Structural outline inspection
β β βββ diagnostics.py # Health, error classification & diagnostics
β βββ prompts/
β βββ __init__.py # Standard MCP Prompts (@mcp.prompt)
β βββ resources.py # Dynamic MCP Resources (@mcp.resource)
βββ tests/ # 25 test suites (431 passing tests)
βββ config.py # Centralized configuration & thresholds
βββ pyproject.toml # Explicit package discovery specification
βββ server.py # Starlette ASGI dual-transport server (/mcp & /sse)
βββ README.md # Master documentation
Install the package directly into your Python environment:
# Clone the repository
git clone https://github.com/Vignesh-Manivasakam/MCP-Code-Copilot.git
cd MCP-Code-Copilot
# Install with pip (editable CLI mode)
pip install -e .Start the server and specify your project workspace:
# Using the installed CLI wrapper:
mcp-code-copilot /path/to/your/project --port 8000
# Or via Python directly:
python server.py /path/to/your/project --port 8000Console Output:
============================================================
π FastMCP Code Copilot Server v3.0.0
============================================================
Project : my-project-workspace
MCP : http://127.0.0.1:8000/mcp
Health : http://127.0.0.1:8000/health
Sandbox : ENFORCED (/path/to/your/project)
============================================================
Add the server definition to your claude_desktop_config.json:
{
"mcpServers": {
"fastmcp-code-copilot": {
"command": "python",
"args": [
"-m", "server",
"D:\\path\\to\\your\\workspace",
"--port", "8000"
]
}
}
}Run the automated test suite to verify sandbox boundary enforcement:
# Run security and path traversal penetration tests
python -m pytest tests/test_security.py tests/test_fts5.py -v- License: Released under the open-source MIT License.
- Compliance: Engineered to conform with enterprise corporate IT governance guidelines. Eliminates commercial per-seat licensing fees while providing transparent, auditable code interaction logs.
- Author: Vignesh Manivasakam (LinkedIn Β· GitHub)
