jupyter-server-connections: A Jupyter server extension to share kernel connection files
Each kernel creates a connections file formatted as JSON that contains the
ports used for creating the various ZeroMQ sockets to communicate with the
kernel. This file is located in the JUPYTER_RUNTIME_DIR directory, e.g.,
~/.local/share/jupyter/data/runtime, with a kernel-<id>.json file name
structure, where <id> is replaced with the UUID of the kernel. The UUID is
automatically generated when using the POST /kernels endpoint of the
jupyter_server REST API.
The POST /kernels endpoint returns only the Location header to the newly
created kernel. The GET /kernels endpoint returns a list of kernels with some
information about the kernels, like the id, name, execution_count, and
last_activity. The GET /kernels/{id} endpoint of the jupyter_server REST API
returns the same information for a specific kernel. However, the connection file
contents are not supplied by these endpoints. So, a client using the
jupyter_server REST API can create, start, stop, and remove kernels but there is
no way to obtain the connection file contents for the kernels from the
jupyter_server REST API, which is needed to establish a connection to the ZeroMQ
sockets to connect and execute code on the kernels.
I have not found a solution to this. There is probably another extension or tool I am supposed to use (Gateway?), but this seems like something that should be provided with the REST API. This extension adds endpoints to the jupyter_server REST API to get connection files for kernels. This eliminates the need to use alternative methods to communicate the connection files to clients, such as Network File System (NFS).
Installation
-
Install the
jupyter-server-connectionspackage usingpipand the public package repository (PyPI).pip install jupyter-server-connections
Contributing
-
Clone this repository.
git clone https://github.com/Theia-Scientific/jupyter-server-connections.git && cd jupyter-server-connections
-
Create a virtual environment.
python3 -m venv .venv
-
Activate the virtual environment.
source .venv/bin/activate
or if direnv is installed:
cp .envrc.example .envrc
followed by:
direnv allow -
Install the package, utility, the required dependencies, and the development dependencies.
python3 -m pip install -e ".[dev]"
-
Create a local branch.
git checkout -b feature-awesome-new-feature
-
Modify the code.
-
Manually test features by starting the Jupyter server.
jupyter server --ServerApp.jpserver_extensions="{'jupyter_server_connections': True}"
Information will be printed to the console, e.g.,
[I 2025-12-13 13:35:01.795 ServerApp] jupyter_server_connections | extension was successfully linked. [I 2025-12-13 13:35:01.797 ServerApp] jupyter_server_terminals | extension was successfully linked. [I 2025-12-13 13:35:01.810 ConnectionsExtensionApp] Initialize settings [I 2025-12-13 13:35:01.810 ServerApp] jupyter_server_connections | extension was successfully loaded. [I 2025-12-13 13:35:01.810 ServerApp] jupyter_server_terminals | extension was successfully loaded. [I 2025-12-13 13:35:01.812 ServerApp] Serving notebooks from local directory: /home/cfield/Code/jupyter_server_connections [I 2025-12-13 13:35:01.812 ServerApp] Jupyter Server 2.17.0 is running at: [I 2025-12-13 13:35:01.812 ServerApp] http://localhost:8888/?token=<TOKEN> [I 2025-12-13 13:35:01.812 ServerApp] http://127.0.0.1:8888/?token=<TOKEN> [I 2025-12-13 13:35:01.812 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 2025-12-13 13:35:01.814 ServerApp] To access the server, open this file in a browser: file:///home/cfield/.local/share/jupyter/runtime/jpserver-<ID>-open.html Or copy and paste one of these URLs: http://localhost:8888/?token=<TOKEN> http://127.0.0.1:8888/?token=<TOKEN>
Copy the
<TOKEN>value and save for later. It will be needed for executing curl commands.Start a new terminal while leaving the previous terminal running, and create a shell variable for the
<TOKEN>value copied earlier from the previous terminal still running thejupyter serverapplication.export TOKEN=<TOKEN>
Check if any kernels already exist.
curl "http://localhost:8888/api/kernels?token=${TOKEN}" []
Create a new kernel.
curl -X POST -d '{"name":"python3"}' "http://localhost:8888/api/kernels?token=${TOKEN}" [{"id": "b2042229-7c6c-416b-9ae2-97ae16017cf5", "name": "python3", "last_activity": "2025-12-13T18:11:28.731478Z", "execution_state": "starting", "connections": 0}]
Copy the value for the
idfield and export to a shell variable.export ID=b2042229-7c6c-416b-9ae2-97ae16017cf5
Try the endpoints from this extension.
$ curl "http://localhost:8888/api/kernels/${ID}/connection?token=${TOKEN}" {"shell_port": 42679, "iopub_port": 35375, "stdin_port": 58141, "control_port": 48063, "hb_port": 55541, "ip": "127.0.0.1", "key": "6a553a72-a32a994e0a70400ae68a6922", "transport": "tcp", "signature_scheme": "hmac-sha256", "kernel_name": "python3"}
When done testing, close the current terminal that was used to invoke
curlcommands. Change back to the terminal running thejupyter servercommand. PressCTRL+Cand enterYto stop the process. -
Run automated tests locally on developer machine, and add tests to maintain 100% coverage as needed.
pytest --color=yes --cov=jupyter_server_connections --cov-report=term-missing
-
Run linter for style conformity and minimize potential bugs.
flake8 . --exclude .venv --count --max-complexity=10 --max-line-length=127 --statistics
-
Commit changes to your local branch.
git add -A && git commit -m "Add new feature"
-
Push your local branch to GitHub to create a Pull Request (PR).
git push origin feature-awesome-new-feature
-
Create a Pull Request (PR) in GitHub.
-
Wait for CI to complete.
-
Add comment to PR that it is ready to review.
License
This project is licensed under either the 3-Clause BSD license See the LICENSE file for information about licensing and copyright.
Metadata
Release files for jupyter-server-connections 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jupyter_server_connections-0.1.2.tar.gz | 7.8 kB | With provenance | Details for jupyter_server_connections-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jupyter_server_connections-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for jupyter_server_connections-0.1.2-py3-none-any.whl |
Total release size: 15.4 kB
Release files / jupyter_server_connections-0.1.2.tar.gz
| Download URL | jupyter_server_connections-0.1.2.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c6000a5709e5017cd161b9ceabe8ef05be27f0505596d6e9e88c94420f2433c
|
|
BLAKE2b-256 checksum How to use checksums |
930cb9f0648f84a8fdef9028b1042438f4e596cb6c60496d03b6739dd14e1089
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 24, 2026.
Transparency logRelease files / jupyter_server_connections-0.1.2-py3-none-any.whl
| Download URL | jupyter_server_connections-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
453299b27f5aa519bf07ad09a5d78458bcfb3962fd4182c7de7f0216b672aa94
|
|
BLAKE2b-256 checksum How to use checksums |
069af884238d3994112b6b9309de4708823bdc352c585aaf0af321c9282b94a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 24, 2026.
Transparency logSecurity for jupyter-server-connections 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for jupyter_server_connections-0.1.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.