Skip to main content
Glama
README.md
# Compartment Box MCP

A Model Context Protocol (MCP) server that organizes, stores, and executes tool calls inside named **compartment rooms** — like a toolbox with labeled drawers. One MCP config entry replaces all your other MCPs. The compartment box acts as a **full proxy** that launches and calls other MCP servers on demand.

## Why?

| Problem | Compartment Box Solution |
|---|---|
| Dozens of MCP entries in your config | **One entry** — the only MCP you need |
| LLM sees duplicate tools and gets confused | Compartment box is the **single gateway** — other servers run behind it |
| LLM hallucinates tool call parameters | Stored tools have **explicit schemas with {{param}} templates** |
| No way to combine tools into workflows | **Minecraft-style recipe crafting** chains tools together |
| Hard to organize tools by purpose | **Named rooms** with icons, descriptions, and tags |
| Can't save and reuse MCP tool calls | **`create_mcp_tool`** stores calls to any MCP server for instant recall |

## How It Works

```
┌─────────────────────────────────────────────────────────┐
│                    Your MCP Config                       │
│                                                          │
│   "compartment-box"  ← the ONLY entry you need          │
└──────────────┬───────────────────────────────────────────┘
               │
               ▼
┌─────────────────────────────────────────────────────────┐
│              Compartment Box MCP Server                   │
│                                                          │
│  ┌──────────┐ ┌──────────┐ ┌──────────┐                │
│  │ Room A   │ │ Room B   │ │ Room C   │  ...rooms      │
│  │ 🔧 shell │ │ 🔌 mcp   │ │ ⚗ recipe │                │
│  │ 🌐 http  │ │ 🔌 mcp   │ │ ⚗ recipe │                │
│  └──────────┘ └──────────┘ └──────────┘                │
│                     │                                    │
│               MCP Client Manager                         │
│          (spawns servers on demand)                       │
│                     │                                    │
│       ┌─────────────┼─────────────┐                     │
│       ▼             ▼             ▼                     │
│  ┌─────────┐  ┌─────────┐  ┌─────────┐                │
│  │ server1 │  │ server2 │  │ server3 │  ...registered  │
│  └─────────┘  └─────────┘  └─────────┘                │
└─────────────────────────────────────────────────────────┘
```

## Quick Start

### 1. Build

```bash
npm install
npm run build
```

### 2. Add to your MCP config

This is the **only MCP entry** you need:

**Cursor** (`~/.cursor/mcp.json`):

```json
{
  "mcpServers": {
    "compartment-box": {
      "command": "node",
      "args": ["C:\\Users\\isman\\Documents\\compartment box mcp\\dist\\index.js"]
    }
  }
}
```

**Claude Desktop** (`claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "compartment-box": {
      "command": "node",
      "args": ["C:\\Users\\isman\\Documents\\compartment box mcp\\dist\\index.js"]
    }
  }
}
```

### 3. Register your existing MCP servers

Move your other MCP servers out of the config and into the compartment box. Ask your LLM:

```
"Register an MCP server called 'brave-search' with command 'npx'
 and args ["mcp-remote", "https://search.example.com/mcp"]
 with env API_KEY=abc123"
```

Or use `register_server` directly. Registered servers are saved to `~/.compartment-box/servers.json` and launched on demand when an `mcp_call` tool is executed.

### 4. Optional: Custom storage location

Set `COMPARTMENT_BOX_PATH` environment variable to change where data is saved.
Default: `~/.compartment-box/data.json` (tools) and `~/.compartment-box/servers.json` (servers)

## Tools (14 total)

### Room Management

| Tool | Description |
|---|---|
| `create_room` | Create a new named compartment room |
| `list_rooms` | Visual ASCII display of the entire compartment box |
| `delete_room` | Remove a room and all its tools |

### Tool Storage

| Tool | Description |
|---|---|
| `store_tool` | Store a shell command, HTTP request, script, or MCP call into a room |
| `create_mcp_tool` | Create and auto-save an MCP tool call definition (streamlined for MCP calls) |
| `remove_tool` | Remove a tool from a room |
| `move_tool` | Move a tool between rooms |
| `inspect_tool` | View full details of any stored tool |
| `search_tools` | Search across all rooms by name, description, tags, or type |

### Execution & Crafting

| Tool | Description |
|---|---|
| `execute` | Run tools with flexible targeting (`tool`, `room/tool`, `room1 + room2`) |
| `craft_recipe` | Combine tools into a new composite recipe (Minecraft-style crafting) |

### Server Management

| Tool | Description |
|---|---|
| `register_server` | Register an external MCP server so the box can launch and proxy its tools |
| `unregister_server` | Remove a registered server |
| `list_servers` | Show all registered MCP servers and their launch configs |

## Concepts

### Rooms

Named containers for organizing tools. Each room has a name, icon, and description. Rooms are auto-created when you store a tool into a room that doesn't exist yet.

```
"Create a room called devops with a gear icon for CI/CD tools"
```

### Stored Tools

Each tool has:
- **Name** and **description** (for LLM comprehension)
- **Execution type**: `shell`, `http`, `script`, or `mcp_call`
- **Parameters**: `{{param}}` template variables that get substituted at runtime
- **Tags** for organization and search

```
"Store a shell tool called 'deploy' in devops that runs 'git push origin {{branch}}'"
```

### MCP Tool Calls (Proxy Execution)

The compartment box acts as a full MCP proxy. When you store an `mcp_call` tool and execute it:

1. The box looks up the server in its registry (`servers.json`)
2. Spawns the server process and connects as an MCP client
3. Calls the tool with `{{param}}` values resolved
4. Returns the result directly
5. Keeps the connection alive for future calls

This means **other MCP servers don't need to be in your config at all** — no duplicate tools confusing the LLM.

```
"Create an MCP tool called 'web-search' in my search-tools room
 that calls brave_web_search on the brave-search server
 with a {{query}} parameter"
```

### Flexible Execution

The `execute` tool understands multiple targeting patterns:

| Pattern | Behavior |
|---|---|
| `"deploy"` | Find and run the tool named "deploy" in any room |
| `"devops/deploy"` | Run "deploy" specifically from the "devops" room |
| `"devops"` | Run ALL tools in the "devops" room |
| `"build + test + deploy"` | Run multiple tools in sequence |
| `"ci-room + deploy-room"` | Run all tools from both rooms |

### Recipe Crafting

Combine existing tools into reusable composite workflows — like Minecraft crafting:

```
"Craft a recipe called 'full-deploy' that combines build, test, and deploy
 from the devops room. Run them sequentially."
```

Recipe modes:
- **sequential**: Run steps in order, collect all outputs
- **parallel**: Run all steps simultaneously
- **pipe**: Chain outputs — step N's output feeds into step N+1 via `{{outputKey}}`

Recipes can combine any tool types — shell commands, HTTP calls, scripts, and MCP calls all work as recipe ingredients.

## Storage

Two JSON files in `~/.compartment-box/` (portable and human-readable):

| File | Contents |
|---|---|
| `data.json` | All rooms, tools, recipes, and usage statistics |
| `servers.json` | Registered MCP server launch configs (command, args, env) |

## Architecture

```
src/
  index.ts            MCP server — 14 tool definitions & handlers
  types.ts            TypeScript interfaces (5 execution types)
  storage.ts          JSON file persistence for rooms & tools
  server-registry.ts  MCP server launch config registry
  client-manager.ts   Spawns and manages connections to MCP servers
  executor.ts         Shell, HTTP, script, MCP call, and recipe execution
  visualizer.ts       ASCII compartment box rendering
```