Logo van Python Notebook MCP

Python Notebook MCP

Community
UsamaK98

Lightweight Python Notebook MCP - Enable AI assistants to create, edit, and view Jupyter notebooks via Model Context Protocol

UitgeverUsamaK98
Repositorypython-notebook-mcp
TaalPython
Forks
13
Sterren
45
Beschikbare tools
0
Transporttypestdio
Categorieën
LicentieMIT
Links
  • Koppel tools aan AI-workflows

    Python Notebook MCP biedt MCP-functionaliteit die compatibele AI-clients en agenten kunnen gebruiken.

  • 0 beschikbare tools

    Bekijk hieronder de aanroepbare acties, inclusief namen en beschrijvingen als de server die beschikbaar stelt.

  • Configuratie om direct te kopiëren

    Gebruik de installatievoorbeelden om deze server in je favoriete MCP-client te configureren.

  • Indicatoren van opensource-interesse

    45 sterren en 13 forks in de gekoppelde repository.

This server allows compatible AI assistants (like Cursor or Claude Desktop) to interact with Jupyter Notebook files (.ipynb) on your local machine.

📋 Prerequisites

Before you begin, ensure you have the following installed:

  1. Python: Version 3.10 or higher.
  2. uv: The fast Python package installer and virtual environment manager from Astral. If you don't have it, install it:
    bash
    # On macOS / Linux
    curl -LsSf https://astral.sh/uv/install.sh | sh
    
    # On Windows (PowerShell)
    powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
    
    # IMPORTANT: Add uv to your PATH if prompted by the installer
    # For macOS/Linux (bash/zsh), add to your ~/.zshrc or ~/.bashrc:
    # export PATH="$HOME/.local/bin:$PATH"
    # Then restart your shell or run `source ~/.zshrc` (or equivalent)
  3. fastmcp CLI (Optional, for Claude Desktop fastmcp install): If you plan to use the fastmcp install method for Claude Desktop, you need the fastmcp command available.
    bash
    # Using uv
    uv pip install fastmcp
    
    # Or using pipx (recommended for CLI tools)
    pipx install fastmcp

🔧 Setup

  1. Clone the Repository:

    bash
    git clone https://github.com/UsamaK98/python-notebook-mcp.git # Or your fork/local path
    cd python-notebook-mcp
  2. Choose Setup Method:

    • Option A: Automated Setup (Recommended) Run the appropriate script for your OS from the project's root directory (where you just cd-ed into).

      • macOS / Linux:
        bash
        # Make script executable (if needed)
        chmod +x ./install_unix.sh
        # Run the script
        bash ./install_unix.sh
      • Windows (PowerShell):
        powershell
        # You might need to adjust PowerShell execution policy first
        # Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
        .\install_windows.ps1

      These scripts will create the .venv, install dependencies, and output the exact paths needed for your MCP client configuration.

    • Option B: Manual Setup Follow these steps if you prefer manual control or encounter issues with the scripts.

      1. Create & Activate Virtual Environment:
        bash
        # Create the environment (e.g., named .venv)
        uv venv
        
        # Activate the environment
        # On macOS/Linux (bash/zsh):
        source .venv/bin/activate
        # On Windows (Command Prompt):
        # .venv\Scripts\activate.bat
        # On Windows (PowerShell):
        # .venv\Scripts\Activate.ps1
        (You should see (.venv) or similar at the start of your shell prompt)
      2. Install Dependencies:
        bash
        # Make sure your venv is active
        uv pip install -r requirements.txt

▶️ Running the Server

Make sure your virtual environment (.venv) is activated if you used manual setup.

Method 1: Direct Execution (Recommended for Cursor, General Use)

This method uses uv run to execute the server script directly using your current Python environment (which should now have the dependencies installed).

  1. Run the Server:

    bash
    # From the python-notebook-mcp directory
    uv run python server.py

    The server will start and print status messages, including the (uninitialized) workspace directory.

  2. Client Configuration (mcp.json): Configure your MCP client (e.g., Cursor) to connect. Create or edit the client's MCP configuration file (e.g., .cursor/mcp.json in your workspace).

    Template (Recommended):

    json
    {
      "mcpServers": {
        "jupyter": {
          // Use the absolute path to the Python executable inside your .venv
          "command": "/full/absolute/path/to/python-notebook-mcp/.venv/bin/python", // macOS/Linux
          // "command": "C:\\full\\absolute\\path\\to\\python-notebook-mcp\\.venv\\Scripts\\python.exe", // Windows
          "args": [
              // Absolute path to the server script
              "/full/absolute/path/to/python-notebook-mcp/server.py"
            ],
          "autoApprove": ["initialize_workspace"] // Optional: Auto-approve certain safe tools
        }
      }
    }

    ❓ Why the full path to Python? GUI applications like Cursor might not inherit the same PATH environment as your terminal. Specifying the exact path to the Python interpreter inside your .venv ensures the server runs with the correct environment and dependencies. ⚠️ IMPORTANT: Replace the placeholder paths with the actual absolute paths on your system.

