Skip to main content

Revia MCP Client

Python client for the Revia MCP bridge. Connect your Python code to WhatsApp, Telegram, Slack, and Gmail through a single async client. Also supports bidirectional chat with coding agents connected to your Revia instance.

Contents

Install

pip install revia-mcp

Quickstart

import asyncio
from revia_mcp import ReviaMCPClient

async def main():
    async with ReviaMCPClient(
        "https://revia.devshub.ai/api/v1/mcp",
        token="rvagent_YOUR_TOKEN_HERE",
    ) as revia:

        # Health check
        pong = await revia.ping()
        print(pong)  # {"status": "pong", "user_id": "...", ...}

        # List channels
        channels = await revia.channels_list()
        for ch in channels["channels"]:
            print(f"{ch['platform']}: {'connected' if ch['reachable'] else 'offline'}")

        # Send a WhatsApp message
        await revia.messages_send(
            "whatsapp:974XXXXXXXX@s.whatsapp.net",
            "Hello from Python!",
        )

        # Read recent messages
        msgs = await revia.messages_read("whatsapp:974XXXXXXXX@s.whatsapp.net", limit=10)
        for m in msgs["messages"]:
            print(f"[{m['timestamp']}] {m.get('sender')}: {m.get('content')}")

        # Send an email
        await revia.email_send(
            to="client@example.com",
            subject="Meeting follow-up",
            body="Thanks for your time today!",
        )

asyncio.run(main())

Real-time events via WebSocket

async def stream_events():
    async with ReviaMCPClient(
        "https://revia.devshub.ai/api/v1/mcp",
        token="rvagent_YOUR_TOKEN_HERE",
    ) as revia:

        async for event in revia.events_ws():
            print(f"[{event['platform']}] {event['from']}: {event['content']}")

The WebSocket reconnects automatically on disconnect with exponential backoff. Pass name="MyBot" to register with a human-readable name so Revia can discover and chat with your agent.

Chat with connected coding agents

Revia can discover and chat with coding agents that are connected via WebSocket. Use agents_list to see who's online, then agent_chat to send a natural language message and get a response:

async def chat_with_agents():
    async with ReviaMCPClient(
        "https://revia.devshub.ai/api/v1/mcp",
        token="rvagent_YOUR_TOKEN_HERE",
    ) as revia:

        # See who's connected
        agents = await revia.agents_list()
        for a in agents["agents"]:
            print(f"  {a['name']} ({a['agent_id']})")

        # Send a natural language message and get a response
        reply = await revia.agent_chat(
            agent_id="agent_abc123",
            message="What's the status of the deployment?",
        )
        print(reply["response"])

The call blocks for up to 60 seconds waiting for the agent's response. Pass timeout_s to adjust.

WebSocket client (agent-side)

If you're building a coding agent that Revia should be able to chat with, use ReviaWebSocket directly. It handles auth, registration, event streaming, and chat responses:

import asyncio
from revia_mcp.ws import ReviaWebSocket

async def handle_chat(chat_id: str, message: str) -> str:
    """Revia sent us a message — respond in natural language."""
    if "deployment" in message.lower():
        return "Deployment is green — all pods healthy, last deploy 5 minutes ago."
    if "errors" in message.lower():
        return "No errors in the last hour. Error rate is 0.02%."
    return f"I received: {message}"

async def main():
    ws = ReviaWebSocket(
        "wss://revia.devshub.ai/api/v1/mcp/ws",
        token="rvagent_YOUR_TOKEN_HERE",
        name="My CodeSync Agent",
        on_chat=handle_chat,
    )

    async for event in ws:
        print(f"[{event.get('platform', 'system')}] {event.get('type')}: {event.get('content', '')}")

asyncio.run(main())

If you prefer manual control over chat responses, omit on_chat and handle chat events yourself:

async for event in ws:
    if event.get("type") == "chat":
        chat_id = event["chat_id"]
        message = event["message"]
        # ... think about it ...
        await ws.send_chat_response(chat_id, "Here's my response.")
    else:
        print(f"Event: {event}")

ReviaWebSocket constructor:

Param Type Default Description
ws_url str required WebSocket URL, e.g. wss://revia.devshub.ai/api/v1/mcp/ws
token str required Agent token (rvagent_...)
name str "Python Agent" Human-readable name shown in Revia's agents_list
on_chat Callable None Async callback (chat_id, message) -> str for auto-responding to Revia
reconnect bool True Automatically reconnect on disconnect with exponential backoff

Properties and methods:

Member Type Description
agent_id str | None The agent ID assigned by the server after registration
send_chat_response(chat_id, message) async Manually send a response to a chat message from Revia

API Reference

Health

Method MCP Tool Description
ping() ping Health check — returns user scope and server time

Channels & Contacts

Method MCP Tool Description
channels_list() channels_list List channels and connectivity
contacts_list(platform?, query?, limit?) contacts_list List contacts
conversations_list(platform?, limit?) conversations_list List conversations
conversation_get(target) conversation_get Get one conversation

Messages

Method MCP Tool Description
messages_read(target, limit?, before?, after?) messages_read Read message history
messages_send(target, message, reply_to?) messages_send Send a message
attachments_fetch(target, message_id?, limit?) attachments_fetch Fetch attachment metadata

Email

Method MCP Tool Description
email_list(query?, max_results?) email_list List Gmail messages
email_search(query, max_results?) email_search Search Gmail
email_read(email_id) email_read Read full email
email_send(to, subject, body, cc?, draft?) email_send Send or draft email

Revia AI

Method MCP Tool Description
revia_ask(prompt, contact?, use_context?) revia_ask Ask Revia (read-only)
conversation_claim(target, ttl_s?) conversation_claim Mute auto-responder

Events

Method MCP Tool Description
events_poll(after_cursor?, limit?) events_poll Poll for events
events_wait(after_cursor?, timeout_ms?, limit?) events_wait Long-poll for events
events_subscribe(callback_url, events?, secret?) events_subscribe Register webhook
events_unsubscribe(subscription_id) events_unsubscribe Remove webhook
events_ws(name?, on_chat?) WebSocket event stream (recommended)

Agents

Method MCP Tool Description
agents_list() agents_list List connected coding agents
agent_chat(agent_id, message, timeout_s?) agent_chat Chat with a connected agent

Token

Generate an agent token in the Revia dashboard: Settings → Coding Agent (MCP) → Generate Token. Tokens use the rvagent_ prefix and are shown only once.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

revia_mcp-0.1.2.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

revia_mcp-0.1.2-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file revia_mcp-0.1.2.tar.gz.

File metadata

  • Download URL: revia_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.4

File hashes

Hashes for revia_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6c728bb7481aa6a02ce9075340a1dbf022f8ef0c07efbafdcc2279d90109e6fa
MD5 7797517601921140fe3f87b015be2e7f
BLAKE2b-256 59b2dc3f26363c31b93a54348501728164e365344335427805ff321112af14a5

See more details on using hashes here.

File details

Details for the file revia_mcp-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: revia_mcp-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.4

File hashes

Hashes for revia_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1e70173308941a1b7fa5bfca384c51c7eab295de005347487aef2d5fe51b201f
MD5 70172a2286e5816e8c5df21c3fff203d
BLAKE2b-256 d6662d166509fc8ac53f01f4a82d11f82e8012aab604c6702628544948364b8d

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.3

2 files

This release

0.1.2 This release

2 files

0.1.1

1 file

0.1.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page