A TypeScript implementation of the MCP (Model Context Protocol) server for managing Autobox AI simulations. This is a complete rewrite of the Python version with improved type safety, better performance, and unified stack consistency.
- 🚀 Simulation Management: Start, stop, and monitor AI simulations
- 🐳 Docker Integration: Each simulation runs in an isolated container
- 📊 Real-time Monitoring: Get status and logs from running simulations
- 🎯 Configuration Management: Create and validate simulation configs
- 🤖 AI-Assisted Setup: Generate simulation configurations with AI help
- 📝 Type-Safe: Full TypeScript implementation with Zod schemas
- ⚡ Modern Stack: Built with ES modules and latest Node.js features
-
Node.js 18+: Required for running the server
-
Docker: Must be installed and running
-
OpenAI API Key: Required for AI agent simulations
export OPENAI_API_KEY=sk-your-key-here -
Autobox Engine TypeScript: The engine Docker image must be built:
cd ../autobox-engine-ts ./bin/docker-build
# Clone and install dependencies
git clone https://github.com/margostino/autobox.git
cd autobox/autobox-mcp-ts
yarn install# Run in development mode with auto-reload
yarn dev
# Build TypeScript
yarn build
# Run tests
yarn test
# Run tests with coverage
yarn test:coverage
# Lint code
yarn lint
# Format code
yarn format-
Build the Docker image:
./bin/docker-build
-
Edit Claude Desktop configuration:
open ~/Library/Application\ Support/Claude/claude_desktop_config.json
-
Add the Autobox MCP server to the config:
{ "mcpServers": { "autobox": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "HOST_HOME=${HOME}", "-e", "HOST_USER=${USER}", "-e", "OPENAI_API_KEY=${OPENAI_API_KEY}", "-v", "/var/run/docker.sock:/var/run/docker.sock", "-v", "${HOME}/.autobox:/root/.autobox", "autobox-mcp:latest" ] } } } -
Restart Claude Desktop (Cmd+Q and reopen)
-
Build the Docker image:
./bin/docker-build
-
Add to Claude CLI:
claude mcp add autobox -s user docker -- run -i --rm \ -e HOST_HOME=$HOME \ -e HOST_USER=$USER \ -e OPENAI_API_KEY=$OPENAI_API_KEY \ -v /var/run/docker.sock:/var/run/docker.sock \ -v ${HOME}/.autobox:/root/.autobox \ autobox-mcp:latest
-
Verify connection:
claude mcp list # Should show: autobox ... ✓ Connected
- OPENAI_API_KEY: This environment variable is required and must be passed to the MCP container. The MCP forwards it to simulation containers so agents can communicate with OpenAI.
- HOST_HOME: Required for proper volume mounting when the MCP runs in Docker. Without this, config files won't be accessible to simulation containers.
- HOST_USER: Optional but recommended for proper file permissions.
Simulation fails with "ENOENT: no such file or directory" when loading configs:
- Ensure
HOST_HOMEis set in the Docker command - Verify
${HOME}/.autobox/config/simulations/contains your simulation configs - Check that the MCP container has access to
/var/run/docker.sock
Simulation fails with "401 You didn't provide an API key":
- Ensure
OPENAI_API_KEYis set in your environment before starting the MCP - Verify the environment variable is being passed to the MCP container with
-e OPENAI_API_KEY - Check that your OpenAI API key is valid and has credits
Cannot connect to Docker:
- Ensure Docker is running
- Verify
/var/run/docker.sockis mounted in the MCP container - Check Docker permissions (user must be in
dockergroup on Linux)
You can test the MCP server locally by running it directly and sending JSON-RPC messages via stdin/stdout.
Development mode (with auto-reload):
yarn devBuilt version:
yarn build
node dist/index.jsUsing Docker:
./bin/docker-runThe MCP server uses JSON-RPC 2.0 protocol over stdio. Each message must be on a single line.
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test-client","version":"1.0.0"}}}' | yarn dev{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"list_simulations","arguments":{}}}{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"list_available_configs","arguments":{}}}{"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"name":"start_simulation","arguments":{"config_name":"gift_choice","daemon":false}}}{"jsonrpc":"2.0","id":6,"method":"tools/call","params":{"name":"get_simulation_status","arguments":{"simulation_id":"03a961047a33"}}}{"jsonrpc":"2.0","id":7,"method":"tools/call","params":{"name":"get_simulation_execution_status","arguments":{"simulation_id":"03a961047a33"}}}{"jsonrpc":"2.0","id":8,"method":"tools/call","params":{"name":"get_simulation_metrics","arguments":{"simulation_id":"03a961047a33","include_docker_stats":true}}}{"jsonrpc":"2.0","id":9,"method":"tools/call","params":{"name":"ping_simulation","arguments":{"simulation_id":"abc123def456"}}}{"jsonrpc":"2.0","id":10,"method":"tools/call","params":{"name":"get_simulation_health","arguments":{"simulation_id":"03a961047a33"}}}{"jsonrpc":"2.0","id":11,"method":"tools/call","params":{"name":"instruct_agent","arguments":{"simulation_id":"abc123def456","agent_name":"Alice","instruction":"Focus on being more creative"}}}{"jsonrpc":"2.0","id":12,"method":"tools/call","params":{"name":"abort_simulation","arguments":{"simulation_id":"abc123def456"}}}{"jsonrpc":"2.0","id":13,"method":"tools/call","params":{"name":"stop_simulation","arguments":{"simulation_id":"abc123def456"}}}{"jsonrpc":"2.0","id":14,"method":"tools/call","params":{"name":"get_simulation_logs","arguments":{"simulation_id":"abc123def456","tail":50}}}Create a test script for interactive testing:
#!/bin/bash
# test-mcp.sh
# Build and run the server in the background
yarn build
node dist/index.js &
SERVER_PID=$!
# Wait for server to start
sleep 2
# Send test messages
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test-client","version":"1.0.0"}}}' | nc localhost 3000
echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' | nc localhost 3000
echo '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"list_simulations","arguments":{}}}' | nc localhost 3000
# Cleanup
kill $SERVER_PIDThe MCP Inspector provides a visual interface for testing MCP servers:
# Install MCP Inspector globally
npm install -g @modelcontextprotocol/inspector
# Run the inspector with your MCP server
mcp-inspector node dist/index.jsThen open your browser to test the server interactively.
The MCP Inspector provides the easiest way to test your MCP server during development.
Using TypeScript directly (no build required):
npx @modelcontextprotocol/inspector tsx src/index.tsThis will:
- Start the MCP Inspector web interface
- Run your TypeScript source directly via
tsx - Open a browser at
http://localhost:5173 - Provide a visual interface to test all tools interactively
Using built JavaScript:
npx @modelcontextprotocol/inspector node dist/index.jsAdvantages:
- ✅ No need to build (
tsxruns TypeScript directly) - ✅ Visual interface for testing tools
- ✅ See requests/responses in real-time
- ✅ Test tool parameters with form validation
- ✅ View full JSON-RPC messages
- ✅ No manual JSON-RPC formatting required
Quick test without prompts:
npx -y @modelcontextprotocol/inspector tsx src/index.ts- The server communicates via stdio (stdin/stdout), not HTTP
- Each JSON-RPC message must be on a single line
- The
idfield is used to match requests with responses - Docker must be running for simulation-related tools to work
- Set
OPENAI_API_KEYenvironment variable before starting - Set
LOG_LEVEL=debugfor verbose logging during testing
list_simulations- List all simulations (running and completed)start_simulation- Start a new simulation from configstop_simulation- Stop a running simulationget_simulation_status- Get detailed status of a simulationget_simulation_logs- Retrieve logs from a simulationget_simulation_metrics- Get real-time metrics (progress, agent stats, Docker stats)
list_available_configs- List available simulation templatescreate_simulation_config- Create new simulation config with AI assistancecreate_simulation_metrics- Create metrics configuration with AI assistancedelete_simulation- Delete a simulation configuration and its metrics files
instruct_agent- Send instructions to agents in running simulationsstop_all_simulations- Stop all running simulations at once
"List all available simulation configs"
"Start the summer_vacation simulation"
"Show me the status of running simulations"
"Create a new simulation about negotiating a business deal"
"Get the logs from simulation abc123"
"Delete the test_simulation config and its metrics"
"Send an instruction to Alice in the running simulation"
autobox-mcp-ts/
├── src/
│ ├── config/ # Configuration management
│ ├── docker/ # Docker container management
│ ├── mcp/ # MCP server implementation
│ ├── types/ # TypeScript types and schemas
│ ├── utils/ # Utilities (logger, etc.)
│ └── index.ts # Entry point
├── tests/
│ ├── unit/ # Unit tests
│ └── integration/ # Integration tests
└── bin/ # Build and run scripts
All configurations are validated using Zod schemas that match the autobox-engine-ts types:
import { SimulationConfigSchema, type SimulationConfig } from './types';
// Validated at runtime
const config = SimulationConfigSchema.parse(jsonData);- Type Safety: Full TypeScript with Zod validation
- Modern Async: Uses native Promises and async/await
- ES Modules: Modern module system
- Shared Types: Can share types with autobox-engine-ts
- Better Error Handling: Strongly typed error responses
- Improved Logging: Structured logging with log levels
- Testing: Jest-based comprehensive test suite
-
Check Docker:
docker ps docker images | grep autobox-mcp-ts -
Check Environment Variables:
echo $OPENAI_API_KEY
-
Test Manually:
./bin/docker-run
-
Image not found:
cd ../autobox-engine-ts ./bin/docker-build -
Permission errors:
- Ensure Docker Desktop is running
- On Linux:
sudo usermod -aG docker $USER
- Watch Mode: Use
yarn devfor auto-reload during development - Type Checking: Run
tsc --noEmitto check types without building - Debugging: Set
LOG_LEVEL=debugfor verbose logging - Testing: Use
yarn test:watchfor continuous testing
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Run
yarn lint && yarn test - Submit a pull request
Apache License 2.0
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Built with ❤️ in TypeScript