Python Server API for Meshagent
Actively maintained. Last release 6 days ago. A safe choice.
pip install meshagent-apiMeshagent
MeshAgent API
The meshagent.api is the foundation that all other packages build on. It includes foundational protocols, JWT authentication, room management, document sync, and more.
JWT Authentication
MeshAgent uses JSON Web Tokens (JWTs) to authenticate participants. A token encodes who you are (participant name) and what you’re allowed to access (project ID, room name, role). The token is signed, so the server can verify it without storing any state.
from meshagent.api import ParticipantToken
token = ParticipantToken(
name="alice",
project_id="your-project-id",
api_key_id="your-api-key-id",
)
token.add_room_grant(room_name="my-room", role="user")
jwt = token.to_jwt(token="your-api-secret")
WebSocket Protocol
A WebSocket keeps a two-way connection open between your Python code and the Meshagent server. This allows instant messaging, file transfers, and document updates. WebSocketClientProtocol manages the underlying connection:
from meshagent.api import WebSocketClientProtocol
protocol = WebSocketClientProtocol(url=room_url, token=jwt)
async with protocol:
# communication occurs over this protocol
Messages are encoded and decoded using a Protocol layer that is transport-agnostic.
RoomClient
RoomClient is the main entry point for interacting with a room. Once you pass in the protocol, the room becomes ready and you gain access to specialized sub-clients:
messaging: send or broadcast text/files.storage: open or write files in the room.sync: collaborate on structured documents.agents: manage agent instances.queues,datasets,livekit, and more.
Document Runtime and Schemas
SyncClient and the document runtime allow multiple participants to edit structured documents (defined by a MeshSchema) with real-time updates propagated via WebSocket messages.
WebhookServer
WebhookServer can run in your own service to receive signed room.call handoffs from MeshAgent.
Meshagent
Separate from rooms, Meshagent is a REST-based client for managing projects, API keys, and secrets. It is useful for administrative tasks.