Method 2: Claude Desktop Integration (fastmcp install)

This method uses the fastmcp tool to create a dedicated, isolated environment for the server and register it with Claude Desktop. You generally don't need to activate the .venv manually for this method, as fastmcp install handles environment creation.

  1. Install the Server for Claude:
    bash
    # From the python-notebook-mcp directory
    fastmcp install server.py --name "Jupyter Notebook MCP"
    • fastmcp install uses uv behind the scenes to create the environment and install dependencies from requirements.txt.
    • The server will now appear in the Claude Desktop developer settings and can be enabled there. You generally don't need to manually edit claude_desktop_config.json when using fastmcp install.

📘 Usage

Key Concept: Workspace Initialization

Regardless of how you run the server, the first action you must take from your AI assistant is to initialize the workspace. This tells the server where your project files and notebooks are located.

python
# Example tool call from the client (syntax may vary)
initialize_workspace(directory="/full/absolute/path/to/your/project_folder")

⚠️ You must provide the full absolute path to the directory containing your notebooks. Relative paths or paths like . are not accepted. The server will confirm the path and list any existing notebooks found.

Core Operations

Once the workspace is initialized, you can use the available tools:

python
# List notebooks
list_notebooks()

# Create a new notebook
create_notebook(filepath="analysis/new_analysis.ipynb", title="My New Analysis")

# Add a code cell to the notebook
add_cell(filepath="analysis/new_analysis.ipynb", content="import pandas as pd\ndf = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]})\ndf.head()", cell_type="code")

# Read the first cell (index 0)
read_cell(filepath="analysis/new_analysis.ipynb", cell_index=0)

# Edit the second cell (index 1)
edit_cell(filepath="analysis/new_analysis.ipynb", cell_index=1, content="# This is updated markdown")

# Read the output of the second cell (index 1) after execution (if any)
read_cell_output(filepath="analysis/new_analysis.ipynb", cell_index=1)

# Read the entire notebook structure
read_notebook(filepath="analysis/new_analysis.ipynb")

🛠️ Available Tools

ToolDescription
initialize_workspaceREQUIRED FIRST STEP. Sets the absolute path for the workspace.
list_notebooksLists all .ipynb files found within the workspace directory.
create_notebookCreates a new, empty Jupyter notebook if it doesn't exist.
read_notebookReads the entire structure and content of a notebook.
read_cellReads the content and metadata of a specific cell by index.
edit_cellModifies the source content of an existing cell by index.
add_cellAdds a new code or markdown cell at a specific index or the end.
read_notebook_outputsReads all outputs from all code cells in a notebook.
read_cell_outputReads the output(s) of a specific code cell by index.

🧪 Development & Debugging

If you need to debug the server itself:

  • Run Directly: Use uv run python server.py and observe the terminal output for errors or print statements.
  • FastMCP Dev Mode: For interactive testing with the MCP Inspector:
    bash
    # Make sure fastmcp is installed in your environment
    # uv pip install fastmcp
    uv run fastmcp dev server.py

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Installatie

TypingMind
{
  "mcpServers": {
    "python-notebook-mcp": {
      "command": "fastmcp",
      "args": [
        "run",
        "server.py"
      ]
    }
  }
}

Gebruik Python Notebook MCP MCP met meerdere AI-modellen

TypingMind koppelt MCP-tools aan de werkruimte. Zodra Python Notebook MCP is verbonden, kun je deze dus met verschillende AI-modellen in TypingMind gebruiken, zonder de verbinding voor elk model apart in te stellen. Deze MCP-integratie draait lokaal via de TypingMind MCP-connector op je apparaat.

Installatiehandleiding voor de lokale connector

Gebruik dit als de MCP-server toegang nodig heeft tot lokale bestanden, apps of privébronnen op je computer.

1

Open de MCP-instellingen

Ga in TypingMind naar Instellingen, Geavanceerde instellingen en vervolgens Model Context Protocol. Kies daar Connector instellen.

  1. Open TypingMind in je browser.
  2. Klik op het pictogram Instellingen.
  3. Ga naar Geavanceerde instellingen.
  4. Open het gedeelte Model Context Protocol.
  5. Klik op Connector instellen en kies Dit apparaat.
