@@ -358,6 +358,7 @@ async def get_tools(
358358 Returns:
359359 List[BaseTool]: A list of tools available under the specified context.
360360 """
361+
361362 if self ._use_isolated_event_loop :
362363 # Discover tools via an isolated thread to avoid the anyio CancelScope
363364 # cross-task error on Vertex AI Agent Engine.
@@ -373,6 +374,9 @@ async def get_tools(
373374 if provider_headers :
374375 headers .update (provider_headers )
375376
377+ assert isinstance (
378+ self ._connection_params , StreamableHTTPConnectionParams
379+ )
376380 raw_tools = await asyncio .to_thread (
377381 list_tools_in_thread ,
378382 self ._connection_params .url ,
@@ -389,12 +393,15 @@ async def get_tools(
389393 header_provider = self ._header_provider ,
390394 use_isolated_event_loop = True ,
391395 )
392- if self ._is_tool_selected (mcp_tool , readonly_context ):
396+ if readonly_context is None or self ._is_tool_selected (
397+ mcp_tool , readonly_context
398+ ):
393399 tools .append (mcp_tool )
394400 if self ._use_mcp_resources :
395401 tools .append (LoadMcpResourceTool (mcp_toolset = self ))
402+ if self ._use_mcp_resources :
403+ tools .append (LoadMcpResourceTool (mcp_toolset = self ))
396404 return tools
397-
398405 # Fetch available tools from the MCP server
399406 tools_response : ListToolsResult = await self ._execute_with_session (
400407 lambda session : session .list_tools (),
0 commit comments