Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ for the frontend extension.

- **Command Discovery**: List all available JupyterLab commands with their metadata
- **Command Execution**: Execute any JupyterLab command programmatically from Python
- **MCP Integration**: Automatically exposes tools to AI assistants via [jupyter-server-mcp](https://github.com/jupyter-ai-contrib/jupyter-server-mcp)

## Requirements

Expand All @@ -25,9 +26,40 @@ To install the extension, execute:
pip install jupyterlab_commands_toolkit
```

To install with `jupyter-server-mcp` integration support:

```bash
pip install jupyterlab_commands_toolkit[mcp]
```

## Usage

Use the toolkit to execute any JupyterLab command from Python:
### With jupyter-server-mcp (Recommended)

This extension automatically registers its tools with [jupyter-server-mcp](https://github.com/jupyter-ai-contrib/jupyter-server-mcp) via Python entrypoints, making them available to AI assistants and other MCP clients.

1. Install both packages:

```bash
pip install jupyterlab_commands_toolkit[mcp]
```

2. Start Jupyter Lab (the MCP server starts automatically):

```bash
jupyter lab
```

3. Configure your MCP client (e.g., Claude Desktop) to connect to `http://localhost:3001/mcp`

The following tools will be automatically available:

- `list_all_commands` - List all available JupyterLab commands with their metadata
- `execute_command` - Execute any JupyterLab command programmatically

### Direct Python Usage

Use the toolkit directly from Python to execute JupyterLab commands:

```python
import asyncio
Expand Down
6 changes: 6 additions & 0 deletions jupyterlab_commands_toolkit/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
# Store for pending command results
pending_requests: Dict[str, Dict[str, Any]] = {}

# Tools list for jupyter-server-mcp entrypoint discovery
TOOLS = [
"jupyterlab_commands_toolkit.tools:list_all_commands",
"jupyterlab_commands_toolkit.tools:execute_command",
]


def emit(data, wait_for_result=False):
"""
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ dependencies = [
]
dynamic = ["version", "description", "authors", "urls", "keywords"]

[project.optional-dependencies]
mcp = ["jupyter-server-mcp>=0.1.2"]

[project.entry-points."jupyter_server_mcp.tools"]
jupyterlab_commands_toolkit = "jupyterlab_commands_toolkit.tools:TOOLS"

[tool.hatch.version]
source = "nodejs"

Expand Down