A community-driven registry for the Claude Code ecosystem. Not affiliated with Anthropic.
Are you the author? Sign in to claim
Enhanced MCP code execution. Agent framework-agnostic (optimized for Claude Code). Skills framework (99.6% token reducti
99.6% Token Reduction through CLI-based scripts and progressive tool discovery for Model Context Protocol (MCP) servers.
Note: This project is optimized for Claude Code with native Skills support. The core runtime works with any AI agent. Scripts with CLI arguments achieve 99.6% token reduction.
An enhanced implementation of Anthropic's Code Execution with MCP pattern, optimized for Claude Code, combining the best ideas from the MCP community and adding significant improvements:
Native Skills Support: This project includes proper Claude Code Skills integration:
.claude/skills/ - Skills in Claude Code's native format (SKILL.md + workflow.py)Dual-layer architecture:
.claude/skills/) - Native discovery and format./scripts/) - CLI-based Python workflows with argparseToken efficiency:
Note: Scripts work with any AI agent. Claude Code Skills provide native auto-discovery for Claude Code users.
This project builds upon and merges ideas from:
ipdelete/mcp-code-execution - Original implementation of Anthropic's PRIMARY pattern
elusznik/mcp-server-code-execution-mode - Production security patterns
Our contribution: Merged the best of both, added CLI-based scripts pattern, implemented multi-transport support, and refined the architecture for maximum efficiency.
Native Skills format in .claude/skills/ directory:
.claude/skills/
├── simple-fetch/
│ ├── SKILL.md # YAML frontmatter + markdown instructions
│ └── workflow.py # → symlink to ../../scripts/simple_fetch.py
└── multi-tool-pipeline/
├── SKILL.md # Multi-tool orchestration example
└── workflow.py # → symlink to ../../scripts/multi_tool_pipeline.py
How it works:
.claude/skills/Benefits:
Documentation: See .claude/skills/README.md for details
CLI-based Python workflows that agents execute with parameters:
# Simple example (generic template)
uv run python -m runtime.harness scripts/simple_fetch.py \
--url "https://example.com"
# Pipeline example (generic template)
uv run python -m runtime.harness scripts/multi_tool_pipeline.py \
--repo-path "." \
--max-commits 5
Benefits over writing scripts from scratch:
What's included:
Full support for all MCP transport types:
{
"mcpServers": {
"local-tool": {
"type": "stdio",
"command": "uvx",
"args": ["mcp-server-git"]
},
"jina": {
"type": "sse",
"url": "https://mcp.jina.ai/sse",
"headers": {"Authorization": "Bearer YOUR_KEY"}
},
"exa": {
"type": "http",
"url": "https://mcp.exa.ai/mcp",
"headers": {"x-api-key": "YOUR_KEY"}
}
}
}
Optional rootless container execution with comprehensive security:
# Sandbox mode with security controls
uv run python -m runtime.harness workspace/script.py --sandbox
Security features:
If you don't have uv installed:
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
# Verify installation
uv --version
# Clone repository
git clone https://github.com/yourusername/mcp-code-execution-enhanced.git
cd mcp-code-execution-enhanced
# Install dependencies (creates .venv automatically)
uv sync
# Verify installation
uv run python -c "from runtime.mcp_client import get_mcp_client_manager; print('✓ Installation successful')"
Important for Claude Code Users: This project uses its own
mcp_config.jsonfor MCP server configuration, separate from Claude Code's global configuration (~/.claude.json). To avoid conflicts, use different servers in each configuration or disable overlapping servers in~/.claude.jsonwhile using this project.
Create mcp_config.json from the example:
# Copy example config (includes git + fetch for examples)
cp mcp_config.example.json mcp_config.json
This config works out of the box:
{
"mcpServers": {
"git": {
"type": "stdio",
"command": "uvx",
"args": ["mcp-server-git", "--repository", "."]
},
"fetch": {
"type": "stdio",
"command": "uvx",
"args": ["mcp-server-fetch"]
}
},
"sandbox": {
"enabled": false
}
}
To add more servers: Edit mcp_config.json and add your own MCP servers. See docs/TRANSPORTS.md for examples of stdio, SSE, and HTTP transports.
# Auto-generate typed Python wrappers from your MCP servers
uv run mcp-generate
# This creates ./servers/<server_name>/<tool>.py files
# Example: servers/git/git_log.py, servers/fetch/fetch.py
# Test with a simple script
uv run python -m runtime.harness scripts/simple_fetch.py --url "https://example.com"
# If you configured a git server, test the pipeline
uv run python -m runtime.harness scripts/multi_tool_pipeline.py --repo-path "." --max-commits 5
If you want to use container sandboxing:
# Install Podman (recommended, rootless)
sudo apt-get install -y podman # Ubuntu/Debian
brew install podman # macOS
# OR install Docker
curl -fsSL https://get.docker.com | sh
# Verify
podman --version # or docker --version
# Test sandbox mode
uv run python -m runtime.harness scripts/simple_fetch.py --url "https://example.com" --sandbox
If using Claude Code, the Skills are already configured in .claude/skills/ and will be auto-discovered. No additional setup needed!
To use:
.claude/skills/For multi-step workflows (research, data processing, synthesis):
ls ./scripts/ → see available script templatescat ./scripts/simple_fetch.py → see CLI args and patternuv run python -m runtime.harness scripts/simple_fetch.py \
--url "https://example.com"
Generic template scripts (scripts/):
simple_fetch.py - Basic single-tool execution patternmulti_tool_pipeline.py - Multi-tool chaining patternNote: These are templates - use them as examples to create workflows for your specific MCP servers and use cases.
For simple tasks or novel workflows:
ls ./servers/ → discover available MCP toolsuv run python -m runtime.harness workspace/script.pyExample script:
import asyncio
from runtime.mcp_client import call_mcp_tool
async def main():
result = await call_mcp_tool(
"git__git_log",
{"repo_path": ".", "max_count": 10}
)
print(f"Fetched {len(result)} commits")
return result
if __name__ == "__main__":
asyncio.run(main())
Traditional Approach (High Token Usage):
Agent → MCP Server → [Full Tool Schemas 27,300 tokens] → Agent
Scripts with CLI Args (99.6% Reduction - PREFERRED):
Agent → Discovers scripts → Reads script docs → Executes with CLI args
Script → Multi-server orchestration → Returns results
Tokens: ~110 (script discovery + documentation)
Time: ~5 seconds
Script Writing (98.7% Reduction - ALTERNATIVE):
Agent → Discovers tools → Writes script
Script → MCP Server → Returns data
Agent → Processes/summarizes
Tokens: ~2,000 (tool discovery + script writing)
Time: ~2 minutes
runtime/mcp_client.py: Lazy-loading MCP client manager with multi-transport supportruntime/harness.py: Dual-mode script execution (direct/sandbox)runtime/generate_wrappers.py: Auto-generate typed wrappers from MCP schemasruntime/sandbox/: Container sandboxing with security controlsscripts/: CLI-based workflow templates with 2 generic examplesDON'T: Write scripts from scratch each time DO: Use pre-written scripts with CLI arguments
"""
SCRIPT: Your Script Name
DESCRIPTION: What it does
CLI ARGUMENTS:
--query Research query (required)
--limit Max results (default: 10)
USAGE:
uv run python -m runtime.harness scripts/your_script.py \
--query "your question" \
--limit 5
"""
import argparse
import asyncio
import sys
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--query", required=True)
parser.add_argument("--limit", type=int, default=10)
# Filter script path from args
args_to_parse = [arg for arg in sys.argv[1:] if not arg.endswith(".py")]
return parser.parse_args(args_to_parse)
async def main():
args = parse_args()
# Your workflow logic here
return result
if __name__ == "__main__":
asyncio.run(main())
See scripts/README.md for complete documentation.
{
"type": "stdio",
"command": "uvx",
"args": ["mcp-server-name"],
"env": {"API_KEY": "your-key"}
}
{
"type": "sse",
"url": "https://mcp.example.com/sse",
"headers": {"Authorization": "Bearer YOUR_KEY"}
}
{
"type": "http",
"url": "https://mcp.example.com/mcp",
"headers": {"x-api-key": "YOUR_KEY"}
}
See docs/TRANSPORTS.md for detailed information.
{
"sandbox": {
"enabled": true,
"runtime": "auto",
"image": "python:3.11-slim",
"memory_limit": "512m",
"timeout": 30
}
}
--network none--cap-drop ALL)no-new-privileges, SELinux labelsSee SECURITY.md for complete security documentation.
# Run all tests (129 total)
uv run pytest
# Unit tests only
uv run pytest tests/unit/
# Integration tests (requires Docker/Podman for sandbox tests)
uv run pytest tests/integration/
# With coverage
uv run pytest --cov=src/runtime
README.md (this file) - Overview and quick startCLAUDE.md - Quick reference for Claude CodeAGENTS.md.template - Template for adapting to other AI frameworksscripts/README.md - Scripts system guidescripts/SKILLS.md - Complete scripts documentationdocs/USAGE.md - Comprehensive user guidedocs/ARCHITECTURE.md - Technical architecturedocs/CONFIGURATION.md - MCP server configuration management (Claude Code vs project)docs/TRANSPORTS.md - Transport-specific detailsSECURITY.md - Security architecture and best practices# Type checking
uv run mypy src/
# Formatting
uv run black src/ tests/
# Linting
uv run ruff check src/ tests/
# Generate wrappers from tool definitions
uv run mcp-generate
# (Optional) Generate discovery config with LLM parameter generation
uv run mcp-generate-discovery
# (Optional) Execute safe tools and infer schemas
uv run mcp-discover
# Execute a script with MCP tools available
uv run mcp-exec workspace/script.py
# Execute in sandbox mode
uv run mcp-exec workspace/script.py --sandbox
| Approach | Tokens | Time | Use Case |
|---|---|---|---|
| Traditional | 27,300 | N/A | All tool schemas loaded upfront |
| Scripts with CLI Args | 110 | 5 sec | Multi-step workflows (PREFERRED) |
| Script Writing | 2,000 | 2 min | Novel workflows (ALTERNATIVE) |
Scripts with CLI args achieve 99.6% reduction - exceeding Anthropic's 98.7% target!
From ipdelete/mcp-code-execution:
From elusznik/mcp-server-code-execution-mode:
Enhanced in this project:
Scripts with CLI Arguments:
--query, --num-urls, etc.)Multi-Transport:
Dual-Mode Execution:
{
"mcpServers": {
"git": {
"command": "uvx",
"args": ["mcp-server-git", "--repository", "."]
}
}
}
{
"mcpServers": {
"local-stdio": {
"type": "stdio",
"command": "uvx",
"args": ["mcp-server-name"],
"env": {"API_KEY": "key"},
"disabled": false
},
"remote-sse": {
"type": "sse",
"url": "https://mcp.example.com/sse",
"headers": {"Authorization": "Bearer KEY"},
"disabled": false
},
"remote-http": {
"type": "http",
"url": "https://mcp.example.com/mcp",
"headers": {"x-api-key": "KEY"},
"disabled": false
}
},
"sandbox": {
"enabled": false,
"runtime": "auto",
"image": "python:3.11-slim",
"memory_limit": "512m",
"cpu_limit": "1.0",
"timeout": 30,
"max_timeout": 120
}
}
See the examples/ directory for:
example_progressive_disclosure.py - Classic token reduction patternexample_tool_chaining.py - LLM orchestration patternexample_sandbox_usage.py - Container sandboxing demoexample_sandbox_simple.py - Basic sandbox usageSee the scripts/ directory for production-ready workflows.
"MCP server not configured"
mcp_config.json server names match your calls"Connection closed"
which <command>"Module not found"
uv run mcp-generate to regenerate wrapperssrc/ is in PYTHONPATH (harness handles this)Import errors in skills
python scripts/script.py ❌uv run python -m runtime.harness scripts/script.py ✅Python 3.14 compatibility:
We welcome contributions! Areas of interest:
# Install with dev dependencies
uv sync --all-extras
# Run quality checks
uv run black src/ tests/
uv run mypy src/
uv run ruff check src/ tests/
uv run pytest
MIT License - see LICENSE file for details
| Feature | Original (ipdelete) | Bridge (elusznik) | Enhanced (this) |
|---|---|---|---|
| Progressive Disclosure | ✅ PRIMARY | ⚠️ ALTERNATIVE | ✅ PRIMARY |
| Token Reduction | 98.7% | ~95% | 99.6% |
| Type Safety | ✅ Pydantic | ⚠️ Basic | ✅ Enhanced |
| Sandboxing | ❌ None | ✅ Required | ✅ Optional |
| Multi-Transport | ❌ stdio only | ❌ stdio only | ✅ stdio/SSE/HTTP |
| Scripts Pattern | ❌ None | ❌ None | ✅ Yes + examples |
| CLI Execution | ❌ None | ❌ None | ✅ Immutable |
| Test Coverage | ⚠️ Partial | ⚠️ Partial | ✅ Comprehensive |
| Python 3.11 | ✅ Yes | ⚠️ 3.12+ | ✅ Stable |
uv syncmcp_config.json with your MCP serversuv run mcp-generate to create wrappersuv run python -m runtime.harness scripts/simple_fetch.py --url "https://example.com"AGENTS.md for operational guidescripts/ for available workflowsdocs/ for detailed documentationQ: Why Skills instead of writing scripts? A: Skills achieve 99.6% token reduction vs 98.7% for scripts, and execute 24x faster (5 sec vs 2 min). They're pre-tested, documented, and immutable.
Q: Can I use this without Claude Code? A: Yes, but with limitations. The core runtime (script writing, 98.7% reduction) works with any AI agent. The Scripts with CLI args (99.6% reduction) work for Claude Code's operational intelligence.
Q: Can I still write custom scripts? A: Yes! Scripts with CLI args are PREFERRED for common workflows (with Claude Code), but custom scripts are fully supported for novel use cases and other AI agents.
Q: What's the difference from the original projects? A: We merged the best of both (progressive disclosure + security), added CLI-based scripts pattern, multi-transport support, and refined the architecture.
Q: Why Python 3.11 instead of 3.14? A: anyio <4.9.0 has compatibility issues with Python 3.14's asyncio changes. 3.11 is stable and well-tested.
Q: Is sandboxing required? A: No, it's optional. Use direct mode for development (fast), sandbox mode for production (secure).
Q: How do I add my own MCP servers?
A: Add them to mcp_config.json, run uv run mcp-generate, and they're ready to use!
ls scripts/ and cat scripts/simple_fetch.py1000+ skills curated from Anthropic, Vercel, Stripe, and other engineering teams
Design enforcement with memory — keeps your UI consistent across a project
Universal SEO skill for Claude Code. 25 sub-skills + 18 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, bac
Route Claude Code traffic to any of 17 provider backends including free or local models