Metadata-Version: 2.3
Name: claude-code-redis-channels
Version: 0.1.0
Summary: Minimal Redis-backed channel integration for Claude Code
Author: Dallas Pool
Author-email: Dallas Pool <codeninja@gmail.com>
Requires-Dist: anyio>=4.12.1
Requires-Dist: mcp>=1.26.0
Requires-Dist: pydantic>=2.12.5
Requires-Dist: redis>=7.3.0
Requires-Dist: starlette>=0.52.1
Requires-Dist: uvicorn>=0.42.0
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# Claude Code Redis Channels (claude-code-redis-channels)

A minimal Redis-backed channel integration for [Claude Code](https://code.claude.com/), implemented in Python.

## Overview
This package provides an MCP (Model Context Protocol) server that enables Claude Code to receive events and send replies via Redis. It supports multi-agent scenarios, inter-agent synchronization, and a synchronous "await" bridge for external callers.

## Features
- **Python-Native:** Built with `mcp` Python SDK and `asyncio`.
- **Multi-Agent Support:** Route messages to specific agents via unique `AGENT_ID`.
- **Two-Way Support:** Reply to messages from Claude Code using a Redis `reply` tool.
- **Sync-over-Async:** Await an agent's response via a blocking HTTP endpoint (`GET /await/{agent_id}`).
- **Inter-Agent Coordination:** Agents can wait for each other indefinitely using the `await_message` tool.
- **Minimal Dependencies:** Only requires `mcp`, `redis`, `starlette`, and `uvicorn`.

## Setup

### Requirements
- Python 3.12+
- `uv` (recommended)

### Installation
```bash
uv tool install .
```

## Configuration
Add the server to your `.mcp.json`:
```json
{
  "mcpServers": {
    "redis-channel": {
      "command": "uv",
      "args": ["run", "--package", "claude-code-redis-channels", "redis-channel"],
      "env": {
        "REDIS_URI": "redis://localhost:6379",
        "AGENT_ID": "dallas-main",
        "HTTP_PORT": "8000"
      }
    }
  }
}
```

## Await Endpoint (Sync Bridge)
The server can optionally host an HTTP endpoint that blocks until the agent sends a reply. This allows CLI scripts or microservices to "wait" for Claude to finish.

```bash
# In one terminal, wait for Claude's next message (indefinite wait)
curl "http://localhost:8000/await/dallas-main"

# In Claude Code:
# > reply chat_id="123" text="Task complete!"
```

## Usage
Start Claude Code with the development channel flag:
```bash
claude --dangerously-load-development-channels server:redis-channel
```

### Sending Messages
Send a JSON payload to a specific agent's inbox:
```bash
redis-cli PUBLISH claude:inbox:dallas-main '{"content": "Hello Dallas!", "meta": {"chat_id": "123"}}'
```

### Inter-Agent Communication
Agents can wait for each other indefinitely within their session:
`await_message(target_agent_id="other-agent")`

## Testing
A manual integration test script is included in `scripts/test_mcp.py`. It simulates a Claude Code session and verifies Redis communication.

```bash
uv run scripts/test_mcp.py
```

*Note: Requires a running Redis instance on localhost:6379.*
