Initialize earlier

This still does not avoid that we get the error
notifications/initialized is not allowed.
This commit is contained in:
Andre Heinecke 2025-10-11 12:30:39 +02:00
parent c96cc26939
commit 0a5c29c1ce
No known key found for this signature in database
GPG Key ID: 4312127CF596D25D
1 changed files with 17 additions and 2 deletions

View File

@ -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