Skip to main content

CLI tool for LLM agents to operate Jupyter Lab servers

Project description

jupyter-jcli

CLI tool for LLM agents to operate Jupyter Lab servers.

j-cli enables AI agents (and humans) to remotely control Jupyter servers — execute code in kernels, manage sessions, and write outputs back to notebooks, all from the command line.

Installation

# from source
uv sync

Requires Python 3.10+.

Quick Start

# set connection (or pass via -s / -t flags)
export JCLI_JUPYTER_SERVER_URL=http://localhost:8888
export JCLI_JUPYTER_SERVER_TOKEN=your-token

# check connectivity
j-cli healthcheck

# create a session and execute code
j-cli session create --kernel python3 --name my-session
j-cli exec <session_id> --code "print('hello world')"

Commands

Global Options

Flag Description
-s, --server-url Jupyter server URL (env: JCLI_JUPYTER_SERVER_URL, default: http://localhost:8888)
-t, --token Auth token (env: JCLI_JUPYTER_SERVER_TOKEN)
-j, --json Output as JSON for programmatic use
--version Show version

healthcheck

Check server connectivity and running kernel count.

j-cli healthcheck

kernelspec list

List available kernel specifications.

j-cli kernelspec list

session

j-cli session create --kernel python3 --name my-session
j-cli session list
j-cli session kill <session_id>

kernel

j-cli kernel interrupt <session_id>
j-cli kernel restart <session_id>

exec

Execute code in a kernel session. Supports inline code, py:percent files, and Jupyter notebooks.

# inline code
j-cli exec <session_id> --code "import pandas as pd; df = pd.read_csv('data.csv'); df.head()"

# execute from py:percent file
j-cli exec <session_id> --file analysis.py

# execute specific cells from a notebook
j-cli exec <session_id> --file notebook.ipynb --cell 0:3

# execute a single cell
j-cli exec <session_id> --file notebook.ipynb --cell 5

Cell spec formats (0-indexed):

Spec Meaning
3 Cell 3 only
3:7 Cells 3, 4, 5, 6
3: Cell 3 to end
:5 Cells 0 through 4

Notebook writeback: When executing from a file, outputs are automatically written back to the paired .ipynb file. For analysis.py, j-cli looks for analysis.ipynb in the same directory.

Py:Percent Format

j-cli supports the py:percent format — plain Python files with cell markers:

# ---
# jupyter:
#   kernelspec:
#     name: python3
# ---

# %%
import numpy as np

# %%
x = np.random.randn(100)
print(x.mean())

Development

# install with test dependencies
uv sync --extra test

# run tests (requires a real Jupyter server, started automatically by fixtures)
uv run pytest -v

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyter_jcli-0.1.0.tar.gz (175.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyter_jcli-0.1.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

Details for the file jupyter_jcli-0.1.0.tar.gz.

File metadata

  • Download URL: jupyter_jcli-0.1.0.tar.gz
  • Upload date:
  • Size: 175.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for jupyter_jcli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 90a028c02e63caec67410597a6bb2dc50a87ecd5ff13aa964986ad242e6ee884
MD5 1642e71926d8bc5b6779c56b2ec965f8
BLAKE2b-256 49b9fd92bd0c2f38a9612ea57612ac291b1f1c90bb287cc25b2b56fd44f9bddd

See more details on using hashes here.

File details

Details for the file jupyter_jcli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: jupyter_jcli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for jupyter_jcli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 311fbc122c34baac0ea4d8003bf35d7a19d605b4a99165c7d244e9b694bb9d79
MD5 e2b989a8061a6b678cf79d512a8e36b5
BLAKE2b-256 47a0341955d44b919c88071f42dacb918abca1c3187ee3e144d09592c770522f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page