@@ -678,7 +678,7 @@ def __init__(
678678 normalized_tools : list [ToolProtocol | Callable [..., Any ] | MutableMapping [str , Any ]] = ( # type:ignore[reportUnknownVariableType]
679679 [] if tools_ is None else tools_ if isinstance (tools_ , list ) else [tools_ ] # type: ignore[list-item]
680680 )
681- self ._local_mcp_tools = [tool for tool in normalized_tools if isinstance (tool , MCPTool )]
681+ self .mcp_tools : list [ MCPTool ] = [tool for tool in normalized_tools if isinstance (tool , MCPTool )]
682682 agent_tools = [tool for tool in normalized_tools if not isinstance (tool , MCPTool )]
683683
684684 # Build chat options dict
@@ -720,7 +720,7 @@ async def __aenter__(self) -> "Self":
720720 Returns:
721721 The ChatAgent instance.
722722 """
723- for context_manager in chain ([self .chat_client ], self ._local_mcp_tools ):
723+ for context_manager in chain ([self .chat_client ], self .mcp_tools ):
724724 if isinstance (context_manager , AbstractAsyncContextManager ):
725725 await self ._async_exit_stack .enter_async_context (context_manager )
726726 return self
@@ -742,18 +742,6 @@ async def __aexit__(
742742 """
743743 await self ._async_exit_stack .aclose ()
744744
745- @property
746- def mcp_tools (self ) -> list ["MCPTool" ]:
747- """Get the list of MCP tools attached to this agent.
748-
749- MCP tools are stored separately from regular tools for lifecycle management.
750- Their functions are added to the tools list at runtime during run() or run_stream().
751-
752- Returns:
753- List of MCPTool instances attached to this agent.
754- """
755- return self ._local_mcp_tools
756-
757745 def _update_agent_name_and_description (self ) -> None :
758746 """Update the agent name in the chat client.
759747
@@ -829,7 +817,7 @@ async def run(
829817 else :
830818 final_tools .append (tool ) # type: ignore
831819
832- for mcp_server in self ._local_mcp_tools :
820+ for mcp_server in self .mcp_tools :
833821 if not mcp_server .is_connected :
834822 await self ._async_exit_stack .enter_async_context (mcp_server )
835823 final_tools .extend (mcp_server .functions )
@@ -956,7 +944,7 @@ async def run_stream(
956944 else :
957945 final_tools .append (tool )
958946
959- for mcp_server in self ._local_mcp_tools :
947+ for mcp_server in self .mcp_tools :
960948 if not mcp_server .is_connected :
961949 await self ._async_exit_stack .enter_async_context (mcp_server )
962950 final_tools .extend (mcp_server .functions )
0 commit comments