python-lsp-jsonrpc is a Python 3.8+ server implementation of the JSON RPC 2.0 protocol. This library was extracted from the Python LSP Server project to provide a standalone JSON-RPC core. It is currently at version 1.1.2 and receives updates as needed for bug fixes and minor feature enhancements.
pip install -U python-lsp-jsonrpcVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a basic JSON-RPC server handling two methods: `sum` and `notify_exit`. The server communicates over standard I/O, expecting JSON-RPC requests on stdin and sending responses to stdout. To run, save as `server.py` and execute `python server.py`. You can then send JSON-RPC requests via a client (e.g., using `echo '{"jsonrpc": "2.0", "method": "sum", "params": {"a": 1, "b": 2}, "id": 1}' | python server.py`).
Upgrade to Python 3.8 or newer, or pin `python-lsp-jsonrpc<1.1.0`.
Update package installations (`pip install python-lsp-jsonrpc`) and all import statements from `python_jsonrpc_server` to `jsonrpc`.
Ensure all import statements use `from jsonrpc.server import ...` or `from jsonrpc.manager import ...`.
If `ujson` is desired, ensure it is installed (`pip install ujson`). Otherwise, no specific action is needed as the standard `json` library is used by default.