Skip to main content

Multi-channel AI gateway with extensible messaging integrations

Project description

PyClaw

PyPI version Python License: MIT Tests

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
WhatsApp 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 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, status
  • chat.send, chat.abort
  • sessions.list, sessions.get
  • config.get, config.set
  • agents.list, agents.bindings
  • channels.list, channels.status
  • models.list, models.probe
  • browser.*, cron.*, tools.*
  • plan.list, plan.resume
  • backup.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


ไธญๆ–‡็‰ˆ README

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

openclaw_py-0.2.4.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openclaw_py-0.2.4-py3-none-any.whl (1.3 MB view details)

Uploaded Python 3

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

Hashes for openclaw_py-0.2.4.tar.gz
Algorithm Hash digest
SHA256 effa37f6f8559665717837843220661434160870832443e6683334a3ffb8a3a6
MD5 564a92225373ebea2e8e583aff091ec7
BLAKE2b-256 9d4f3285e1849646a2b023d6de24d0e85b70a68e18def51b6c4a8050a3fcee16

See more details on using hashes here.

Provenance

The following attestation bundles were made for openclaw_py-0.2.4.tar.gz:

Publisher: release.yml on chensaics/openclaw-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for openclaw_py-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ecaafad70412d260a2e2e9fcf3d56b404624c6301c133af0e684286f65cbd884
MD5 ac8567314001f02e47b701e08162f506
BLAKE2b-256 9b545d158327f06bbd3a7e6a770b5f59a6133f79d9397d80833981aa901e9020

See more details on using hashes here.

Provenance

The following attestation bundles were made for openclaw_py-0.2.4-py3-none-any.whl:

Publisher: release.yml on chensaics/openclaw-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page