Multi-channel AI gateway with extensible messaging integrations
Project description
PyClaw
Multi-channel AI Gateway โ Connect your AI Agent to 27+ messaging platforms through a unified gateway.
PyClaw is a Python rewrite of openclaw/openclaw, featuring MCP tool integration, 20+ built-in tools, cross-platform UI (Web/Desktop/Mobile), and an OpenAI-compatible HTTP API.
Documentation โ Quick Start, Installation Guide, Configuration, Concepts, Troubleshooting.
Features
๐ค Agent Runtime
- Multi-provider LLM streaming (OpenAI, Anthropic, Google Gemini, Ollama, and 25+ more)
- 20+ built-in tools: file I/O, grep, find, exec, web search/fetch, browser, memory, cron, TTS, etc.
- MCP (Model Context Protocol) support โ connect any stdio or HTTP MCP server
- Task planner with multi-step Plan/Step decomposition
- User interrupt system (cancel/append mid-generation)
- Sub-agent orchestration (spawn, steer, kill)
- SKILL.md-based skill injection with ClawHub marketplace
๐ง Memory System
- Context compaction with LLM-based summarization
- Dialog persistence (JSONL format with date-based sharding)
- Hybrid search: SQLite FTS5 + LanceDB vector search
- Daily summary service for session consolidation
- Active Memory with multiple query modes
- Wiki System for structured knowledge base
๐ฌ 27+ Messaging Channels
Telegram, Discord, Slack, WhatsApp, Signal, iMessage, Feishu, DingTalk, QQ, MS Teams, Matrix, IRC, LINE, Twitch, Nostr, and more.
Unified ChannelPlugin interface โ each channel is a self-contained module with DM/group policy, allowFrom whitelists, and mention gating.
๐ช Gateway
- FastAPI + WebSocket v3 bidirectional protocol
- OpenAI-compatible HTTP API (
/v1/chat/completions,/v1/responses,/v1/models) - 25+ RPC methods: chat, sessions, agents, channels, config, models, browser, cron, plan, backup, tools, etc.
- Config hot-reload, channel health monitoring
๐ฅ๏ธ Cross-Platform UI
- Next.js 15 Web Application
- Tauri 2.x Desktop App (macOS, Linux, Windows)
- Expo React Native Mobile App (iOS, Android)
- 17+ pages: Chat, Agents, Channels, Sessions, Usage, Cron, Plans, Skills, Nodes, Voice, Logs, Debug, Config, System, Settings, and more
๐ก๏ธ Security
- Command exec approval rules
- Workspace sandbox boundary
- SSRF prevention
- Plaintext secret scanning
- Configuration security audit
Quick Start
Requirements
- Python >= 3.10
- An LLM API key (OpenAI, Anthropic, Google Gemini, Ollama, or any OpenAI-compatible provider)
Install
# One-line install (macOS / Linux)
curl -fsSL https://raw.githubusercontent.com/chensaics/openclaw-py/master/scripts/install.sh | bash
# One-line install with local model support
curl -fsSL https://raw.githubusercontent.com/chensaics/openclaw-py/master/scripts/install.sh | bash -s -- --extras llamacpp
curl -fsSL https://raw.githubusercontent.com/chensaics/openclaw-py/master/scripts/install.sh | bash -s -- --extras mlx # Apple Silicon only
# Windows (PowerShell)
irm https://raw.githubusercontent.com/chensaics/openclaw-py/master/scripts/install.ps1 | iex
# From PyPI
pip install openclaw-py
# Or via pipx (isolated environment)
pipx install openclaw-py
# macOS via Homebrew
brew install chensaics/tap/pyclaw
# From source (development)
pip install -e ".[dev,ui]"
# Docker
docker run -it --rm -e OPENAI_API_KEY="sk-..." ghcr.io/chensaics/openclaw-py:latest pyclaw agent "Hello"
Optional Extras
| Extra | What it adds |
|---|---|
ui |
TypeScript client (Web/Desktop/Mobile) |
matrix |
Matrix channel (matrix-nio) |
whatsapp |
WhatsApp channel (neonize) |
voice |
Voice TTS (edge-tts) |
dev |
Testing + linting (pytest, ruff, mypy) |
all |
ui + matrix + voice + more |
First Run
# 1. Interactive setup
pyclaw setup --wizard
# 2. Chat with the agent
pyclaw agent "What is the weather in Tokyo?"
# 3. Start the gateway
pyclaw gateway
# 4. Launch the desktop UI
pyclaw ui
# 5. Or launch as a web app
pyclaw ui --web --port 18776
CLI Reference
Core Commands
| Command | Description |
|---|---|
pyclaw setup --wizard |
Interactive setup wizard |
pyclaw setup --non-interactive |
Headless setup (env vars) |
pyclaw agent <message> |
Run a single agent turn |
pyclaw gateway |
Start the gateway server |
pyclaw ui |
Launch desktop UI |
pyclaw ui --web |
Launch web UI |
pyclaw status [--deep] |
Show status / probe health |
pyclaw doctor |
Run diagnostics |
Configuration
| Command | Description |
|---|---|
pyclaw config list |
Show all config |
pyclaw config get <key> |
Get a config value |
pyclaw config set <key> <value> |
Set a config value |
Agents & Channels
| Command | Description |
|---|---|
pyclaw agents list |
List agents |
pyclaw agents add <name> --model <model> |
Add an agent |
pyclaw channels list |
List channels |
pyclaw channels status |
Connection status |
Auth & MCP
| Command | Description |
|---|---|
pyclaw auth login --provider <name> |
Add API key profile |
pyclaw auth status |
Show auth profiles |
pyclaw mcp status |
Show MCP servers and tools |
pyclaw mcp list-tools |
List available MCP tools |
Operations
| Command | Description |
|---|---|
pyclaw service install |
Install as system service |
pyclaw secrets audit |
Scan for plaintext secrets |
pyclaw security audit |
Security audit |
pyclaw logs [--follow] |
Tail runtime logs |
pyclaw backup export |
Export config and sessions |
Supported Channels
| Channel | Library | Type |
|---|---|---|
| Telegram | aiogram | Core |
| Discord | discord.py | Core |
| Slack | slack-bolt (Socket Mode) | Core |
| neonize (Baileys) | Core | |
| Signal | signal-cli JSON-RPC | Core |
| iMessage | imsg JSON-RPC | Core |
| Web | Built-in | Core |
| Feishu / Lark | Open Platform API | Extension |
| DingTalk | Stream Mode | Extension |
| QQ Bot | Extension | |
| MS Teams | Bot Framework | Extension |
| Matrix | matrix-nio | Extension |
| IRC | Native TCP/TLS | Extension |
| LINE | Messaging API | Extension |
| Twitch | IRC/TLS | Extension |
| Nostr | NIP-04 relay | Extension |
| BlueBubbles | REST webhook | Extension |
| Google Chat | OAuth webhook | Extension |
| Mattermost | REST + WebSocket | Extension |
| Nextcloud Talk | REST webhook | Extension |
| Synology Chat | Incoming webhook | Extension |
| Tlon / Urbit | HTTP API | Extension |
| Zalo | Official API | Extension |
| Voice Call | Twilio | Extension |
Supported LLM Providers
Core Providers
| Provider | Models |
|---|---|
| OpenAI | GPT-4o, GPT-4o-mini, o1, o3-mini |
| Anthropic | Claude Opus, Claude Sonnet, Claude Haiku |
| Google Gemini | Gemini 2.0 Flash, Gemini Pro |
| Ollama | Any locally hosted model |
OpenAI-Compatible Providers
| Provider | Notes |
|---|---|
| OpenRouter | Access to all models |
| Together AI | Open-source models |
| Groq | Fast inference |
| Fireworks AI | Fast inference |
| Perplexity | Search-augmented |
Chinese Providers
| Provider | Notes |
|---|---|
| DeepSeek | DeepSeek-V2 / DeepSeek-Coder |
| Moonshot / Kimi | 128k context |
| Zhipu / GLM | GLM-4 series |
| Qwen / DashScope | Qwen series |
| Volcengine | Doubao models |
| MiniMax | MiniMax models |
| Qianfan / ็พๅบฆ | ERNIE series |
MCP (Model Context Protocol)
Connect external tool servers via MCP. Config format is compatible with Claude Desktop and Cursor.
Add to ~/.pyclaw/pyclaw.json:
{
"tools": {
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]
},
"remote-api": {
"url": "https://example.com/mcp/",
"headers": { "Authorization": "Bearer xxx" }
}
}
}
}
Configuration
PyClaw stores its state in ~/.pyclaw/:
~/.pyclaw/
โโโ pyclaw.json # Main config (JSON5 with comments)
โโโ auth-profiles.json # API keys and OAuth credentials
โโโ credentials/ # Web provider credential files
โโโ sessions/ # Agent session transcripts (JSONL)
โโโ workspace/ # Workspace files (AGENTS.md, HEARTBEAT.md, etc.)
Example Config
{
"models": {
"providers": {
"openai": { "apiKey": "sk-..." },
"anthropic": { "apiKey": "sk-ant-..." }
}
},
"agents": {
"defaults": {
"model": "gpt-4o",
"provider": "openai"
}
},
"channels": {
"telegram": {
"enabled": true,
"token": "123456:ABC-DEF",
"allowFrom": ["your_user_id"]
}
}
}
Environment Variables
| Variable | Description |
|---|---|
OPENAI_API_KEY |
OpenAI API key |
ANTHROPIC_API_KEY |
Anthropic API key |
GOOGLE_API_KEY |
Google AI API key |
TELEGRAM_BOT_TOKEN |
Telegram bot token |
PYCLAW_GATEWAY_PORT |
Gateway port (default: 18777) |
Gateway API
WebSocket (port 18777)
Full bidirectional protocol for real-time agent interaction. 25+ RPC methods:
connect,health,statuschat.send,chat.abortsessions.list,sessions.getconfig.get,config.setagents.list,agents.bindingschannels.list,channels.statusmodels.list,models.probebrowser.*,cron.*,tools.*plan.list,plan.resumebackup.export,backup.import
HTTP (OpenAI-compatible)
| Endpoint | Description |
|---|---|
POST /v1/chat/completions |
Chat completions (streaming SSE) |
POST /v1/responses |
Responses API (streaming SSE) |
GET /v1/models |
List available models |
Docker
Docker Compose (recommended)
# Setup
docker compose run --rm pyclaw-cli setup --non-interactive --accept-risk
# Start gateway
docker compose up -d pyclaw-gateway
# View logs
docker compose logs -f pyclaw-gateway
Docker
# Build
docker build -t pyclaw .
# Run gateway
docker run -v ~/.pyclaw:/root/.pyclaw -p 18777:18777 pyclaw gateway
Architecture
openclaw-py/
โโโ src/pyclaw/ # Python backend (658 files)
โ โโโ agents/ # Agent runtime
โ โ โโโ runner.py # Core loop
โ โ โโโ stream.py # Multi-provider streaming
โ โ โโโ session.py # JSONL DAG session storage
โ โ โโโ planner.py # Task Plan/Step decomposition
โ โ โโโ providers/ # 25+ LLM provider adapters
โ โ โโโ skills/ # SKILL.md discovery
โ โ โโโ tools/ # 20+ built-in tools + MCP bridge
โ โ
โ โโโ gateway/ # Gateway server
โ โ โโโ server.py # FastAPI + WebSocket v3
โ โ โโโ openai_compat.py # /v1/chat/completions
โ โ โโโ methods/ # 25+ RPC handlers
โ โ
โ โโโ channels/ # 27 messaging channels
โ โ โโโ base.py # ChannelPlugin interface
โ โ โโโ telegram/ # aiogram
โ โ โโโ discord/ # discord.py
โ โ โโโ slack/ # slack-bolt
โ โ โโโ ... # + 24 more
โ โ
โ โโโ config/ # Configuration (Pydantic + JSON5)
โ โโโ memory/ # Memory (SQLite + LanceDB)
โ โโโ mcp/ # MCP client
โ โโโ security/ # Security modules
โ โโโ cron/ # APScheduler jobs
โ โโโ cli/ # Typer CLI (25+ commands)
โ
โโโ apps/ # TypeScript clients
โ โโโ web/ # Next.js 15 Web app
โ โโโ desktop/ # Tauri 2.x Desktop app
โ โโโ mobile/ # Expo React Native app
โ
โโโ packages/ # Shared packages
โ โโโ shared/ # Types, API client, Store
โ โโโ ui/ # UI components
โ
โโโ tests/ # 297 test files
โโโ docs/ # Documentation
Tech Stack
| Layer | Technology |
|---|---|
| Language | Python 3.10+ |
| Web framework | FastAPI + Uvicorn |
| WebSocket | websockets |
| HTTP client | httpx |
| CLI | Typer + Rich |
| Data validation | Pydantic v2 |
| Config format | JSON5 |
| Database | SQLite + FTS5 |
| Vector search | LanceDB |
| UI (Web) | Next.js 15 |
| UI (Desktop) | Tauri 2.x |
| UI (Mobile) | Expo React Native |
| Testing | pytest, pytest-asyncio |
| Linting | ruff |
| Type checking | mypy |
| Build | Hatch |
Project Stats
| Metric | Value |
|---|---|
| Source files | 658 Python files |
| Test files | 297 test files |
| Channels | 27 |
| LLM providers | 25+ |
| Built-in tools | 20+ |
| RPC methods | 25+ |
| CLI commands | 25+ groups |
| UI pages | 17+ |
Development
# Install with dev dependencies
pip install -e ".[dev,ui]"
# Run tests
pytest
# Run tests with coverage
pytest --cov=pyclaw --cov-report=term-missing
# Lint
ruff check src/ tests/
# Format
ruff format src/ tests/
# Type check
mypy src/pyclaw/
Contributing
Pull requests welcome. The project follows standard Python conventions:
- Code style enforced by
ruff - Type annotations enforced by
mypy - All new features should include tests
- Async-first architecture throughout
Acknowledgements
This project is inspired by OpenClaw (originally built with TypeScript). PyClaw is a ground-up rewrite using Python + TypeScript, with additional features.
Thanks to:
- OpenClaw โ original project inspiration
- Next.js โ React framework
- Tauri โ Desktop apps
- Expo โ Mobile apps
License
MIT โ Copyright (c) 2026 CHEN SAI
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openclaw_py-0.2.4.tar.gz.
File metadata
- Download URL: openclaw_py-0.2.4.tar.gz
- Upload date:
- Size: 2.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
effa37f6f8559665717837843220661434160870832443e6683334a3ffb8a3a6
|
|
| MD5 |
564a92225373ebea2e8e583aff091ec7
|
|
| BLAKE2b-256 |
9d4f3285e1849646a2b023d6de24d0e85b70a68e18def51b6c4a8050a3fcee16
|
Provenance
The following attestation bundles were made for openclaw_py-0.2.4.tar.gz:
Publisher:
release.yml on chensaics/openclaw-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openclaw_py-0.2.4.tar.gz -
Subject digest:
effa37f6f8559665717837843220661434160870832443e6683334a3ffb8a3a6 - Sigstore transparency entry: 1494858140
- Sigstore integration time:
-
Permalink:
chensaics/openclaw-py@9b1fa9b24a574daeff2da294a545303607f6ab14 -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/chensaics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9b1fa9b24a574daeff2da294a545303607f6ab14 -
Trigger Event:
push
-
Statement type:
File details
Details for the file openclaw_py-0.2.4-py3-none-any.whl.
File metadata
- Download URL: openclaw_py-0.2.4-py3-none-any.whl
- Upload date:
- Size: 1.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecaafad70412d260a2e2e9fcf3d56b404624c6301c133af0e684286f65cbd884
|
|
| MD5 |
ac8567314001f02e47b701e08162f506
|
|
| BLAKE2b-256 |
9b545d158327f06bbd3a7e6a770b5f59a6133f79d9397d80833981aa901e9020
|
Provenance
The following attestation bundles were made for openclaw_py-0.2.4-py3-none-any.whl:
Publisher:
release.yml on chensaics/openclaw-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openclaw_py-0.2.4-py3-none-any.whl -
Subject digest:
ecaafad70412d260a2e2e9fcf3d56b404624c6301c133af0e684286f65cbd884 - Sigstore transparency entry: 1494858496
- Sigstore integration time:
-
Permalink:
chensaics/openclaw-py@9b1fa9b24a574daeff2da294a545303607f6ab14 -
Branch / Tag:
refs/tags/v0.2.4 - Owner: https://github.com/chensaics
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@9b1fa9b24a574daeff2da294a545303607f6ab14 -
Trigger Event:
push
-
Statement type: