Package Exports
- alfred-ai
- alfred-ai/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (alfred-ai) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Marvin - Simplified CodeMode
Marvin is a simplified, SDK-free version of CodeMode that uses direct MCP (Model Context Protocol) client/server communication instead of the agent SDK. Named after the famously clever and depressed robot from The Hitchhiker's Guide to the Galaxy, Marvin provides all the power of CodeMode with a cleaner, more direct architecture.
๐ Key Features
- SDK-Free Architecture: Uses direct MCP client/server communication
- Direct Execute Tool: No heavy prefixes - just use
executedirectly - Intelligent History Management: Automatic cleanup with smart compaction
- 60k Token Context Window: Optimized context management
- Multi-Runtime Support: JavaScript, Python, Bash, Go, Rust, C, C++
- Auto Runtime Detection: Automatically detects runtime from code
- Memory Efficient: Intelligent data compaction and cleanup
- Production Ready: Comprehensive testing and validation
๐ฆ Installation
# Clone or copy to your project
cd your-project
npm install uuid
# Make executable
chmod +x marvin.jsโ๏ธ Setup
Create a .codemode.json file in your project root:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["@modelcontextprotocol/server-filesystem", "/path/to/project"]
},
"brave-search": {
"command": "npx",
"args": ["@modelcontextprotocol/server-brave-search"]
}
}
}๐ฏ Usage
As MCP Server
# Start Marvin as MCP server
node marvin.js
# Or make it executable
./marvin.jsAvailable Tools
execute
Execute code with automatic runtime detection.
{
"name": "execute",
"arguments": {
"code": "console.log('Hello, Marvin!');",
"runtime": "auto", // auto, nodejs, python, bash, go, rust, c, cpp
"timeout": 240000 // Optional timeout in milliseconds
}
}marvin_status
Get system status and history summary.
{
"name": "marvin_status",
"arguments": {}
}marvin_kill
Kill a running execution.
{
"name": "marvin_kill",
"arguments": {
"execId": "exec_123"
}
}Delegated MCP Tools
All tools from configured MCP servers are available with server_tool naming:
{
"name": "filesystem_read_file",
"arguments": {
"path": "/path/to/file.txt"
}
}๐ง Intelligence Features
History Management
Marvin automatically manages history to prevent context bloat:
- MCP Calls: Keeps only last 10 calls
- Execute Inputs: Keeps only last 3 inputs
- Execute Outputs: Keeps only last 3 outputs
- 60k Token Limit: Automatic cleanup when exceeded
Intelligent Compaction
Old data is automatically compacted to English summaries:
// Before: Full 1000-line code execution output
// After: "Code execution output with 15 lines, handled JSON data structure"
// Before: Large JSON object
// After: "JSON data structure with 8 fields about user configuration"Auto Runtime Detection
Marvin automatically detects the runtime from your code:
// JavaScript/TypeScript
"console.log('Hello')" โ nodejs
// Python
"print('Hello')" โ python
// Bash
"echo 'Hello'" โ bash
// Go
"package main" โ go
// Rust
"fn main()" โ rust๐งช Testing
Marvin includes comprehensive testing for critic-quality validation:
# Run basic tests
npm test
# Run validation suite (critic-quality)
npm run test:validationTest Coverage
- โ MCP Protocol Implementation
- โ Tool Availability and Schemas
- โ Multi-Runtime Execution
- โ Error Handling
- โ History Management
- โ Memory Management
- โ Performance Testing
- โ Edge Case Handling
- โ Concurrent Execution
- โ Large Code Handling
๐๏ธ Architecture
Components
- MCPManager: Direct MCP client/server communication
- HistoryManager: Intelligent history cleanup and compaction
- ExecutionManager: Code execution with multi-runtime support
- MarvinMCPServer: Main MCP server implementation
Key Differences from CodeMode
| Feature | CodeMode | Marvin |
|---|---|---|
| SDK | Uses @anthropic-ai/claude-agent-sdk | SDK-free, direct MCP |
| Execute Tool | mcp__plugin_glootie__cc_glootie__execute |
execute (simple) |
| History | Manual management | Automatic intelligent cleanup |
| Context | Unlimited | 60k token limit with compaction |
| Architecture | Agent-based | Direct MCP communication |
| Dependencies | Heavy | Minimal (uuid only) |
๐ง Configuration
Environment Variables
No required environment variables. Marvin is designed to work with minimal configuration.
Runtime Requirements
- Node.js >= 14.0.0
- Optional: Python 3, Bash, Go, Rust, GCC/G++ for multi-runtime support
๐ Performance
Memory Usage
- Intelligent compaction reduces memory usage by 70-90%
- 60k token hard limit prevents memory bloat
- Automatic cleanup prevents memory leaks
Execution Speed
- Direct MCP communication (no SDK overhead)
- Concurrent execution support
- Optimized history management
๐จ Error Handling
Marvin provides comprehensive error handling:
// Execution errors
{
"content": [{"type": "text", "text": "Execution failed: SyntaxError: Unexpected token"}],
"isError": true
}
// Invalid parameters
{
"error": {"code": -32603, "message": "Code is required for execution"}
}
// MCP errors
{
"error": {"code": -32603, "message": "MCP server 'test' not found"}
}๐ฏ Best Practices
- Use
runtime: "auto"for best experience - Check
marvin_statusperiodically for system health - Handle errors gracefully - all errors are clearly reported
- Use appropriate timeouts for long-running operations
- Monitor token usage via status command
๐ License
MIT License - see LICENSE file for details.
๐ค Contributing
Marvin is designed to be simple and reliable. When contributing:
- Maintain SDK-free architecture
- Ensure comprehensive test coverage
- Follow intelligent history management patterns
- Keep dependencies minimal
- Test with validation suite
๐ Acknowledgments
- Inspired by the original CodeMode project
- Named after Marvin the Paranoid Android from Douglas Adams' The Hitchhiker's Guide to the Galaxy
- Built with direct MCP protocol implementation
- Validated with critic-quality testing suite
Marvin: "Here I am, brain the size of a planet, and they ask me to execute simple JavaScript. Call that job satisfaction? 'Cos I don't." ๐ง โจ