JupyterMCP connects Jupyter Notebook to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Jupyter Notebooks. This integration enables AI-assisted code execution, data analysis, visualization, and more. This tool is compatible ONLY with Jupyter Notebook version 6.x. It does NOT work with: - Jupyter Lab - Jupyter Notebook v7.x - VS Code Noteboo
Add this skill
npx mdskills install jjsantos01/jupyter-notebook-mcpBridges Jupyter Notebook 6.x to Claude via WebSocket, enabling AI-driven code execution and analysis
1# JupyterMCP - Jupyter Notebook Model Context Protocol Integration23JupyterMCP connects [Jupyter Notebook](https://jupyter.org/) to [Claude AI](https://claude.ai/chat) through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Jupyter Notebooks. This integration enables AI-assisted code execution, data analysis, visualization, and more.45## ⚠️ Compatibility Warning67**This tool is compatible ONLY with Jupyter Notebook version 6.x.**89It does NOT work with:1011- Jupyter Lab12- Jupyter Notebook v7.x13- VS Code Notebooks14- Google Colab15- Any other notebook interfaces1617## Features1819- **Two-way communication**: Connect Claude AI to Jupyter Notebook through a WebSocket-based server20- **Cell manipulation**: Insert, execute, and manage notebook cells21- **Notebook management**: Save notebooks and retrieve notebook information22- **Cell execution**: Run specific cells or execute all cells in a notebook23- **Output retrieval**: Get output content from executed cells with text limitation options2425## Components2627The system consists of three main components:28291. **WebSocket Server (`jupyter_ws_server.py`)**: Sets up a WebSocket server inside Jupyter that bridges communication between notebook and external clients302. **Client JavaScript (`client.js`)**: Runs in the notebook to handle operations (inserting cells, executing code, etc.)313. **MCP Server (`jupyter_mcp_server.py`)**: Implements the Model Context Protocol and connects to the WebSocket server3233## Installation3435### Prerequisites3637- [Python 3.12 or newer](https://www.python.org/downloads/) (probably also work with older versions, but not tested)38- [`uv` package manager](/README.md#installing-uv)39- [Claude AI desktop application](https://claude.ai/download)4041#### Installing uv4243If you're on Mac:4445```bash46brew install uv47```4849On Windows (PowerShell):5051```bash52powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"53```5455For other platforms, see the [uv installation guide](https://docs.astral.sh/uv/getting-started/installation/).5657### Setup58591. Clone or download this repository to your computer:6061 ```bash62 git clone https://github.com/jjsantos01/jupyter-notebook-mcp.git63 ```64652. Create virtual environment with required packages an install `jupyter-mcp` kernel, so it can be recognized by your jupyter installation, if you had one before.6667 ```bash68 uv run python -m ipykernel install --name jupyter-mcp69 ```70713. (optional) Install additional Python packages for your analysis:7273 ```bash74 uv pip install seaborn75 ```76774. Configure Claude desktop integration:78 Go to `Claude` > `Settings` > `Developer` > `Edit Config` > `claude_desktop_config.json` to include the following:7980 ```json81 {82 "mcpServers": {83 "jupyter": {84 "command": "uv",85 "args": [86 "--directory",87 "/ABSOLUTE/PATH/TO/PARENT/REPO/FOLDER/src",88 "run",89 "jupyter_mcp_server.py"90 ]91 }92 }93 }94 ```9596 Replace `/ABSOLUTE/PATH/TO/` with the actual path to the `src` folder on your system. For example:97 - Windows: `"C:\\Users\\MyUser\\GitHub\\jupyter-notebook-mcp\\src\\"`98 - Mac: `/Users/MyUser/GitHub/jupyter-notebook-mcp/src/`99100 If you had previously opened Claude, then `File` > `Exit` and open it again.101102## Usage103104### Starting the Connection1051061. Start your Jupyter Notebook (version 6.x) server:107108 ```bash109 uv run jupyter nbclassic110 ```1111122. Create a new Jupyter Notebook and make sure that you choose the `jupyter-mcp` kernel: `kernel` -> `change kernel` -> `jupyter-mcp`1131143. In a notebook cell, run the following code to initialize the WebSocket server:115116 ```python117 import sys118 sys.path.append('/path/to/jupyter-notebook-mcp/src') # Add the path to where the scripts are located119120 from jupyter_ws_server import setup_jupyter_mcp_integration121122 # Start the WebSocket server inside Jupyter123 server, port = setup_jupyter_mcp_integration()124 ```125126 Don't forget to replace here `'/path/to/jupyter-notebook-mcp/src'` with `src` folder on your system. For example:127 - Windows: `"C:\\Users\\MyUser\\GitHub\\jupyter-notebook-mcp\\src\\"`128 - Mac: `/Users/MyUser/GitHub/jupyter-notebook-mcp/src/`129130 1311324. Launch Claude desktop with MCP enabled.133134### Using with Claude135136Once connected, Claude will have access to the following tools:137138- `ping` - Check server connectivity139- `insert_and_execute_cell` - Insert a cell at the specified position and execute it140- `save_notebook` - Save the current Jupyter notebook141- `get_cells_info` - Get information about all cells in the notebook142- `get_notebook_info` - Get information about the current notebook143- `run_cell` - Run a specific cell by its index144- `run_all_cells` - Run all cells in the notebook145- `get_cell_text_output` - Get the output content of a specific cell146- `get_image_output` - Get the images output of a specific cell147- `edit_cell_content` - Edit the content of an existing cell148- `set_slideshow_type`- Set the slide show type for cell149150## ⚠️ DISCLAIMER151152This is an experimental project and should be used with caution. This tool runs arbitrary Python code in your computer, which could potentially modify or delete data if not used carefully. Always back up your important projects and data.153154## Example Prompts155156Ask Claude to perform notebook operations:157158### Python example159160You can check the [example notebook](/notebooks/example_notebook.ipynb) and the [video demo](https://x.com/jjsantoso/status/1906780778807390562)161162```plain163You have access to a Jupyter Notebook server.164165I need to create a presentation about Python's Seaborn library.166The content is as follows:167168- What is Seaborn?169- Long vs. Wide data format170- Advantages of Seaborn over Matplotlib171- Commonly used Seaborn functions172- Live demonstration (comparison of Seaborn vs. Matplotlib)173 - Bar plot174 - Line plot175 - Scatter plot176177For each concept, I want the main explanations provided in markdown cells, followed by one or more Python code cells demonstrating its usage. Keep the text concise—the cells shouldn't exceed 10 lines each.178179Use appropriate slideshow types for each cell to make the presentation visually appealing.180```181182[Check Here the full conversation](https://claude.ai/share/420b6aa6-b84b-437f-a6a6-89d310c36d52)183184### Stata example185186For this example, you need the [Stata Software](https://www.stata.com/) (v17 or later), which is not open source. If you already have Stata, you need to install the [`stata-setup`](https://pypi.org/project/stata-setup/) package:187188```bash189uv pip install stata-setup190```191192Then, at the begining of your notebook, you need to additionally include:193194```python195import stata_setup196stata_setup.config('your_stata_installation_directory', 'your_stata_edition')197```198199You can check the [example notebook](/notebooks/stata_example.ipynb) and the [video demo](https://x.com/jjsantoso/status/1906780784800731251)200201This exercise comes from [Professor John Robert Warren webpage](https://www.rob-warren.com/soc3811_stata_exercises.html)202203```plain204You have access to a Jupyter Notebook server. By default it runs Python, but you can run Stata (v18) code in this server using the %%stata magic, for example:205206%%stata207display "hello world"208209Run the available tools to solve the exercise, execute the code, and interpret the results.210211**EXERCISE:**212213In this exercise, you will use data from the American Community Survey (ACS). The ACS is a product of the U.S. Census Bureau and involves interviewing millions of Americans each year. For an introduction to the ACS, visit the ACS website (here).214215For this exercise, I have created a data file containing two variables collected from respondents of the 2010 ACS who lived in one of two metropolitan areas: Minneapolis/St Paul and Duluth/Superior. The two variables are: (1) People's poverty status and (2) the time it takes people to commute to work.216217Use STATA syntax files you already have (from the first assignment or class examples) and modify them to accomplish the following goals.2182191. Read the data file (`"./stata_assignment_2.dat"`) for this assignment into STATA.2202. Be sure to declare "zero" as a missing value for `TRANTIME`, the commuting time variable.2213. Create a new dichotomous poverty variable that equals "1" if a person's income-to-poverty-line ratio (`POVRATIO`) is less than 100, and "0" otherwise; see the bottom of the assignment for an example of how to do this in STATA.2224. Separately for Minneapolis/St Paul and Duluth/Superior, produce:223 - a histogram of the commuting time (`TRANTIME`) variable.224 - measures of central tendency and spread for commuting time.225 - a frequency distribution for the poverty status (0 vs 1) variable.2265. Separately for Minneapolis/St Paul and Duluth/Superior, use STATA code to produce:227 - a 95% confidence interval for the mean commuting time.228 - a 95% confidence interval for the proportion of people who are poor. See below for an example of how to do this in STATA.229230Use the results from step #4 above to:2312326. Separately for Minneapolis/St Paul and Duluth/Superior, manually calculate:233 - a 95% confidence interval for the mean commuting time.234 - a 95% confidence interval for the proportion of people who are poor.2357. Confirm that your answers from steps #5 and #6 match.236237Based on the results above, answer this question:2382398. How do you interpret the confidence intervals calculated in steps #5 and #6 above?2402419. Finally, create a do file (.do) with the all the Stata code and the answers as comments.242243---244245**DESCRIPTION OF VARIABLES IN "STATA ASSIGNMENT 2.DAT"**246247**METAREAD** (Column 4-7)248Metropolitan Area249- `2240`: Duluth-Superior, MN/WI250- `5120`: Minneapolis-St. Paul, MN251252**POVRATIO** (Column 18-20)253Ratio of person's income to the poverty threshold:254- `<100`: Below Poverty Line255- `100`: At Poverty Line256- `>100`: Above Poverty Line257258**TRANTIME** (Column 21-23)259Travel time to work260- `0`: Zero minutes261- `1`: 1 Minute262- etc.263264```265266[Check Here the full conversation](https://claude.ai/share/97b5a546-9375-434d-8224-561706782880)267268## Testing with External Client269270You can test the functionality without using Claude Desktop with the included external client:271272```bash273uv run python src/jupyter_ws_external_client.py274```275276This will provide an interactive menu to test some available functions.277278For automated testing of all commands:279280```bash281uv run python src/jupyter_ws_external_client.py --batch282```283284## Troubleshooting285286- **Connection Issues**: If you experience connection timeouts, the client includes a reconnection mechanism. You can also try restarting the WebSocket server.287- **Cell Execution Problems**: If cell execution doesn't work, check that the cell content is valid Python/Markdown and that the notebook kernel is running.288- **WebSocket Port Conflicts**: If the default port (8765) is already in use, the server will automatically try to find an available port.289290## Limitations291292- Only supports Jupyter Notebook 6.x293- Text output from cells is limited to 1500 characters by default294- Does not support advanced Jupyter widget interactions295- Connection may timeout after periods of inactivity296297## License298299[MIT](/LICENSE)300301## Other Jupyter MCPs302303This project is inspired by similar MCP integrations for Jupyter as:304305- [ihrpr](https://github.com/ihrpr/mcp-server-jupyter)306- [Datalayer](https://github.com/datalayer/jupyter-mcp-server/tree/main)307
Full transparency — inspect the skill content before installing.