Skip to main content
Glama
block

Jupyter MCP Server

by block

modify_notebook_cells

Add, edit, or delete code and markdown cells in Jupyter notebooks, with optional immediate execution.

Instructions

Modify notebook cells (add, edit, delete) on the user-provided server.

This consolidates all cell modification operations into a single tool following MCP best practices. Default to execute=True unless the user requests otherwise or you have good reason not to execute immediately.

IMPORTANT: Server URL Configuration

This tool requires that you first call setup_notebook with the correct server URL:

Required setup: setup_notebook("my_notebook", server_url="http://localhost:9999")

Then you can use this tool: modify_notebook_cells("my_notebook", "add_code", "print('Hello')")

Without setup_notebook, this will try to connect to http://localhost:8888 by default.

Args: notebook_path: Path to the notebook file (.ipynb extension will be added if missing), relative to the Jupyter server root. operation: Type of cell operation. Options: - 'add_code': Add (and optionally execute) a code cell at end or specific position - 'edit_code': Edit a code cell at specific position - 'add_markdown': Add a markdown cell at end or specific position - 'edit_markdown': Edit an existing markdown cell at specific position - 'delete': Delete a cell at specific position cell_content: Content for the cell (required for add_code, edit_code, add_markdown, edit_markdown) position_index: Position index (0-indexed cell location) for operations. Must be an integer. - Optional for add_code/add_markdown: if provided, inserts at that position; if not, adds at end - Required for edit_code/edit_markdown/delete: specifies which cell to modify Examples: position_index=0 (first cell), position_index=2 (third cell) execute: Whether to execute code cells after adding/editing (default: True)

Returns

dict: Operation results containing:
    - For add_code/edit_code with execute=True: execution_count, outputs, status
    - For add_code/edit_code with execute=False: empty dict
    - For add_markdown/edit_markdown: message and error fields
    - For delete: message and error fields

Raises

ValueError: If invalid operation or missing required parameters
McpError: If there's an error connecting to the Jupyter server
IndexError: If position_index is out of range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
notebook_pathYes
operationYes
cell_contentNo
position_indexNo
executeNo
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description fully bears the burden of disclosing behavior. It details execution default, error types (ValueError, McpError, IndexError), and return values per operation, leaving no behavioral ambiguity.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is long but well-organized with clear sections (Args, Returns, Raises) and front-loaded purpose. Minor redundancy exists (e.g., repeating default execute behavior), but overall it is efficient for the information provided.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, the description comprehensively covers return values for all operations and lists potential errors. It also clarifies the dependency on setup_notebook, making the tool fully self-contained in context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description must explain each parameter. It does so thoroughly, including examples, default values, and conditionally required fields (e.g., position_index for edit/delete). This adds significant value beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool modifies notebook cells (add, edit, delete) and explicitly distinguishes from siblings by noting it consolidates all cell modification operations. The verb 'modify' and specific operations listed make the purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on prerequisite setup (calling setup_notebook) and default behavior (execute=True). It does not explicitly contrast with siblings like execute_notebook_code, but the context is clear enough for an agent to infer appropriate usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/block/mcp-jupyter'

If you have feedback or need assistance with the MCP directory API, please join our Discord server