Skip to main content

clikernel

clikernel gives LLM agents persistent kernel sessions over MCP or a plain stream protocol. Imports, variables, and results remain available between calls. Agents can create kernels or attach to existing ones, including a user’s live solveit kernel.

rustygate hosts the kernels. Clikernel routes requests to local or named remote gateways and supplies startup code to Python kernels.

New kernels close with their creating conversation by default. Attaching to an existing kernel does not claim ownership. Use autoclose=false on a persistent gateway to keep a new kernel for later conversations. See core for configuration and lifecycle details.

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

Choose a kernel, then execute code:

create(kernel="ipymini")
exec(code="6*7")

Use kernel="luau" for bundled Luau, or kernel="miniapl" for APL when miniapl is installed on the gateway. exec never creates or switches kernels. See MCP for named gateways, dialog bindings, and other tools.

Configuration

Three optional files in $XDG_CONFIG_HOME/clikernel/ configure the router, usually under ~/.config/clikernel/, or under the directory clikernel-mcp --cfgdir names:

  • 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.12

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.12
File Size Uploaded
clikernel-0.2.12.tar.gz 24.3 kB Details

Built distribution (wheel)

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

Total release size: 46.6 kB

Release files / clikernel-0.2.12.tar.gz

Download URL clikernel-0.2.12.tar.gz
Size 24.3 kB
Tags Source
SHA-256 checksum
How to use checksums
375978a0373a61623c770992fb7262f59025200ff4f42e732a3b5fe504a48e08
BLAKE2b-256 checksum
How to use checksums
fdfbb1020ecbafa0f69ca402df00e98c60dfe3a616fb4eb0a968c3e54c2f4003
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.12-py3-none-any.whl

Download URL clikernel-0.2.12-py3-none-any.whl
Size 22.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d656134866f1e7678c2e63a95284479caef19d965574d43b115871650835155
BLAKE2b-256 checksum
How to use checksums
4388eb75b0ca6e302ee9db189ba0c07d35db650656be7c84cd1df6cf160dead4
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

This release

0.2.12 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