Instelscherm voor de TypingMind MCP-connector met Dit apparaat geselecteerd
2

Voer de connectoropdracht uit

Kies Dit apparaat, kopieer de opdracht uit TypingMind en voer deze uit in Terminal. Laat het proces draaien zolang je MCP gebruikt.

  1. Kopieer de installatieopdracht die TypingMind toont.
  2. Open Terminal op macOS of Windows Terminal op Windows.
  3. Plak de opdracht en voer deze uit.
  4. Keur de pakketinstallatie goed als Terminal vraagt of je wilt doorgaan.
  5. Laat het proces in het Terminal-venster draaien zolang je MCP-tools gebruikt.
3

Voeg Python Notebook MCP toe als server

Klik op Servers bewerken zodra de connectorstatus Gereed is en plak de MCP-serverconfiguratie.

  1. Wacht tot de connectorstatus Gereed aangeeft.
  2. Klik op Servers bewerken.
  3. Plak de MCP-serverconfiguratie van Python Notebook MCP.
  4. Sla de serverlijst op.
  5. Vernieuw om te controleren of de connector nog steeds klaar is voor gebruik.
MCP-instellingen van TypingMind met een actieve server en de knop Servers bewerken
{
  "mcpServers": {
    "python-notebook-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Gebruik de verbinding met verschillende modellen

Sla de serverlijst op, open Plug-ins en schakel de MCP-tools van Python Notebook MCP in. Selecteer vervolgens een ondersteund AI-model in TypingMind en gebruik de tools in de chat of wijs ze toe aan een AI-agent.

  1. Open de pagina Plug-ins in TypingMind.
  2. Schakel de MCP-tools van Python Notebook MCP in.
  3. Start een chat en kies het AI-model dat je wilt gebruiken.
  4. Gebruik de MCP-tools in een chat of wijs ze toe aan een AI-agent.
  5. Schakel wanneer nodig over naar een ander AI-model zonder opnieuw verbinding te maken met MCP.
TypingMind-chat met ingeschakelde MCP-tools en een geselecteerd AI-model
Kun je Python Notebook MCP gebruiken om me hiermee te helpen?
Python Notebook MCP
Zeker. Ik heb het gelezen.
Dit vond ik met Python Notebook MCP.

Veelgestelde vragen

Waarvoor wordt de MCP-server Python Notebook MCP gebruikt?

Python Notebook MCP is een MCP-server waarmee compatibele AI-clients verbinding kunnen maken met externe tools en context. In TypingMind hoef je deze MCP-server maar één keer toe te voegen om de tools beschikbaar te maken in je AI-werkruimte.

Kan ik Python Notebook MCP MCP met meerdere AI-modellen in TypingMind gebruiken?

Ja. TypingMind verbindt MCP-tools op werkruimteniveau. Daardoor kun je Python Notebook MCP gebruiken met verschillende AI-modellen, zoals Claude, ChatGPT, Gemini of andere modellen die je in TypingMind hebt ingesteld, zonder de MCP-server voor elk model afzonderlijk in te stellen.

Waarom Python Notebook MCP MCP gebruiken met TypingMind?

TypingMind is een van de beste interfaces voor chats met LLM's, omdat het meerdere AI-modellen, prompts, plug-ins, AI-agenten, API-sleutels en MCP-tools samenbrengt in één werkruimte. Als Python Notebook MCP verbonden is, kun je de MCP-tools ervan gebruiken met je favoriete modellen en je chatworkflow overzichtelijk houden in TypingMind.

Hoe verbind ik Python Notebook MCP MCP met TypingMind?

Python Notebook MCP werkt via de lokale MCP-connector van TypingMind. Dit is de beste optie als de MCP-server toegang nodig heeft tot lokale bestanden, desktopapps, opdrachtregeltools of privébronnen op je computer.

Welke tools biedt Python Notebook MCP MCP in TypingMind?

Python Notebook MCP biedt MCP-functies die je kunt inschakelen via de pagina Plug-ins in TypingMind. Je kunt ze gebruiken in chats of toewijzen aan AI-agenten.

Moet ik mijn API-sleutels delen met TypingMind om Python Notebook MCP MCP te gebruiken?

Nee. TypingMind werkt in de eerste plaats lokaal en laat je de controle houden over je modelaanbieders, API-sleutels, prompts en MCP-configuratie. Als Python Notebook MCP authenticatie vereist, voeg je bij het maken van de verbinding de vereiste headers, OAuth-instellingen of lokale configuratie voor die MCP-server toe.

Gerelateerde MCP-servers

Toon alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