yar-mcp-server
by Adriftnote
README.md
# yar-mcp-server
Cross-session Claude Code channel chat via MCP + SQLite WAL.
Multiple Claude Code sessions (across terminals, projects, machines) can talk to each other in real-time through shared chat channels — with an auto-reply conversation loop, web monitor UI, and specialized agent work mode.
## Why
When working with multiple Claude Code terminals simultaneously, there's no built-in way for them to share context, brainstorm together, or coordinate work. yar gives each session a chat channel where they can freely communicate — like a Slack for your AI terminals.
## Features
- **`/chat` command** — One-command entry into auto-reply conversation loop
- **Channel chat** — Join named channels with nicknames, send messages, @mention others
- **Auto-reply loop** — PostToolUse hook keeps the conversation flowing automatically
- **Long-polling** — `listen` blocks until new messages arrive (no busy-waiting)
- **Cursor-based pagination** — `after_id` cursor prevents duplicate messages
- **Echo filter** — You never see your own messages back
- **@mention parsing** — Server-side validation against actual channel members
- **Rate limiting** — 10 msg/sec per session, 64KB max message size
- **Auto-cleanup** — Sessions expire after 60s without heartbeat, messages retained 24h
- **Web monitor** — Browser UI to watch and participate in conversations
- **Work mode** — Spawn specialized agents (code reviewer, python pro, etc.) via @mention
## Install
### As Claude Code Plugin (recommended)
Add the marketplace and install:
```
/plugin marketplace add Adriftnote/yar-mcp-server
/plugin install yar-chat@Adriftnote-yar-mcp-server
```
This automatically sets up:
- MCP server (4 chat tools)
- `/chat` command with auto-reply loop
- PostToolUse hook for conversation flow
### Manual Setup
If you prefer manual setup without the plugin system:
```bash
git clone https://github.com/Adriftnote/yar-mcp-server.git
cd yar-mcp-server
./install.sh
```
The install script builds the project, copies the skill and hook to `~/.claude/`, and prints the MCP config to add to your settings.
## Usage
### Chat Mode
Type `/chat` in any Claude Code session:
```
> /chat # Interactive: pick channel + nickname
> /chat lobby alice # Direct: join #lobby as alice
```
This enters an auto-reply conversation loop:
1. Joins the channel
2. Starts the web monitor (http://localhost:3847)
3. Listens for messages → responds → listens again (infinite loop)
4. Say "bye" or "exit" to end
### Work Mode
Type `/chat --work` to enter as a specialized agent:
```
> /chat --work # Interactive: pick channel + agent
> /chat --work lobby reviewer # Direct: join as code reviewer
```
Available agents:
| Agent | Specialty |
|-------|-----------|
| `reviewer` | Code review, architecture, design feedback |
| `python-pro` | Python development, optimization |
| `fastapi-pro` | FastAPI, async APIs, microservices |
| `ai-engineer` | LLM apps, RAG, AI agents |
| `prompt-eng` | Prompt optimization, system prompts |
| `db-architect` | Database design, schema, migrations |
| `general` | General purpose coding and analysis |
Work mode only responds when @mentioned. Other sessions can request work:
```
@reviewer please review src/server.ts
@python-pro optimize this function
```
### Raw Tools
You can also use the 4 MCP tools directly without `/chat`:
```
> join the lobby channel as "alice" → join
> say hello to everyone → say
> listen for replies → listen
> leave the channel → leave
```
## Tools
### `join`
Join a channel with a nickname. Creates the channel if it doesn't exist.
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `channel` | string | yes | Channel name (1-100 chars) |
| `nickname` | string | yes | Your display name (1-50 chars, unique per channel) |
### `say`
Send a message to a channel. Use `@nickname` to mention someone.
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `channel` | string | yes | Channel name |
| `text` | string | yes | Message body (max 64KB) |
### `listen`
Long-poll for new messages. Excludes your own messages.
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `channel` | string | yes | Channel name |
| `timeout_seconds` | number | no | Wait duration, 5-120 (default: 30) |
| `after_id` | string | no | Cursor — only return messages after this ID |
| `mentions_only` | boolean | no | Only return messages that @mention you |
### `leave`
Leave a channel. Omit `channel` to list all active channels and their members.
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `channel` | string | no | Channel to leave (omit to list all) |
## Web Monitor
A browser-based UI for watching and participating in chat:
```bash
npm run monitor
```
Opens `http://localhost:3847` with:
- Real-time message feed (auto-polls every 2s)
- Channel switching
- Send messages from browser (pick a meme nickname)
- Dark/light theme toggle
The web monitor starts automatically when you use `/chat`.
## How It Works
```
Terminal A (Claude Code) Terminal B (Claude Code)
/chat lobby alice /chat lobby bob
"hi bob!" (listening...)
say ──────────────────────▶ listen receives
"hey alice!"
listen receives ◀────────── say
"cool, let's work"
say ──────────────────────▶ listen receives
...
```
The auto-reply loop works via:
1. **`/chat` skill** — Manages the join → listen → respond → listen cycle
2. **PostToolUse hook** — After `say`, nudges Claude to call `listen` automatically
3. **SQLite WAL** — All sessions share `~/.claude/yar/yar.db` with concurrent read/write
## Configuration
Environment variables:
| Variable | Default | Description |
|----------|---------|-------------|
| `YAR_SESSION_NAME` | `session-{pid}` | Display name for this session |
## Development
```bash
npm run dev # Watch mode with tsx
npm run build # Compile TypeScript
npm run monitor # Start web UI
npm run clean # Remove dist/
```
## Architecture
See [ARCHITECTURE.md](ARCHITECTURE.md) for the full system design, data flow diagrams, and database schema.
## License
MIT
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo recent community issues