Manage Jupyter notebooks programmatically with MCP server tools for reading, editing, and executing cells
mcp-server-jupyter is an MCP (Model Context Protocol) server designed to manage and interact with Jupyter notebooks programmatically. This project enables AI applications, such as Claude Desktop, Continue, Cursor, and others, to connect to specific data sources and tools via a standardized protocol. By leveraging the power of Jupyter notebooks, this server provides a flexible environment for researchers, developers, and data scientists to execute code snippets, store computational experiments, and share insights.
mcp-server-jupyter includes six core tools, each designed to meet specific notebook management needs:
read_notebook_with_outputs
: This tool allows the server to read a Jupyter notebook's content along with its output cells.read_notebook_source_only
: A variant of read_notebook_with_outputs
, this tool is used when size limitations prevent reading the entire notebook, ensuring only the source code is processed.read_output_of_cell
: Enables retrieval of a specific cell's execution output for inspection.add_cell
: Facilitates the addition of new cells to an existing notebook programmatically.edit_cell
: Allows modification of an existing cell’s content, making it easier to update and evolve notebooks without manual interventions.execute_cell
: Executes a specific cell and returns its output for validation and verification purposes.These tools are designed to be lightweight, efficient, and compatible with the broader MCP ecosystem, ensuring seamless integration across various AI applications and contexts.
MCP (Model Context Protocol) serves as an interface for various AI applications to interact with data sources, tools, and notebooks. mcp-server-jupyter adheres strictly to this protocol, defining clear interfaces for the mcp
client to invoke server commands via HTTP requests.
The architecture of mcp-server-jupyter involves a Flask backend responsible for handling MCP queries from clients, parsing them into appropriate Jupyter notebook operations, and executing these tasks through the nbformat
library. The use of Flask ensures high flexibility and scalability, allowing the server to handle complex workflows across multiple notebooks simultaneously.
graph TD
A[AI Application] -->|MCP Client| B[MCP Server]
B --> C[Jupyter Notebook]
style A fill:#e1f5fe
style B fill:#f3e5f5
graph TD
A[Client API] --> B[Mathematical Model Engine]
B --> C[MCP Server]
C --> D[Jupyter Notebooks Repository]
D --> E[Output Storage]
style A fill:#e1f5fe
style B fill:#f3e5f5
style D fill:#b2eef4
To set up and run mcp-server-jupyter, follow these steps:
Before configuring the MCP server, ensure that you have a running Jupyter instance. This setup is critical for ensuring compatibility when integrating with the Jupyter notebooks.
uv venv --seed
source .venv/bin/activate
uv pip install jupyterlab
.venv/bin/jupyter lab
Note: The UV_PROJECT_ENVIRONMENT
should be set to the path of your virtual environment used for managing dependencies. You can obtain this path by running:
echo $(pwd)/.venv
To integrate mcp-server-jupyter with Claude Desktop, add a configuration entry in your claude_desktop_config.json
.
PyPi package:
{
"mcpServers": {
"Jupyter-notebook-manager": {
"command": "uv",
"args": ["run", "--with", "mcp-server-jupyter", "mcp-server-jupyter"],
"env": {
"UV_PROJECT_ENVIRONMENT": "/path/to/venv/.venv"
}
}
}
}
Git repo fork:
{
"mcpServers": {
"Jupyter-notebook-manager": {
"command": "uv",
"args": [
"run",
"--directory",
"/Users/inna/mcp-server-jupyter/src/mcp_server_jupyter",
"mcp-server-jupyter"
],
"env": {
"UV_PROJECT_ENVIRONMENT": "/path/to/venv/.venv"
}
}
}
}
In an automated data analysis pipeline, mcp-server-jupyter can manage multiple Jupyter notebooks running various preprocessing and modeling stages. By executing cells across different notebooks based on specific criteria (e.g., data availability), the workflow remains fully automated and scalable.
For developers working on live experiments, using mcp-server-jupyter allows for dynamic modifications to notebook content without disrupting ongoing computational tasks. This capability ensures that experiment setups can be adjusted in real-time while maintaining consistent state across multiple executions.
mcp-server-jupyter is compatible with the following MCP clients:
Claude Desktop
Continue
Cursor
gantt width:90%
title MCP Clients Supported by mcp-server-jupyter
dateFormat YYYY-MM-DD
section General Info
Claude Desktop :done, 2023-10-05, 2024-02-28
Continue : done, 2023-10-05, 2024-02-28
Cursor : inprogress, 2023-10-15, 2023-12-29
This section outlines the performance and compatibility matrix of mcp-server-jupyter with various AI applications.
To fine-tune the mcp-server-jupyter installation, consider these advanced configuration options:
API Key Security: Set an environment variable MCP_API_KEY
to secure your server against unauthorized access.
Custom Environment Setup:
{
"mcpServers": {
"Jupyter-notebook-manager": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-jupyter"],
"env": {
"API_KEY": "your-api-key"
}
}
}
}
Logging and Debugging: Enable detailed logging by setting MCP_DEBUG_LEVEL
to debug
.
A1: Ensure the Jupyter notebook is running in a compatible virtual environment managed via uv
. Configure your MCP server with the correct environment variables as detailed in the README.
A2: Yes, mcp-server-jupyter is optimized for handling both small and large notebooks. Use read_notebook_source_only
for larger files to avoid performance issues associated with full notebook processing.
A3: mcp-server-jupyter supports manual updates through its tools, but it does not yet support automatic reloads. Regularly save and refresh the notebook page manually after making changes using the server’s APIs.
A4: mcp-server-jupyter is designed to work with a wide range of Jupyter notebook versions, but compatibility might vary depending on specific features used in your notebooks. Test thoroughly before deploying in production environments.
A5: The API key and environment variables can be securely managed using .env files or configuration tools. Ensure that no unauthorized access is granted by securing these credentials meticulously.
To contribute to mcp-server-jupyter, follow these steps:
Clone the Repository:
git clone https://github.com/ihrpr/mcp-server-jupyter.git
Install Dependencies:
uv venv --seed
source .venv/bin/activate
pip install -r requirements.txt
Run the Server Locally:
python mcp_server_jupyter/__main__.py
Contribute by Submitting a Pull Request: Ensure your code adheres to our coding standards and integrates smoothly with existing features.
For more information on the broader MCP ecosystem, visit:
Join the community for updates, discussions, and more resources to enhance your use of mcp-server-jupyter in AI projects.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica