About π Jupyter MCP Server
Jupyter MCP Server connects MCP-enabled applications and AI agents to Jupyter notebooks for code execution and notebook management. It captures text and image outputs, including PNG and JPEG, and maintains state across operations.
Key features
- 01Execute Python code in real time
- 02Manage notebook kernels and sessions
- 03Create and edit notebook cells
- 04Extract text and image outputs
- 05Create, list, and switch notebooks
Use cases
- 01Run analysis code in a notebook
- 02Generate visualizations and retrieve images
- 03Organize notebook cells through an AI agent
- 04Inspect execution output and errors
MCP support
The server exposes notebook execution, cell, file, and output operations to MCP clients. It connects with Jupyter through its server API and WebSocket channels.
Configuration
Local server config is the same for every client. Copy it into your clientβs MCP config file.
We havenβt collected a package or remote endpoint for this server. Follow the instructions in the project README.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEπ Jupyter MCP Server
A comprehensive Model Context Protocol (MCP) server that bridges AI agents with Jupyter notebooks, enabling real-time code execution, visualization generation, and advanced image extraction capabilities.
π― About This Project
This project is a fork and enhancement of the original Jupyter MCP Server developed by Datalayer, Inc.. Special thanks to the Datalayer team for their foundational work on integrating Jupyter with the Model Context Protocol ecosystem.
Key Enhancements in This Fork:
- Improved documentation and setup process
- Enhanced error handling and robustness
- Additional example configurations
- Streamlined installation and configuration
- Updated dependencies and compatibility
π Key Features
π― Real-Time Jupyter Integration
- Live Code Execution: Execute Python code in real-time through WebSocket connections
- Kernel Management: Automatic kernel creation, lifecycle management, and cleanup
- Session Persistence: Maintain state across multiple operations
πΌοΈ Advanced Image Extraction
- Multi-Format Support: Extract PNG and JPEG images from matplotlib, seaborn, plotly
- Base64 Encoding: Ready-to-use image data for AI processing
- Comprehensive Output Handling: Text, images, errors, and execution results
π Complete Notebook Management
- File Operations: Create, delete, switch between multiple notebooks
- Cell Manipulation: Add, modify, move, delete cells with full CRUD operations
- Content Management: Support for both markdown and code cells
π‘οΈ Enterprise-Ready Security
- Smart XSRF Handling: Automatic token detection and management
- Authentication Support: Compatible with tokenized Jupyter servers
- Error Recovery: Graceful fallbacks for connection issues
ποΈ Architecture
graph TD
A[AI Agent/Claude] --> B[MCP Server]
B --> C[Jupyter Server API]
B --> D[WebSocket Channels]
C --> E[Kernel Management]
D --> F[Real-time Execution]
F --> G[Output Capture]
G --> H[Image Extraction]
G --> I[Text Processing]
B --> J[Notebook Files]
π οΈ 18 Comprehensive Tools
π Cell Content Management
add_execute_code_cell- Execute Python code with real-time outputadd_markdown_cell- Add formatted documentationmodify_cell- Edit existing cell contentchange_cell_type- Convert between markdown and code cells
πΌοΈ Output Extraction
get_cell_image_output- Extract base64-encoded images (PNG/JPEG)get_cell_text_output- Get all text outputs including errors and tracebacks
ποΈ Notebook File Operations
create_notebook- Create new notebook filesdelete_notebook- Remove notebook files safelyswitch_notebook- Change active notebooklist_notebooks- Browse available notebooks
π Data Discovery
list_cells- Overview of all cells with previewread_cell- Full content of specific cellsget_notebook_info- Comprehensive notebook metadata
View complete tool documentation β
π Quick Start
Prerequisites
- Python 3.11+
- Jupyter Notebook
- Claude Desktop or compatible MCP client
Installation
-
Clone the repository
git clone https://github.com/JosephLin11/jupyter-mcp-server.git cd jupyter-mcp-server -
Install dependencies
pip install -r requirements.txt -
Start Jupyter Server
./scripts/start_jupyter.sh -
Configure Claude Desktop Add to your
claude_desktop_config.json:{ "mcpServers": { "jupyter": { "command": "python", "args": ["/path/to/your/jupyter-mcp-server/src/jupyter_mcp_server.py"] } } }π‘ Tip: Run
python3 scripts/get_claude_config.pyto generate the correct configuration with current paths!
π‘ Example Use Cases
π Data Visualization Pipeline
# 1. Create and execute visualization code
add_execute_code_cell(cell_content="""
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
# Generate sample data
data = np.random.normal(0, 1, 1000)
# Create beautiful visualization
plt.figure(figsize=(12, 8))
plt.subplot(2, 2, 1)
plt.hist(data, bins=50, alpha=0.7, color='skyblue')
plt.title('Distribution Analysis')
plt.subplot(2, 2, 2)
sns.boxplot(y=data)
plt.title('Box Plot Analysis')
plt.tight_layout()
plt.show()
""")
# 2. Extract the generated image
get_cell_image_output(cell_index=0)
π§ͺ Scientific Computing
# 3D surface visualization
add_execute_code_cell(cell_content="""
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(12, 9))
ax = fig.add_subplot(111, projection='3d')
# Create mesh
x = np.linspace(-5, 5, 100)
y = np.linspace(-5, 5, 100)
X, Y = np.meshgrid(x, y)
Z = np.sin(np.sqrt(X**2 + Y**2))
# Render surface
surface = ax.plot_surface(X, Y, Z, cmap='plasma', alpha=0.9)
ax.set_title('3D Mathematical Function')
plt.colorbar(surface)
plt.show()
""")
# Extract 3D visualization
get_cell_image_output(cell_index=1)
π Technical Highlights
Advanced WebSocket Implementation
- Real-time bidirectional communication with Jupyter kernels
- Comprehensive message type handling (execute_result, display_data, stream, error)
- Automatic reconnection and fallback mechanisms
Smart Output Processing
- Multi-format image extraction (PNG, JPEG) with base64 encoding
- Structured output capture preserving metadata
- Error handling with full traceback support
Robust Security Model
- Automatic XSRF token detection and management
- Multiple authentication endpoint support
- Graceful degradation for different Jupyter configurations
Enterprise-Grade Error Handling
- Comprehensive logging with configurable levels
- Fallback execution modes for reliability
- Resource cleanup and connection management
π Comparison with Alternatives
| Feature | This Implementation | jjsantos01 MCP | Cursor MCP |
|---|---|---|---|
| Tools Available | π 18 tools | 10 tools | 8-10 tools |
| Image Extraction | π PNG + JPEG | PNG only | None |
| Setup Complexity | π Automatic | Manual browser init | CLI args |
| Version Support | π All Jupyter versions | Jupyter 6.x only | Version agnostic |
| Real-time Execution | π WebSocket + HTTP | WebSocket bridge | File-only |
| Security Handling | π Auto XSRF | Basic | Enhanced |
π§ͺ Testing
Run the comprehensive test suite:
# Test image extraction capabilities
python tests/test_image_extraction.py
# Test notebook operations
python tests/test_notebook_save.py
π Project Structure
jupyter-mcp-server/
βββ src/
β βββ jupyter_mcp_server.py # Main MCP server implementation
βββ notebooks/ # π All Jupyter notebooks are created here
β βββ mcp_notebook.ipynb # Default notebook for MCP operations
βββ tests/
β βββ test_image_extraction.py # Image extraction tests
β βββ test_notebook_save.py # Notebook operation tests
βββ scripts/
β βββ start_jupyter.sh # Jupyter server startup script
β βββ get_claude_config.py # Claude configuration generator
βββ examples/
β βββ claude_desktop_config.json # Example configuration
β βββ mcp_notebook.ipynb # Example notebook
β βββ new_notebook.ipynb # Sample notebook
βββ docs/
β βββ MCP_TOOLS_SUMMARY.md # Complete tool reference
β βββ SETUP.md # Setup guide
β βββ IMAGE_EXTRACTION_README.md # Image extraction guide
βββ requirements.txt # Python dependencies
βββ pyproject.toml # Project configuration
βββ README.md # Project documentation
π€ Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
π License
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
π Acknowledgments
- Original Development: Datalayer, Inc. for creating the foundational Jupyter MCP Server
- Inspired by the Model Context Protocol ecosystem
- Built upon the robust Jupyter Server API
- Enhanced with ideas from various MCP implementations
- Special thanks to the open-source community
π§ Contact
Joseph Lin - GitHub
Project Link: https://github.com/JosephLin11/jupyter-mcp-server
Original Project: https://github.com/datalayer/jupyter-mcp-server
β Star this repository if you find it useful! β
Built with β€οΈ for the AI and data science community
Originally developed by Datalayer, enhanced and maintained by Joseph Lin
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.