Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
129 changes: 129 additions & 0 deletions documentation/blog/2025-06-24-mcp-jupyter-server/demo.ipynb

Large diffs are not rendered by default.

158 changes: 158 additions & 0 deletions documentation/blog/2025-06-24-mcp-jupyter-server/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
---
title: "MCP Jupyter: AI-Powered Machine Learning and Data Science"
description: Enable AI agents to work directly with your Jupyter notebooks, leveraging persistent memory and stateful collaboration for enhanced ML and data science workflows
date: 2025-06-24
Comment thread
dwyatte marked this conversation as resolved.
Outdated
authors:
- damien
- dean
- harrison
---

![MCP Jupyter Server](data-goose.png)

Machine learning and data science workflows are inherently iterative. You load data, explore patterns, build models, and refine your approach based on results. But traditional AI assistants lose context between interactions, forcing you to reload data and re-establish context repeatedly—making data-heavy development slow and expensive.

The [**MCP Jupyter Server**](https://github.com/block/mcp-jupyter) solves this by enabling AI agents like Goose to work directly with your Jupyter notebooks, maintaining persistent memory and state across interactions while letting the AI interact with your data through code execution rather than raw data transfer.

<!--truncate-->

## The Memory and Context Problem

Traditional AI coding assistants face a fundamental limitation: they lose context between code iterations. They also are not designed for adhoc work where the expectation is the code should run from start to finish. This creates several challenges for data-heavy ML workflows:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would find it very helpful to have this problem explained with an example. The same example could then be used to show how much better the AI agent works when the MCP Jupyter Server is enabled. Happy to collaborate, maybe making a little video about this!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the text with a little more context and included a link to a video. LMK what you think!

Comment thread
damienrj marked this conversation as resolved.
Outdated

- **Constant data reloading**: Each interaction requires re-loading or describing your dataset
- **Expensive iterations**: Large datasets are slow and costly to process repeatedly
- **Context size**: The raw data is also too large to be fit in context
Comment thread
damienrj marked this conversation as resolved.
Outdated
- **Not designed for adhoc work**: It is harder to have the model do some steps for you, and then let you take over and then later pass control back to the model
Comment thread
damienrj marked this conversation as resolved.
Outdated

This has made it difficult to use AI to help with data science workflows, which led to the creation of the MCP Jupyter Server.

## A Better Approach: Persistent State

The MCP Jupyter Server takes a different approach. Instead of losing context between interactions, it maintains persistent memory and lets the AI interact with your data through code execution. This creates a powerful paradigm:
Comment thread
damienrj marked this conversation as resolved.
Outdated

- **Persistent memory**: Variables and state are maintained across all interactions
- **Efficient iterations**: No need to reload data or re-establish context
- **Code-based data interaction**: AI explores data through execution, not given the raw data
Comment thread
damienrj marked this conversation as resolved.
Outdated
- **True pair programming**: Seamless collaboration within the same notebook context

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **True pair programming**: Seamless collaboration within the same notebook context
- **True pair programming**: Seamless collaboration between assistant and human within the same notebook context


## Transforming ML Workflows

### Exploratory Data Analysis

Instead of describing your dataset, let the AI explore it directly:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to cut down on the AI here and elsewhere

Suggested change
Instead of describing your dataset, let the AI explore it directly:
Instead of describing your dataset, explore it directly with AI:


> <span style={{color: '#2563eb', fontWeight: 'bold'}}>User:</span> "Help me understand this customer dataset"
>
> <span style={{color: '#059669', fontWeight: 'bold'}}>AI:</span> "Let me explore your data structure first"
>
> *<span style={{color: '#6b7280', fontStyle: 'italic'}}>[AI executes: df.info(), df.describe(), df.head()]</span>*
>
> <span style={{color: '#059669', fontWeight: 'bold'}}>AI:</span> "I can see you have 50,000 customers with 12 features. The data includes demographics (age, income), behavioral metrics (purchase_frequency, avg_order_value), and some missing values in the 'phone_number' column. Would you like me to create visualizations for the key relationships, like age vs income or purchase patterns?"
>
> <span style={{color: '#2563eb', fontWeight: 'bold'}}>User:</span> "Yes, show me the age and income distributions, and any correlations"
>
> <span style={{color: '#059669', fontWeight: 'bold'}}>AI:</span> "Perfect! I'll create histograms for age and income, plus a correlation heatmap"
>
> *<span style={{color: '#6b7280', fontStyle: 'italic'}}>[AI generates and displays visualizations]</span>*

The AI can see your actual column names, data types, and distributions—leading to much more relevant suggestions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The AI can see your actual column names, data types, and distributions—leading to much more relevant suggestions.
The assistant can see your actual column names, data types, and distributions—leading to much more relevant suggestions.


### Interactive Model Development

The AI becomes a true collaborator in your modeling process:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The AI becomes a true collaborator in your modeling process:
AI becomes a true collaborator in your modeling process:


> <span style={{color: '#2563eb', fontWeight: 'bold'}}>User:</span> "This model isn't performing well"
>
> <span style={{color: '#059669', fontWeight: 'bold'}}>AI:</span> "Let me check the current metrics and feature importance"
>
> *<span style={{color: '#6b7280', fontStyle: 'italic'}}>[AI executes your existing model evaluation code]</span>*
>
> <span style={{color: '#059669', fontWeight: 'bold'}}>AI:</span> "I see the accuracy is 72% and the most important features are 'price' and 'location'. The model seems to be overfitting - would you like me to try regularization or reduce the feature set?"
>
> <span style={{color: '#2563eb', fontWeight: 'bold'}}>User:</span> "Try regularization first"
>
> <span style={{color: '#059669', fontWeight: 'bold'}}>AI:</span> "I'll add L2 regularization and test different alpha values"
>
> *<span style={{color: '#6b7280', fontStyle: 'italic'}}>[AI implements and tests changes iteratively]</span>*
>
> <span style={{color: '#059669', fontWeight: 'bold'}}>AI:</span> "Great! With alpha=0.1, accuracy improved to 78% and the validation curve looks much better. Should I tune it further or try ensemble methods?"

### Real-time Debugging

When errors occur, the AI has full context:
Comment thread
damienrj marked this conversation as resolved.
Outdated

> <span style={{color: '#2563eb', fontWeight: 'bold'}}>User:</span> "I'm getting a KeyError in cell 5"
>
> <span style={{color: '#059669', fontWeight: 'bold'}}>AI:</span> "Let me check what columns are available in your dataframe"
>
> *<span style={{color: '#6b7280', fontStyle: 'italic'}}>[AI executes: df.columns, df.info()]</span>*
>
> <span style={{color: '#059669', fontWeight: 'bold'}}>AI:</span> "I see the issue - you're trying to access 'customer_id' but the actual column name is 'CustomerID' with capital letters. Also, I notice you have 'purchase_date' as a string - should I convert that to datetime while I fix the KeyError?"
>
> <span style={{color: '#2563eb', fontWeight: 'bold'}}>User:</span> "Yes, fix both issues"
>
> <span style={{color: '#059669', fontWeight: 'bold'}}>AI:</span> "Done! I've updated the column reference and converted purchase_date to datetime. The cell should run properly now."

### Continuous Collaboration

Imagine a scenario where you are working on a new dataset:

> <span style={{color: '#2563eb', fontWeight: 'bold'}}>User:</span> *<span style={{color: '#6b7280', fontStyle: 'italic'}}>[Executes: df = pd.read_csv('sales_data.csv')]</span>*
>
> <span style={{color: '#2563eb', fontWeight: 'bold'}}>User:</span> "Let me check the data types and look for any anomalies"
>
> <span style={{color: '#059669', fontWeight: 'bold'}}>AI:</span> "I'll analyze your sales data structure"
>
> *<span style={{color: '#6b7280', fontStyle: 'italic'}}>[AI executes: df.info(), df.describe(include='all')]</span>*
>
> <span style={{color: '#059669', fontWeight: 'bold'}}>AI:</span> "I found a few issues: 'CustomerID' is stored as text but should be numeric, and there are 847 missing values in 'SalesAmount'. Would you like me to convert 'CustomerID' to numeric and fill the missing 'SalesAmount' values with the median?"
>
> <span style={{color: '#2563eb', fontWeight: 'bold'}}>User:</span> "Yes, please do that and show me the updated info"
>
> <span style={{color: '#059669', fontWeight: 'bold'}}>AI:</span> "Done! CustomerID is now numeric and SalesAmount gaps are filled. Your dataset is clean and ready for modeling."

*<span style={{color: '#6b7280', fontStyle: 'italic'}}>[Later in the session, after you've trained a model...]</span>*

> <span style={{color: '#2563eb', fontWeight: 'bold'}}>User:</span> "How is my model performing?"
>
> <span style={{color: '#059669', fontWeight: 'bold'}}>AI:</span> "Let me generate the key metrics for your trained model"
>
> *<span style={{color: '#6b7280', fontStyle: 'italic'}}>[AI accesses the existing model variable and generates evaluation metrics]</span>*
>
> <span style={{color: '#059669', fontWeight: 'bold'}}>AI:</span> "Your Random Forest achieved 0.84 precision and 0.81 recall. The confusion matrix shows some false positives in the high-value sales category. Would you like me to adjust the decision threshold or try feature engineering?"

This fluid back-and-forth, where the AI understands and builds upon the existing notebook state, allows for seamless collaboration without the need for constant context re-establishment or data reloading.
Comment thread
damienrj marked this conversation as resolved.
Outdated

## Example notebook

Can see an example notebook that was handled by the MCP Jupyter Server. The server
Comment thread
damienrj marked this conversation as resolved.
Outdated

**[📓 View the Complete Demo Notebook](https://github.com/block/mcp-jupyter/blob/main/demos/demo.ipynb)**

The demo walks through a typical data science workflow:
- **Install Missing Libraries**: Installing missing libraries for the notebook
- **Data Generation**: Creating synthetic data for analysis
- **Model Training**: Fitting a linear regression model with scikit-learn
- **Results Analysis**: Extracting model coefficients and performance metrics
- **Visualization**: Creating plots with seaborn

## Getting Started

The MCP Jupyter Server integrates seamlessly with existing workflows and can also be used with the notebook viewer in VS Code based IDEs.

For detailed setup and configuration, check out the [complete documentation](https://block.github.io/mcp-jupyter/).


<head>
<meta property="og:title" content="MCP Jupyter Server: Bringing Notebook Intelligence to AI Agents" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://block.github.io/goose/blog/2025/06/24/mcp-jupyter-server" />
<meta property="og:description" content="A powerful MCP server that enables AI agents to interact with Jupyter notebooks while preserving kernel state and variable context" />
<meta property="og:image" content="https://block.github.io/goose/assets/images/data-goose-31db12eb84fe22345f4ed83d50d8d41f.png" />
<meta name="twitter:card" content="summary_large_image" />
<meta property="twitter:domain" content="block.github.io/goose" />
<meta name="twitter:title" content="MCP Jupyter Server: Bringing Notebook Intelligence to AI Agents" />
<meta name="twitter:description" content="A powerful MCP server that enables AI agents to interact with Jupyter notebooks while preserving kernel state and variable context" />
<meta name="twitter:image" content="https://block.github.io/goose/assets/images/data-goose-31db12eb84fe22345f4ed83d50d8d41f.png" />
</head>
26 changes: 26 additions & 0 deletions documentation/blog/authors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,32 @@ dalton:
socials:
github: dalton-turner

damien:
name: Damien Ramunno-Johnson
title: Principal Machine Learning Engineer
image_url: https://avatars.githubusercontent.com/u/2729283?v=4
page: true
socials:
linkedin: damienrj
github: damienrj

dean:
name: Dean Wyatte
title: Principal Machine Learning Engineer
image_url: https://avatars.githubusercontent.com/u/2512762?v=4
page: true
socials:
github: deanwyatte
Comment thread
damienrj marked this conversation as resolved.
Outdated

harrison:
name: Harrison Mamin
title: Senior Machine Learning Engineer
image_url: https://avatars.githubusercontent.com/u/114013937?v=4
page: true
socials:
github: hmamin-block
Comment thread
dwyatte marked this conversation as resolved.
Outdated


tania:
name: Tania Chakraborty
title: Senior Technical Community Manager
Expand Down
Loading