Skip to content

What is jrpc-core?

jrpc-core is a lightweight Python library that implements the JSON-RPC 2.0 specification with two core layers:

LayerModulePurpose
Messagesjrpc_core.messagesPydantic models for requests, responses, notifications, and errors
Dispatcherjrpc_core.dispatcherRegistry-based routing of incoming messages to handler callables

Design Principles

  • Type-safe — every model is a Pydantic BaseModel with explicit field types and validators.
  • Functional — error handling uses Result and Option from pyfplib instead of exceptions.
  • Lightweight — only depends on pydantic and pyfplib, 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


JsonRpcResponse

Next Steps