Tools
MCP-based tools for Jupyter notebook operations.
These tools are available in both the UI and CLI.
MCP Integrationโ
Jupyter MCP Server starts automatically as a Jupyter server extension, providing seamless access to Jupyter operations.
More tools can be added by connecting to additional MCP servers, see the MCP Agent Runtimes documentation for details.
What is MCP?โ
Model Context Protocol - Standardized interface for AI agent tools:
- Standardized Definitions: Clear schemas and descriptions
- Type Safety: Input validation and type checking
- Extensibility: Easy custom tool integration
- Discoverability: Automatic tool discovery
Available Toolsโ
Notebook Operationsโ
Create Notebook
- Create new notebooks with specified names
- Initialize with default or custom content
- Set kernel and metadata
Read Notebook
- Retrieve notebook content and structure
- Access cell sources and outputs
- Query notebook metadata
List Notebooks
- Enumerate notebooks in workspace
- Filter by path or pattern
- Get notebook metadata
Cell Operationsโ
Add Code Cell
- Add a new code cell at the end of the notebook
- Optionally execute the cell after adding
- Set cell metadata and tags
Insert Code Cell
- Insert a code cell at a specific position (index)
- Execute after insertion if requested
- Preserve existing cell order
Add Markdown Cell
- Add formatted markdown cells for documentation
- Support for headings, lists, code blocks, etc.
- Rich text formatting capabilities
Insert Markdown Cell
- Insert markdown at specific positions
- Update documentation inline with code
- Maintain notebook narrative structure
Modify Cell (Planned)
- Edit existing code cells to fix errors
- Update markdown cells for improved documentation
- Refactor code for better quality
Delete Cell (Planned)
- Remove cells by index or criteria
- Clean up experimental or outdated code
- Maintain notebook organization
Code Executionโ
Execute Code
- Run Python code in the notebook kernel
- Capture outputs, errors, and display data
- Support for async execution
Execute Cell
- Execute specific cells by index
- Get execution results and outputs
- Handle execution errors gracefully
Execute All (Planned)
- Run entire notebook from top to bottom
- Track execution progress
- Generate execution reports
File Operationsโ
List Files
- List files and directories in workspace
- Filter by extension or pattern
- Get file metadata (size, modified date)
Read File
- Read file contents
- Support for various file formats
- Binary and text file handling
Write File
- Create or update files
- Save generated data or reports
- Manage workspace artifacts
Delete File (Planned)
- Remove files from workspace
- Clean up temporary files
- Organize project structure
Kernel Managementโ
List Kernels
- Enumerate available kernels
- Get kernel specifications and capabilities
- Check kernel status
Start Kernel (Planned)
- Launch new kernel instances
- Configure kernel parameters
- Manage kernel lifecycle
Stop Kernel (Planned)
- Shutdown kernel instances
- Clean up kernel resources
- Handle kernel errors
Tool Executionโ
In UIโ
Conversational interface executes tools automatically:
- User provides instruction: "Create a new notebook with pandas import"
- Agent selects tools:
create_notebook,add_code_cell - Tool execution: Runs with appropriate parameters
- Visual feedback: Shows tool status in UI
- Results display: Presents confirmation
In CLIโ
CLI tools invoke MCP tools programmatically:
# The CLI agent uses MCP tools behind the scenes
jupyter-ai-agent create-notebook analysis.ipynb --with-imports pandas,numpy
Tool Execution Modesโ
Frontend Execution (Browser)
- Tools that modify UI elements
- Real-time visual feedback
- Direct DOM manipulation
Backend Execution (Jupyter Server)
- Tools that modify notebooks/files
- Kernel execution and management
- Persistent state changes
Custom Toolsโ
You can add custom tools to extend agent capabilities:
Using Pydantic AIโ
from pydantic_ai import Agent
agent = Agent(model='anthropic:claude-sonnet-4-5')
@agent.tool
def analyze_dataset(file_path: str) -> dict:
"""
Analyze a dataset and return summary statistics.
Args:
file_path: Path to the dataset file
Returns:
Dictionary containing summary statistics
"""
import pandas as pd
df = pd.read_csv(file_path)
return {
'rows': len(df),
'columns': list(df.columns),
'dtypes': df.dtypes.to_dict()
}
Creating MCP Toolsโ
from mcp.server import Server
from mcp.types import Tool
server = Server("custom-tools")
@server.tool()
async def custom_operation(param: str) -> str:
"""Custom tool description."""
# Tool implementation
return f"Processed: {param}"
Tool Discoveryโ
The agent automatically discovers available tools from:
- Jupyter MCP Server: Default tools for notebook operations
- Custom MCP Servers: User-configured additional servers
- Built-in Tools: Agent-specific utilities
- Agent Tools: Tools defined directly on the agent
Best Practicesโ
Tool Designโ
- Clear Descriptions: Write detailed tool descriptions for agent understanding
- Type Safety: Use Pydantic models for parameter validation
- Error Handling: Provide informative error messages
- Idempotency: Design tools to be safely retried
Tool Usageโ
- Minimal Operations: Each tool should do one thing well
- Composability: Combine tools for complex operations
- State Management: Handle state consistently
- Performance: Optimize for common operations
Planned Toolsโ
We're actively developing new tools:
- ๐ง Cell Modification: Edit existing cells (code and markdown)
- ๐๏ธ Cell Deletion: Remove cells by index or criteria
- โถ๏ธ Execute All: Run entire notebooks
- ๐๏ธ Kernel Control: Start, stop, restart kernels
- ๐ Data Analysis: Built-in data profiling and visualization
- ๐ Search: Search across notebooks and files
- ๐ Templates: Generate notebooks from templates
- ๐งช Testing: Execute tests and validate outputs
MCP Server Configurationโ
Future versions will support configuring additional MCP servers through a UI:
- Connect to specialized MCP servers (web search, databases, APIs)
- Configure server authentication and endpoints
- Enable/disable specific tools
- Set tool permissions and restrictions