Initialize earlier
This still does not avoid that we get the error notifications/initialized is not allowed.
This commit is contained in:
parent
c96cc26939
commit
0a5c29c1ce
|
|
@ -238,7 +238,11 @@ class MCPBrowser:
|
||||||
# Initialize if needed for other requests
|
# Initialize if needed for other requests
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
await self.initialize()
|
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
|
# Check if this is a virtual tool call
|
||||||
if jsonrpc_object.get("method") == "tools/call":
|
if jsonrpc_object.get("method") == "tools/call":
|
||||||
tool_name = jsonrpc_object.get("params", {}).get("name")
|
tool_name = jsonrpc_object.get("params", {}).get("name")
|
||||||
|
|
@ -457,6 +461,17 @@ class MCPBrowser:
|
||||||
existing_tools = self.registry.raw_tool_list
|
existing_tools = self.registry.raw_tool_list
|
||||||
self.registry.update_tools(existing_tools + builtin_tools)
|
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):
|
def _handle_server_message(self, message: dict):
|
||||||
"""Handle incoming message from MCP server."""
|
"""Handle incoming message from MCP server."""
|
||||||
# Apply incoming filter
|
# Apply incoming filter
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue