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.

jupygate 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 jupygate 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:

jupygate --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")

create accepts any kernelspec the gateway finds. In the main conversation, exec never creates or switches kernels. See MCP for named gateways and other tools.

In Claude Code, subagents share the current kernel unless clikernel-hook is registered as a PreToolUse hook. With the hook, each subagent’s first exec creates a kernel of its own. See Subagent kernels for the settings entry.

The router checks each exec cell against built-in rules for mistakes agents often make with this toolkit. Most rules add a note to the reply, and --quiet leaves the notes out. Two rules always block the cell: shell access through subprocess, os.system or os.popen, and changes to sys.path.

The router caps text replies to --maxout UTF-8 bytes (default 40,000; pass 0 to disable). When a reply exceeds that limit, the router saves the full output to a temporary file, returns the first chunk with the file path and remaining size, and serves subsequent chunks when you run exec(code="%cont") (or exec(code="%cont <id>") when several calls overflow in parallel).

Configuration

Two 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.
  • gateways.toml names remote gateways and configures authentication without putting tokens in tool arguments:
[gateways.solveit]
url = "https://<instance-host>/rusty"
token_file = "~/.config/solveit/session"

Run solveit-login to sign in through your browser and save that session file with mode 0600. Restart the client after signing in again. Use the instance URL from your browser with /rusty appended. For other gateways, choose one of token, token_env or token_file; verify = false accepts a self-signed certificate. See Solveit login for login options.

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.

Metadata

Release files for clikernel 0.2.21

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.21
File Size Uploaded Provenance Actions
clikernel-0.2.21.tar.gz 31.7 kB Without provenance Details for clikernel-0.2.21.tar.gz

Built distribution (wheel)

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

Total release size: 59.5 kB

Release files / clikernel-0.2.21.tar.gz

Download URL clikernel-0.2.21.tar.gz
Size 31.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7e905c74cdddd2f1cb36123abdcb608f668d7c4ea116dd8615ffc88de0d9a3e2
BLAKE2b-256 checksum
How to use checksums
377ec5cfbfca3c15e7c1d9ce70f149433b638013b7be66540f5e1bd363d37cdc
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.21-py3-none-any.whl

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

Security for clikernel 0.2.21

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

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