Skip to main content

clikernel

clikernel gives an LLM agent a persistent Python or Luau session. Imports, variables, and results remain available between tool calls. An agent can create a kernel or attach to an existing one, including a user’s live solveit kernel, on a local or named remote gateway.

rustygate hosts the Jupyter kernels and provides their MCP tools. clikernel is the conversation-side router: the MCP host launches it over stdio, and it forwards requests to gateways over HTTP. It selects gateways from gateways.toml, supplies startup.py and inspectors.py to Python kernels it creates, and starts a private local gateway when needed. The default kernel is ipymini.

Kernel ownership determines what happens when the conversation ends:

  • A session closes kernels it created with autoclose, including the automatic kernel used by bare py or lua and kernels created with create’s default settings.
  • Attaching with use_kernel does not make that session responsible for closing the kernel.
  • A kernel created with autoclose=false on a resident gateway can outlive the conversation. A later conversation can attach and continue using its state.
  • A private child gateway ends with its conversation. Use a resident gateway for kernels that need to survive across conversations.

Install

pip install clikernel

This installs rustygate and ipymini. No service setup is required for a conversation-local kernel: clikernel starts a private gateway if it cannot find one. To retain kernels across conversations, run a resident gateway, for example through launchd or systemd:

rustygate --port 8787

Use with an MCP host

Register the stdio server with your MCP host. For Claude Code:

claude mcp add clikernel -- clikernel-mcp

Use py(code=...) for Python/IPython or lua(code=...) for bundled Luau. Either starts its language’s kernel when none is current. There is one current kernel: a language mismatch errors without switching or running the code. IPython magics, including %%bash, are Python-only.

For a named kernel, use create(dlgname="work", language="luau"). Omit language to reuse an existing binding unchanged, or default a new kernel to Python. An explicit language must match an existing binding. The other tools are list_kernels, use_kernel, delete_kernel, restart, and interrupt; creation, selection, and listing report the language.

These tools forward to rustygate. list_kernels, use_kernel, and create also accept a host naming a gateway from gateways.toml. One MCP registration can therefore reach multiple machines. Replies retain the gateway’s text and image blocks. Python startup and inspectors run only in Python, never Luau, including after restart.

$CLIKERNEL_HOST overrides the default gateway URL, http://127.0.0.1:8787. If no gateway answers, clikernel uses a private child gateway for the conversation. The ownership rules above determine which kernels close at session end.

Pass --quiet, as in clikernel-mcp --quiet, to omit startup output from replies. Python startup code still runs.

Configuration

Three optional files in $XDG_CONFIG_HOME/clikernel/ configure the router, usually under ~/.config/clikernel/:

  • startup.py runs in each Python kernel clikernel creates, with __file__ set to its path. Its output appears in the reply announcing the kernel unless --quiet is set.
  • inspectors.py installs Python cell inspectors after startup. Define inspect, a list named inspectors, or both. Each inspector runs once before a cell: a one-argument inspector takes the cell’s AST, and a two-argument inspector takes the AST and raw source. Return a string to print a note before the output. Raise the provided RuleBlock to block execution. Other exceptions produce a warning and allow the cell to run. See examples/inspectors.py.
  • gateways.toml names remote gateways and configures authentication without putting tokens in tool arguments:
[gateways.solveit]
url = "https://solveit.example.com/gate"
token_env = "SOLVEIT_TOKEN"
verify = false   # optional: accept a self-signed certificate

The stream protocol

Run clikernel as a plain CLI process for clients that read a text stream rather than MCP messages. It uses a delimiter-framed stdin/stdout protocol:

  • Input is not echoed.
  • Each request gets a . acknowledgement.
  • A per-process random delimiter marks the end of each response.
  • Multiline cells are framed by -- and the delimiter.

The startup banner supplies the protocol instructions and delimiter. Running clikernel without arguments creates a kernel and stops it on exit. --kernel <id> attaches to an existing kernel and leaves it running on exit.

Release files for clikernel 0.2.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clikernel 0.2.10
File Size Uploaded
clikernel-0.2.10.tar.gz 24.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for clikernel 0.2.10
File Interpreter ABI Platform
clikernel-0.2.10-py3-none-any.whl Python 3 none any Details

Total release size: 47.4 kB

Release files / clikernel-0.2.10.tar.gz

Download URL clikernel-0.2.10.tar.gz
Size 24.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5ea4d9bb7aea96384a3acdf8a667de2c2741ca819088346d4c746d506bd3b71a
BLAKE2b-256 checksum
How to use checksums
b5a24ab637db2176f3c349ddbf3a6fbba92e2a618449e7d7e367b0465629623a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release files / clikernel-0.2.10-py3-none-any.whl

Download URL clikernel-0.2.10-py3-none-any.whl
Size 22.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
75c37a1f01ec8c74d3a9668fde63928d634ac76a17d2e02b49a8c4bf35090750
BLAKE2b-256 checksum
How to use checksums
65d4272bfe9f080bd890cc6475860891f7ee6eb514f46ff3f9821407f220a9e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.15

Release history Release notifications | RSS feed

0.2.14

2 release files

0.2.13

2 release files

0.2.12

2 release files

This release

0.2.10 This release

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page