Skip to main content

Python Server API for Meshagent

Project description

Meshagent

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, database, 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 events (HTTP webhooks) from MeshAgent—such as room lifecycle events (e.g., room started/ended)—allowing you to trigger custom logic.

Meshagent

Separate from rooms, Meshagent is a REST-based client for managing projects, API keys, and secrets. It is useful for administrative tasks.

ServiceHost

ServiceHost allows you to expose agents or tools as an HTTP service. The MeshAgent Server or CLI can invoke the service via webhook calls. The Servicehost spins up the agent or tool, connects it to the specified room, and manages its lifecycle until the call completes or is dismissed. This is how examples like the ChatBot or VoiceBot can be run locally and also enables you to deploy an agent as a MeshAgent Service using the same applicable service path once your agent or tool is ready.

When a call to the agent or tool arrives through a webhook, the ServiceHost spawns that agent or tool and connects it to the requested room via the RoomClient and WebSocketClientProtocol. The ServiceHost starts an HTTP servier and registers each path so that multiple agents or toolkits can be hosted.

from meshagent.api.services import ServiceHost

service = ServiceHost() # port defaults to an available port if not assigned

@service.path("/chat")
class SimpleChatbot(ChatBot):
    ...
print(f"running on port {service.port}")
asyncio.run(service.run())

Learn more about MeshAgent on our website or check out the docs for additional examples!

Website: www.meshagent.com

Documentation: docs.meshagent.com


Project details


Release history Release notifications | RSS feed

This version

0.9.0

Download files

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

Source Distribution

meshagent_api-0.9.0.tar.gz (94.2 kB view details)

Uploaded Source

Built Distribution

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

meshagent_api-0.9.0-py3-none-any.whl (102.1 kB view details)

Uploaded Python 3

File details

Details for the file meshagent_api-0.9.0.tar.gz.

File metadata

  • Download URL: meshagent_api-0.9.0.tar.gz
  • Upload date:
  • Size: 94.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for meshagent_api-0.9.0.tar.gz
Algorithm Hash digest
SHA256 afc0300bf4d71bf03e1f68339344fee2b0c950edd73d6f42d178ff71de7db175
MD5 f9b3132ac39d8880d94df3a86f17cf73
BLAKE2b-256 08d46a8dc7e987ac78ae66af613dc23a2c2dc1fca38634246d1e946c6b13c3ac

See more details on using hashes here.

File details

Details for the file meshagent_api-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: meshagent_api-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 102.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for meshagent_api-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a9c6a7d1e1a9f974f9eb102663e944165e6b3718193977e68cac1c7741f53dd
MD5 84048b6dc307b6ec5672e3b39c7d180d
BLAKE2b-256 4328699f8d802a49b2a66c3ff2918f314eb68d3e4d811370311504cda50c8eb8

See more details on using hashes here.

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