From 0a5c29c1ced0780595d923dd1f2c9532251c64b7 Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Sat, 11 Oct 2025 12:30:39 +0200 Subject: [PATCH] Initialize earlier This still does not avoid that we get the error notifications/initialized is not allowed. --- mcp_browser/proxy.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/mcp_browser/proxy.py b/mcp_browser/proxy.py index 79e2ba6..66c1513 100644 --- a/mcp_browser/proxy.py +++ b/mcp_browser/proxy.py @@ -238,7 +238,11 @@ class MCPBrowser: # Initialize if needed for other requests if not self._initialized: await self.initialize() - + # After initalization we MUST return notfications iniitialized + return { + "jsonrpc": "2.0", + "method": "notifications/initialized" + } # Check if this is a virtual tool call if jsonrpc_object.get("method") == "tools/call": tool_name = jsonrpc_object.get("params", {}).get("name") @@ -456,7 +460,18 @@ class MCPBrowser: # Add to registry without going through filter existing_tools = self.registry.raw_tool_list self.registry.update_tools(existing_tools + builtin_tools) - + + # Send initialize request directly to server + init_response = await self.server.send_request("initialize", { + "protocolVersion": "2024-11-05", + "capabilities": {}, + "clientInfo": { + "name": "mcp-browser", + "version": "0.1.0" + } + }) + + def _handle_server_message(self, message: dict): """Handle incoming message from MCP server.""" # Apply incoming filter