Skip to main content

clikernel

clikernel gives an LLM agent a persistent Python workbench built from two processes. A jupygate server runs all the time and hosts real Jupyter kernels (ipymini by default); kernels live there and persist until explicitly stopped. clikernel itself starts and stops with each conversation: a small translator the MCP host launches, speaking MCP to the model and the Jupyter kernels API to the gateway. Outputs come back as concise text — a bare 42 for a single result, tagged sections for several, tracebacks ANSI-stripped and capped.

Because kernels outlive conversations, an agent can connect back to yesterday’s kernel (or the user’s live solveit kernel) and find its state intact — and because nothing is ever stopped implicitly, the only way a kernel dies is an explicit stop_kernel. Creating a kernel runs the user’s startup.py and installs their inspectors.py cell-checking rules, delivered as source so remote kernels get the same setup as local ones.

Install

pip install clikernel

Plus the resident side: jupygate and a kernel (ipymini by default). Start the gateway (and keep it running, e.g. via launchd/systemd):

jupygate --port 8787

Use with an MCP host

Register the stdio server with your MCP host, e.g. for Claude Code:

claude mcp add clikernel -- clikernel-mcp

The tools mirror jupygate’s kernel API plus one composite: connect (create a fresh kernel — running startup.py and installing inspectors — or attach to an existing one by id), execute (run code, get concise text), list_kernels, stop_kernel, restart, and interrupt. Nothing happens until the model calls connect, and nothing is ever stopped except by stop_kernel — a later conversation reattaches to a kernel by id and continues where the last one stopped. $CLIKERNEL_HOST overrides the default gateway (http://127.0.0.1:8787).

Configuration

Three optional files in $XDG_CONFIG_HOME/clikernel/ (usually ~/.config/clikernel/):

  • startup.py — run in every kernel clikernel creates, with __file__ bound to its path; its output returns as part of the connect reply.
  • inspectors.py — cell inspectors installed after startup. The file may define inspect and/or a list inspectors; each is called once per cell before it runs (1-arg: the cell’s AST; 2-arg: AST and raw source). Return a string to print a note before the cell’s output, raise RuleBlock (provided in the namespace) to block the cell; any other exception warns and the cell runs. See examples/inspectors.py.
  • gateways.toml — named remote gateways, so tokens never appear in tool arguments:
[gateways.solveit]
url = "https://solveit.example.com/gate"
token_env = "SOLVEIT_TOKEN"

The stream protocol

Run clikernel as a plain CLI process and the same client speaks a delimiter-framed stdin/stdout protocol for token-reading clients: no echo, a cheap . acknowledgement per request, responses ended by a per-process random delimiter, multiline cells framed by -- and the delimiter. The full recipe is announced in the process’s own startup banner. Run bare it creates a kernel and stops it on exit; --kernel <id> attaches to an existing kernel and leaves it as found.

Download files

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

Source Distribution

clikernel-0.2.0.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

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

clikernel-0.2.0-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file clikernel-0.2.0.tar.gz.

File metadata

  • Download URL: clikernel-0.2.0.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for clikernel-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b99d3fa8ca710e3eb3e614612902ba88dbfe5dfdb5c31bc235bda158c12f1630
MD5 718743e39e03a100f6c01d75174eec84
BLAKE2b-256 2f09238167ea4f48e16f70e8744a99bf53170fadfbf9f1a3938d481249a01208

See more details on using hashes here.

File details

Details for the file clikernel-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: clikernel-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.2

File hashes

Hashes for clikernel-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8048558137e4f3067432c4862e3dc51dd728cd97c56518ff362a0731714d7756
MD5 dc148f7691f4a981f5364ae95e2a947c
BLAKE2b-256 f8a7223aacc97a0d397c6dfa142616f0bd4e85e4742d0e5bcf3499eb78475908

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