Repository navigation
fix(tools/list): initialize the server mode before choosing which tools to list - #482
Merged
echarles merged 2 commits intoOct 5, 2026
Merged
Conversation
…ls to list get_registered_tools() read ServerContext._mode, which is None until initialize() runs. On a freshly started Jupyter extension, REST GET /mcp/tools/list was answered as if in MCP_SERVER mode and listed connect_to_jupyter, until a JSON-RPC request initialized the context. Read the .mode property instead, which initializes on first use. Fixes datalayer#481 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Could a maintainer add the |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
echarles
reviewed
Oct 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #481.
get_registered_tools()readServerContext._mode, which staysNoneuntilinitialize()runs. On a freshly started Jupyter extension, the first RESTGET /mcp/tools/listtherefore took theMCP_SERVERbranch and listedconnect_to_jupyter. That lasted until a JSON-RPC request on/mcpinitialized the context. The fix reads the.modeproperty instead, which initializes on first use.This is one line in
server.py. The JSON-RPC handler'scontext.initialize(); mode = context._modealready behaves correctly, so I left it alone.Testing
tests/test_registered_tools_initializes_mode.py: starts from an uninitializedServerContextinside a stubbed local-document extension, and checks thatget_registered_tools()resolvesJUPYTER_SERVERmode and leaves outconnect_to_jupyter. It fails onmain(assert None == ServerMode.JUPYTER_SERVER) and passes with the fix.test_allowed_jupyter_mcp_tools.pyandtest_capabilities.pystill pass (42 passed with the new test).document_url=local,code_sandbox_url=local): the firstGET /mcp/tools/listnow returns 21 tools withoutconnect_to_jupyter. Before the fix it returned 22.🤖 Generated with Claude Code