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="py")
exec(code="6*7")
Use kernel="luau" for bundled Luau, or kernel="apl" for APL when basedpl is installed in the gateway’s environment. create accepts any kernelspec the gateway finds. 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.pyruns in each Python kernel clikernel creates, with__file__set to its path. Its output appears in the reply announcing the kernel unless--quietis set.inspectors.pyinstalls Python cell inspectors after startup. Defineinspect, a list namedinspectors, 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 providedRuleBlockto block execution. Other exceptions produce a warning and allow the cell to run. See examples/inspectors.py.gateways.tomlnames 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.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| clikernel-0.2.14.tar.gz | 24.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| clikernel-0.2.14-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 47.0 kB
Release files / clikernel-0.2.14.tar.gz
| Download URL | clikernel-0.2.14.tar.gz |
|---|---|
| Size | 24.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4fbcec4c50f2d1946b72f13052872e405a406b4a30136f5e7f3f2d4c7459bb48
|
|
BLAKE2b-256 checksum How to use checksums |
b203dae3ba071a23bae24e9c0bdab9fb3ed6af71de3ebb5499e848651a472760
|
| 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.14-py3-none-any.whl
| Download URL | clikernel-0.2.14-py3-none-any.whl |
|---|---|
| Size | 22.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e7d932ba1b5e0b8f8242692be2907bdfb3d87edb398f059a47f73d3ab13d6149
|
|
BLAKE2b-256 checksum How to use checksums |
574143753d2cd4060c59f164fb72811b450fbba94ff166e232c85f655a84dff4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|