{"id":3780,"library":"python-lsp-jsonrpc","title":"Python LSP JSON-RPC","description":"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.","status":"active","version":"1.1.2","language":"en","source_language":"en","source_url":"https://github.com/python-lsp/python-lsp-jsonrpc","tags":["json-rpc","lsp","server","protocol"],"install":[{"cmd":"pip install -U python-lsp-jsonrpc","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Optional dependency for faster JSON serialization/deserialization. The library is compatible with both 'ujson' and the standard 'json' library.","package":"ujson","optional":true}],"imports":[{"note":"The PyPI package `python-lsp-jsonrpc` is imported via the top-level module `jsonrpc`.","wrong":"from python_lsp_jsonrpc.server import JSONRPCServer","symbol":"JSONRPCServer","correct":"from jsonrpc.server import JSONRPCServer"},{"note":"The PyPI package `python-lsp-jsonrpc` is imported via the top-level module `jsonrpc`.","wrong":"from python_lsp_jsonrpc.manager import JSONRPCMethodManager","symbol":"JSONRPCMethodManager","correct":"from jsonrpc.manager import JSONRPCMethodManager"}],"quickstart":{"code":"import logging\nimport sys\n\nfrom jsonrpc.manager import JSONRPCMethodManager\nfrom jsonrpc.server import JSONRPCServer\n\nlogger = logging.getLogger(__name__)\nlogger.setLevel(logging.INFO)\nhandler = logging.StreamHandler(sys.stderr)\nhandler.setFormatter(logging.Formatter('%(levelname)s: %(message)s'))\nlogger.addHandler(handler)\n\n\nclass ExampleManager(JSONRPCMethodManager):\n    def sum(self, a, b):\n        logger.info(f\"Received sum request for {a}, {b}\")\n        return a + b\n\n    def notify_exit(self):\n        logger.info(\"Received exit notification.\")\n        sys.exit(0)\n\n\ndef main():\n    manager = ExampleManager()\n    server = JSONRPCServer(manager)\n    logger.info(\"Starting JSON RPC server (STDIO). Send JSON RPC requests via stdin.\")\n    server.serve_forever()\n\n\nif __name__ == '__main__':\n    main()","lang":"python","description":"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`)."},"warnings":[{"fix":"Upgrade to Python 3.8 or newer, or pin `python-lsp-jsonrpc<1.1.0`.","message":"As of version 1.1.0, support for Python 3.7 and 3.6 has been dropped. Users on these Python versions must either upgrade their Python environment or pin to a previous version of `python-lsp-jsonrpc`.","severity":"breaking","affected_versions":">=1.1.0"},{"fix":"Update package installations (`pip install python-lsp-jsonrpc`) and all import statements from `python_jsonrpc_server` to `jsonrpc`.","message":"Version 1.0.0 introduced a package rename. This library is a fork of Palantir's `python-jsonrpc-server` and has been renamed to `python-lsp-jsonrpc`. Code referencing the old package name will break.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure all import statements use `from jsonrpc.server import ...` or `from jsonrpc.manager import ...`.","message":"The PyPI package name is `python-lsp-jsonrpc`, but the top-level Python import module is `jsonrpc`. Attempting to import from `python_lsp_jsonrpc` will result in an `ImportError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"While `python-lsp-jsonrpc` is compatible with both `ujson` (for performance) and Python's built-in `json` library, ensure consistent usage if relying on specific `ujson` features or performance characteristics, as tests have specifically addressed compatibility.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}