tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Agentic AI > MCP Protocol > MCP Tool Discovery and Dynamic Tool Loading

MCP Tool Discovery and Dynamic Tool Loading

Author: Venkata Sudhakar

MCPToolset loads all tools from a server by default. But in large deployments an MCP server might expose dozens of tools, and an agent only needs a subset. Loading all tools increases the context window and can confuse the model into choosing the wrong tool. Dynamic tool loading lets you inspect the available tools after connection and filter down to exactly what the agent needs before constructing it.

MCPToolset.from_server() returns the full tool list. You can inspect each tool by name and description, then pass only the filtered subset to the agent. This is also useful for role-based access: a read-only analyst agent gets query tools, while a write-enabled operations agent gets mutation tools from the same MCP server.

The below example shows a ShopMax India MCP server with both read and write tools, and two ADK agents that each load only their permitted subset.


Now connect agents with dynamic tool filtering by role,


It gives the following output,

[analyst] Loaded tools: ['list_orders', 'get_order']
[operations] Loaded tools: ['list_orders', 'get_order', 'update_order_status', 'cancel_order']

[shopmax_analyst] Current orders:
1. ORD-001 - Priya, Laptop - Status: Pending
2. ORD-002 - Arjun, TV - Status: Shipped

[shopmax_operations] Order ORD-001 has been updated to Delivered successfully.

Tool discovery at runtime also lets you build adaptive agents that inspect what a new MCP server offers before deciding how to use it. Print the tool names and descriptions after connection during development to understand what the server exposes. In production, cache the tool list after the first discovery rather than re-fetching on every agent startup. Use consistent tool naming conventions across your MCP servers - prefix read tools with get_ or list_, and write tools with create_, update_, or delete_ - so role-based filtering remains simple and reliable.


 
  


  
bl  br