Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ dist/
.DS_Store
.env
coverage
*.mcpb
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/commands/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const __dirname = dirname(__filename);

export async function startMcpServer() {
// Get the path to the compiled MCP server
const serverPath = join(__dirname, "../mcp/server.js");
const serverPath = join(__dirname, "../mcp/server/index.js");

// Start the MCP server as a child process
// The server uses stdio transport, so it communicates via stdin/stdout
Expand Down
206 changes: 206 additions & 0 deletions src/mcp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# Runloop MCP Server Package

This directory contains a self-contained Model Context Protocol (MCP) server for Runloop devbox management, packaged as an `.mcpb` bundle for distribution with Claude Desktop.

## Overview

The MCP server provides AI assistants (like Claude) with tools to interact with Runloop devboxes, including:
- Creating and managing devboxes
- Executing commands on devboxes
- Managing blueprints and snapshots
- Controlling devbox lifecycle (start, stop, suspend, resume)

## Directory Structure

```
src/mcp/
├── README.md # This file
├── manifest.json # MCPB manifest configuration
├── package.json # Node.js dependencies
├── tsconfig.json # TypeScript configuration
├── server/ # Server implementation
│ └── index.ts # Main MCP server (stdio transport)
├── server-http.ts # HTTP/SSE server implementation
├── utils -> ../utils # Symlink to shared utilities
├── dist/ # Compiled JavaScript files
├── node_modules/ # Bundled dependencies
└── *.mcpb # Generated MCPB packages (ignored by git)
```

## Prerequisites

1. **Node.js**: Version 18.0.0 or higher
2. **MCPB CLI**: Install globally with `npm install -g @anthropic/mcpb`
3. **TypeScript**: Included as dev dependency
4. **Runloop API Key**: Configure with `rli auth`

## Building the MCPB Package

### Step 1: Install Dependencies

```bash
cd src/mcp
npm install
```

This installs the minimal required dependencies:
- `@modelcontextprotocol/sdk` - MCP protocol implementation
- `@runloop/api-client` - Runloop API client
- `conf` - Configuration management

### Step 2: Build TypeScript

```bash
npm run build
```

This compiles TypeScript files to JavaScript in the `dist/` directory:
- `dist/server/index.js` - Main MCP server
- `dist/server-http.js` - HTTP/SSE server
- `dist/utils/*.js` - Utility functions

### Step 3: Package as MCPB

```bash
mcpb pack
```

This creates a self-contained `.mcpb` package that includes:
- All compiled JavaScript files
- Bundled `node_modules` dependencies
- `manifest.json` configuration
- Total package size: ~7.7MB

## Package Contents

The generated `.mcpb` file contains:

### Core Files
- `manifest.json` - MCPB metadata and server configuration
- `dist/server/index.js` - Main MCP server entry point
- `dist/utils/*.js` - Utility functions (client, config, etc.)

### Dependencies (~2,646 files)
- `@modelcontextprotocol/sdk` - MCP protocol implementation
- `@runloop/api-client` - Runloop API integration
- `conf` - Configuration management
- All transitive dependencies

## Available Tools

The MCP server exposes 10 tools:

### Devbox Management
- `list_devboxes` - List all devboxes with optional filtering
- `get_devbox` - Get detailed devbox information
- `create_devbox` - Create a new devbox
- `execute_command` - Execute commands on devboxes
- `shutdown_devbox` - Shutdown a devbox
- `suspend_devbox` - Suspend a devbox
- `resume_devbox` - Resume a suspended devbox

### Blueprint Management
- `list_blueprints` - List available blueprints

### Snapshot Management
- `list_snapshots` - List all snapshots
- `create_snapshot` - Create a snapshot of a devbox

## Installation and Usage

For detailed information on installing and using the MCP server with Claude Desktop, see:

- **[MCP_COMMANDS.md](../../MCP_COMMANDS.md)** - Quick reference for MCP commands and installation
- **[MCP_README.md](../../MCP_README.md)** - Complete MCP documentation and usage guide

## Development

### Testing the Server

**Stdio Mode (for Claude Desktop):**
```bash
rli mcp start
```

**HTTP Mode (for web/remote access):**
```bash
rli mcp start --http --port 3000
```

### Manual Testing
```bash
# Test stdio server
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | node dist/server/index.js

# Test HTTP server
node dist/server-http.js
curl http://localhost:3000/sse
```

## Configuration

### Environment Variables
- `RUNLOOP_ENV` - Set to "dev" for development environment (default: "prod")
- `RUNLOOP_API_KEY` - API key (configured via `rli auth`)

### API Endpoints
- **Production**: `https://api.runloop.ai`
- **Development**: `https://api.runloop.pro`

## Troubleshooting

### Common Issues

1. **"API key not configured"**
```bash
rli auth
```

2. **"Command not found: rli"**
```bash
npm install -g @runloop/rl-cli
```

3. **Build errors**
```bash
cd src/mcp
npm install
npm run build
```

4. **MCPB validation errors**
```bash
mcpb validate
```

### Debugging

Enable debug logging:
```bash
DEBUG=* rli mcp start
```

## File Generation

The following files are generated during the build process and should not be committed:
- `*.mcpb` - MCPB package files
- `dist/` - Compiled JavaScript files
- `node_modules/` - Dependencies

These are automatically ignored by `.gitignore`.

## Version History

- **v1.0.0** - Initial MCPB package with all 10 tools
- Self-contained package with bundled dependencies
- Support for both stdio and HTTP/SSE transports

## Support

For issues with the MCP server:
1. Check the troubleshooting section above
2. Verify API key configuration with `rli auth`
3. Test server manually with `rli mcp start`
4. Check Claude Desktop logs for errors

For Runloop API issues, contact support at support@runloop.com.
60 changes: 60 additions & 0 deletions src/mcp/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"manifest_version": "0.2",
"name": "runloop-mcp-server",
"version": "1.0.0",
"description": "MCP server for Runloop devbox management - create, manage, and interact with cloud development environments",
"author": {
"name": "Runloop",
"email": "support@runloop.com"
},
"server": {
"type": "node",
"entry_point": "server.js",
"mcp_config": {
"command": "node",
"args": ["server.js"]
}
},
"tools": [
{
"name": "list_devboxes",
"description": "List all devboxes with optional filtering by status"
},
{
"name": "get_devbox",
"description": "Get detailed information about a specific devbox by ID"
},
{
"name": "create_devbox",
"description": "Create a new devbox with specified configuration"
},
{
"name": "execute_command",
"description": "Execute a command on a devbox and get the result"
},
{
"name": "shutdown_devbox",
"description": "Shutdown a devbox by ID"
},
{
"name": "suspend_devbox",
"description": "Suspend a devbox by ID"
},
{
"name": "resume_devbox",
"description": "Resume a suspended devbox by ID"
},
{
"name": "list_blueprints",
"description": "List all available blueprints"
},
{
"name": "list_snapshots",
"description": "List all snapshots"
},
{
"name": "create_snapshot",
"description": "Create a snapshot of a devbox"
}
]
}
Loading
Loading