Skip to main content
Glama
ipython-kernel-mcp

ipython-kernel-mcp

ipython-kernel-mcp

An MCP (Model Context Protocol) server that connects to an existing IPython kernel, providing persistent code execution with shared state across calls.

Based on ipython-mcp by gabiteodoru, rewritten for the MCP Python SDK 2.x (MCPServer instead of the removed FastMCP).

How it works

The server connects to a running IPython kernel via a Jupyter connection file (ZMQ). Variables, imports, and computed results persist between tool calls. Multiple clients can share the same kernel — for example, VS Code's variable explorer and an AI agent connected via MCP.

Related MCP server: notebook-agent-mcp

Installation

pip install git+https://github.com/asanchezleache/ipython-kernel-mcp.git

Requires mcp>=2 and jupyter-client>=8 (installed automatically).

Usage

1. Start an IPython kernel

ipython kernel --ConnectionFileMixin.connection_file=~/ipython-mcp-connection.json

2. Register with your MCP client

For Vibe CLI:

vibe mcp add ipython-kernel --transport stdio \
  --command ipython-kernel-mcp \
  --env IPYTHON_MCP_CONNECTION=~/ipython-mcp-connection.json

For other MCP clients (Claude Desktop, etc.), add to your config:

{
  "mcpServers": {
    "ipython-kernel": {
      "command": "ipython-kernel-mcp",
      "env": {
        "IPYTHON_MCP_CONNECTION": "~/ipython-mcp-connection.json"
      }
    }
  }
}

3. Connect VS Code (optional)

Cmd+Shift+P → "Jupyter: Connect to Existing Kernel" → select the connection file. VS Code's variable explorer, inline plots, and tqdm bars share the same kernel.

Tools

Tool

Description

connect_to_kernel

Connect to a running IPython kernel via connection file

execute_code

Execute Python code in the persistent kernel

kernel_status

Check connection status

interrupt_kernel

Interrupt a running execution

Notes

  • The kernel must be started separately. This server connects to an existing kernel; it does not start one.

  • stdout/stderr is collected and returned when execution completes. There is no real-time streaming to the MCP client. For live output (tqdm bars, print statements), use VS Code or a terminal connected to the same kernel.

  • The connection file path is resolved from the connection_file parameter, then the IPYTHON_MCP_CONNECTION environment variable.

License

MIT. See LICENSE.

Available Tools

4 tools
connect_to_kernelA

Connect to an existing IPython kernel using its connection file.

Args: connection_file: Path to the kernel connection JSON file. If not provided, uses the IPYTHON_MCP_CONNECTION environment variable.

Returns: Connection status message.

Inputs: connection_file. Returns: result

execute_codeA

Execute Python code on the connected IPython kernel.

Variables persist between calls. Output (stdout, results, errors) is collected and returned as a single string when execution completes.

Args: code: Python code to execute.

Returns: Execution output (stdout, expression results, or error messages).

Inputs: code (required). Returns: result

interrupt_kernelA

Interrupt the current kernel execution by sending SIGINT.

Useful for stopping long-running code or infinite loops.

Returns: Interrupt status message.

Inputs: no named parameters. Returns: result

kernel_statusA

Check the current kernel connection status.

Returns: Status message indicating whether a kernel is connected.

Inputs: no named parameters. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool performs a clearly distinct function: connecting, executing, checking status, and interrupting. There is no meaningful overlap or ambiguity between tool purposes.

    Naming Consistency4/5

    Most tools follow a verb-first naming pattern (connect_to_kernel, execute_code, interrupt_kernel), but kernel_status is noun-first and breaks the pattern slightly. Overall the naming remains predictable and readable.

    Tool Count5/5

    Four tools is a well-scoped count for a focused IPython kernel integration. Each tool fills a necessary role without unnecessary bloat.

    Completeness4/5

    The core lifecycle of connect, execute, check status, and interrupt is covered. Missing disconnect or restart operations are minor gaps that agents can work around, but the main workflows are supported.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to execute Python, TypeScript, and JavaScript code in persistent Jupyter kernels with stateful variables and imports across interactions.
      7
      79 PyPI
      4
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to execute Jupyter notebook cells with persistent kernel state, output persistence, and structured JSON control surface.
      2
      -
    • A
      license
      A
      quality
      B
      maintenance
      Enables interactive Python execution with a persistent IPython kernel through MCP, retaining namespace state and providing structured output logs for agent and tool integrations.
      8
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Connects Claude Code to local Jupyter kernels for code execution, kernel management, and notebook execution, with security gating and output capture.
      PolyForm Noncommercial 1.0.0