Skip to content

Commit 38c9b9d

Browse files
authored
fix: more resilience on mcp-tools (#171)
1 parent 97ff24e commit 38c9b9d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

jupyter_mcp_server/jupyter_extension/handlers.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,23 +168,25 @@ async def post(self):
168168
search_query = ",".join(allowed_jupyter_tools)
169169
logger.info(f"Searching jupyter-mcp-tools with query: '{search_query}' (allowed_tools: {allowed_jupyter_tools})")
170170

171-
# Query for notebook-related tools with broader search term
171+
# Query for notebook-related tools with shorter timeout
172+
# Note: jupyter-mcp-tools requires JupyterLab frontend to load and register tools via WebSocket
172173
jupyter_tools_data = await get_tools(
173174
base_url=base_url,
174175
token=token,
175176
query=search_query,
176-
enabled_only=False
177+
enabled_only=False,
178+
wait_timeout=5 # Shorter timeout - if frontend isn't loaded, don't wait long
177179
)
178180
logger.info(f"Query returned {len(jupyter_tools_data)} tools")
179181

180182
# Use the tools directly since query should return only what we want
181183
for tool in jupyter_tools_data:
182184
logger.info(f"Found tool: {tool.get('id', '')}")
183185
except Exception as e:
184-
logger.warning(f"Failed to load jupyter-mcp-tools: {e}")
186+
logger.warning(f"Failed to load jupyter-mcp-tools (this is normal if JupyterLab frontend is not loaded): {e}")
185187
jupyter_tools_data = []
186188

187-
logger.info(f"Successfully loaded {len(jupyter_tools_data)} specific jupyter-mcp-tools")
189+
logger.info(f"Successfully loaded {len(jupyter_tools_data)} specific jupyter-mcp-tools (requires JupyterLab frontend)")
188190
else:
189191
# JupyterLab mode disabled, don't load any jupyter-mcp-tools
190192
jupyter_tools_data = []

0 commit comments

Comments
 (0)