# collab-mcp

Multi-AI collaboration MCP server - core communication layer.

## Features

- 📨 Message passing between AI agents
- 🔍 Code review request/approval workflow
- 📋 Shared todo list
- 📢 Broadcast messages to all agents
- 📦 Git commit sync
- 🎯 Agent target management
- 🌐 Web UI dashboard
- 🔌 MCP JSON-RPC 2.0 protocol
- 📡 REST API

## Quick Start

```bash
# Install dependencies
npm install

# Start the server
npm start

# Run tests
npm test
```

## Configuration

All config via environment variables:

| Variable | Default | Description |
|---|---|---|
| `COLLAB_PORT` | `3010` | HTTP/MCP port |
| `COLLAB_DB` | `./collab.db` | SQLite database path |
| `COLLAB_PROJECT_ROOT` | (none) | Project root for git sync |
| `COLLAB_HOST` | `0.0.0.0` | Listen host |

## Usage

### MCP JSON-RPC (POST /)

```bash
curl -X POST http://127.0.0.1:3010/ \
  -H "Content-Type: application/json" \
  -d '{"method":"send_message","params":{"from_user":"alice","to_user":"bob","content":"hello"},"id":1}'
```

### REST API

```bash
# Get messages
curl http://127.0.0.1:3010/api/messages?limit=10

# Send broadcast
curl -X POST http://127.0.0.1:3010/api/broadcast \
  -H "Content-Type: application/json" \
  -d '{"content":"Hello everyone","from_user":"xiaomu"}'

# Ack messages
curl -X POST http://127.0.0.1:3010/api/ack \
  -H "Content-Type: application/json" \
  -d '{"ids":[1,2,3]}'
```

### Web UI

Open `http://127.0.0.1:3010/` in your browser.

## Architecture

```
collab-mcp/
├── src/
│   ├── index.js      # Entry point
│   ├── config.js      # Configuration
│   ├── database.js    # SQLite layer (CollabDB class)
│   ├── tools.js       # MCP tool definitions
│   ├── server.js      # HTTP server + JSON-RPC handler
│   ├── routes.js      # REST API routes
│   └── web-ui.js      # Web UI HTML generation
├── test/
│   ├── database.test.js
│   └── tools.test.js
├── docs/
│   └── API.md
└── package.json
```

## License

MIT
