From 78c7d055cc1612af518ba18c1ef6e20caaddabec Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Fri, 24 Oct 2025 19:27:29 +0200 Subject: [PATCH 1/3] Expose tools via the `jupyter_server_mcp` entrypoints --- README.md | 37 +++++++++++++++++++++++++++- jupyterlab_commands_toolkit/tools.py | 6 +++++ pyproject.toml | 6 +++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d311a97..e1a128f 100644 --- a/README.md +++ b/README.md @@ -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 @@ -25,9 +26,43 @@ 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 + +For more configuration options and examples, see: +- The included [jupyter_config_mcp_example.py](jupyter_config_mcp_example.py) file +- The [jupyter-server-mcp documentation](https://github.com/jupyter-ai-contrib/jupyter-server-mcp#readme) + +### Direct Python Usage + +Use the toolkit directly from Python to execute JupyterLab commands: ```python import asyncio diff --git a/jupyterlab_commands_toolkit/tools.py b/jupyterlab_commands_toolkit/tools.py index e229eb7..ae3b3e1 100644 --- a/jupyterlab_commands_toolkit/tools.py +++ b/jupyterlab_commands_toolkit/tools.py @@ -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): """ diff --git a/pyproject.toml b/pyproject.toml index 114515d..e35aa84 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" From 4898da948a6fb94c3bcd36a431e94ef5a1e7682b Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Fri, 24 Oct 2025 19:30:35 +0200 Subject: [PATCH 2/3] fix readme --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index e1a128f..a3f0090 100644 --- a/README.md +++ b/README.md @@ -56,10 +56,6 @@ 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 -For more configuration options and examples, see: -- The included [jupyter_config_mcp_example.py](jupyter_config_mcp_example.py) file -- The [jupyter-server-mcp documentation](https://github.com/jupyter-ai-contrib/jupyter-server-mcp#readme) - ### Direct Python Usage Use the toolkit directly from Python to execute JupyterLab commands: From 3d4cac5e734b583212b1665a06673763b74b4012 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Fri, 24 Oct 2025 19:32:50 +0200 Subject: [PATCH 3/3] lint --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a3f0090..ca74a27 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ 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