What is jrpc-core?
jrpc-core is a lightweight Python library that implements the JSON-RPC 2.0 specification with two core layers:
| Layer | Module | Purpose |
|---|---|---|
| Messages | jrpc_core.messages | Pydantic models for requests, responses, notifications, and errors |
| Dispatcher | jrpc_core.dispatcher | Registry-based routing of incoming messages to handler callables |
Design Principles
- Type-safe — every model is a Pydantic
BaseModelwith explicit field types and validators. - Functional — error handling uses
ResultandOptionfrom pyfplib instead of exceptions. - Lightweight — only depends on
pydanticandpyfplib, no async runtime required. - Serialisable — round-trips cleanly between Python objects and JSON strings.
Architecture
Incoming JSON string
│
▼
try_parse()
│
┌────┴────┐
│ │
Request Notification
│ │
▼ ▼
JsonRpcDispatcher.__call__()
│
├──► handler registry lookup
│
▼
JsonRpcResponseNext Steps
- Getting Started — install and run your first request
- Messages API — full reference for all message models
- Dispatcher API — full reference for routing and handler registration