@@ -62,6 +62,7 @@ async def test_start_extension_success(self):
6262 with patch ("jupyter_server_mcp.extension.MCPServer" ) as mock_mcp_class :
6363 mock_server = Mock ()
6464 mock_server .start_server = AsyncMock ()
65+ mock_server ._registered_tools = [] # Use list instead of Mock
6566 mock_mcp_class .return_value = mock_server
6667
6768 await extension .start_extension ()
@@ -152,6 +153,7 @@ async def test_full_lifecycle(self):
152153 with patch ("jupyter_server_mcp.extension.MCPServer" ) as mock_mcp_class :
153154 mock_server = Mock ()
154155 mock_server .start_server = AsyncMock ()
156+ mock_server ._registered_tools = [] # Use list instead of Mock
155157 mock_mcp_class .return_value = mock_server
156158
157159 # Start extension
@@ -253,7 +255,7 @@ def test_register_configured_tools_empty(self):
253255 extension .mcp_tools = []
254256
255257 # Should not call register_tool
256- extension ._register_configured_tools ( )
258+ extension ._register_tools ( extension . mcp_tools , source = "configuration" )
257259 extension .mcp_server_instance .register_tool .assert_not_called ()
258260
259261 def test_register_configured_tools_valid (self ):
@@ -264,15 +266,15 @@ def test_register_configured_tools_valid(self):
264266
265267 # Capture log output
266268 with patch ("jupyter_server_mcp.extension.logger" ) as mock_logger :
267- extension ._register_configured_tools ( )
269+ extension ._register_tools ( extension . mcp_tools , source = "configuration" )
268270
269271 # Should register both tools
270272 assert extension .mcp_server_instance .register_tool .call_count == 2
271273
272274 # Check log messages
273- mock_logger .info .assert_any_call ("Registering 2 configured tools" )
274- mock_logger .info .assert_any_call ("✅ Registered tool: os:getcwd" )
275- mock_logger .info .assert_any_call ("✅ Registered tool: math:sqrt" )
275+ mock_logger .info .assert_any_call ("Registering 2 tools from configuration " )
276+ mock_logger .info .assert_any_call ("✅ Registered tool from configuration : os:getcwd" )
277+ mock_logger .info .assert_any_call ("✅ Registered tool from configuration : math:sqrt" )
276278
277279 def test_register_configured_tools_with_errors (self ):
278280 """Test registering tools when some fail to load."""
@@ -281,14 +283,14 @@ def test_register_configured_tools_with_errors(self):
281283 extension .mcp_tools = ["os:getcwd" , "invalid:function" , "math:sqrt" ]
282284
283285 with patch ("jupyter_server_mcp.extension.logger" ) as mock_logger :
284- extension ._register_configured_tools ( )
286+ extension ._register_tools ( extension . mcp_tools , source = "configuration" )
285287
286288 # Should register 2 valid tools (os:getcwd and math:sqrt)
287289 assert extension .mcp_server_instance .register_tool .call_count == 2
288290
289291 # Check error logging
290292 mock_logger .error .assert_any_call (
291- "❌ Failed to register tool 'invalid:function': "
293+ "❌ Failed to register tool 'invalid:function' from configuration : "
292294 "Could not import module 'invalid': No module named 'invalid'"
293295 )
294296
0 commit comments