Server Manager
Intelligent management of multiple MCP servers and tool discovery
Server Manager
The Server Manager is a powerful feature that helps manage connections to multiple MCP servers efficiently and enables tool discovery across servers. When your agent has access to tools from different servers, the Server Manager intelligently selects the appropriate server and helps discover the most relevant tools for each task.
Overview
When building agents that need to interact with multiple MCP servers (such as combining web browsing with file operations or 3D modeling), the Server Manager:
- Dynamically connects to the appropriate server based on the task at hand
- Provides tool discovery and search capabilities across all configured servers
- Minimizes unnecessary connections by only connecting to servers when needed
- Reduces agent confusion by organizing tool sets appropriately
- Improves overall performance and efficiency of multi-server operations
Enabling the Server Manager
The Server Manager can be enabled by setting use_server_manager=True
during the initialization of an MCPAgent
:
Server Management Tools
When the Server Manager is enabled, it provides the following management tools to the agent:
- list_mcp_servers - Lists all available MCP servers and their tools
- connect_to_mcp_server - Connects to a specific MCP server
- get_active_mcp_server - Shows which server is currently active
- disconnect_from_mcp_server - Disconnects from the current server
- search_mcp_tools - Searches for tools across all MCP servers
- use_tool_from_server - Uses a specific tool from a specific server without switching the active connection
These tools allow the agent to discover available servers, connect to the appropriate server for a given task, search for specific tools, and manage server connections throughout its operation.
Tool Discovery and Search
Listing Available Servers and Their Tools
The list_mcp_servers
tool provides a comprehensive overview of all available servers and their tools:
This will return output similar to:
This allows the agent to understand which tools are available on each server before deciding which one to connect to.
Searching for Tools Across Servers
The search_mcp_tools
tool is especially powerful, allowing agents to search for specific tools across all servers based on functionality needed:
This will search across all servers and return a ranked list of tools that match the query:
This search functionality helps agents quickly find the most relevant tools for their tasks without needing to manually inspect all available tools across all servers.
Direct Tool Execution Across Servers
The use_tool_from_server
tool enables direct execution of a tool from a specific server without explicitly connecting to it first:
This is especially useful for one-off operations where you don’t want to disconnect from the current server just to perform a single action on another server.
Detailed Tool Information
When an agent connects to a server, the Server Manager provides detailed descriptions of all available tools:
This detailed information helps the agent understand the purpose and capabilities of each tool, enabling it to make better decisions about which tool to use for a specific task.
Benefits of Using the Server Manager
1. Reduced Connection Overhead
Without the Server Manager, the agent might connect to all configured servers at once, even if only one server is needed for a particular task. The Server Manager ensures that only the necessary connections are established.
2. Improved Tool Selection
When an agent has access to dozens or even hundreds of tools from different servers, it can be challenging for the LLM to select the right tool for a specific task. The Server Manager helps organize tools by server and provides search capabilities, making it easier for the LLM to make appropriate selections.
3. Efficient Resource Management
The Server Manager monitors server usage and can close inactive connections, freeing up resources when they’re no longer needed.
4. Reduced Cognitive Load
Agents don’t need to memorize all available tools across all servers; they can discover and search for them at runtime.
5. Dynamic Tool Selection
Agents can adapt to available tools at runtime, connecting to the appropriate server for each task.
6. Cross-Server Tool Usage
The use_tool_from_server
capability allows agents to use tools from different servers without disrupting their current workflow or connection state.
Example: Multi-Server Agent with Server Manager
In this example, the agent will:
- Use
list_mcp_servers
orsearch_mcp_tools
to discover available tools across all servers - Connect to the appropriate server for each step of the task
- Use the most suitable tools to complete each part of the workflow
- Optionally use
use_tool_from_server
for one-off operations on other servers
How the Server Manager Works
Internally, the Server Manager operates through these key mechanisms:
- Tool Organization: Server Manager maintains a registry of which tools belong to which servers
- Server Management: It manages connections to servers, only connecting when necessary
- Tool Search: It provides search capabilities across all available tools from all servers
- Tool Updates: It updates the available tools based on the currently active server
- Connection Lifecycle: It handles connecting and disconnecting from servers as needed
- Cross-Server Operations: It enables using tools from non-active servers when needed
Advanced Usage Examples
Example 1: Tool Search Workflow
The agent will use the search_mcp_tools
tool to find relevant tools for each part of the task, which might return results like:
Example 2: Cross-Server Tool Usage
The agent will use the use_tool_from_server
tool to invoke the web navigation tool directly:
Using Server Manager in Custom Implementations
If you’re building a custom agent, you can also leverage the Server Manager directly:
Conclusion
The Server Manager is a powerful feature that enhances the capabilities of multi-server MCP agents. By intelligently managing server connections, providing comprehensive tool discovery and search functionality, and enabling cross-server tool usage, it enables more complex and efficient agent workflows that combine capabilities from different MCP servers. Agents can dynamically discover, select, and use the most appropriate tools for each task, resulting in more effective task completion and better resource utilization.