MCPTools
functionality to filter tools by toolset or tool name, allowing agents to load only the specific database tools they need.
Prerequisites
You’ll need the following to use MCPToolbox:Quick Start
Get started with MCPToolbox instantly using our fully functional demo.Verification
To verify that your docker/podman setup is working correctly, you can check the database connection:Basic Example
Here’s the simplest way to use MCPToolbox (after running the Quick Start setup):How MCPToolbox Works
MCPToolbox solves the tool overload problem. Without filtering, your agent gets overwhelmed with too many database tools: Without MCPToolbox (50+ tools):- MCP Toolbox Server exposes 50+ database tools
- MCPToolbox connects and loads ALL tools internally
- Filters to only the
hotel-management
toolset (3 tools) - Agent sees only the 3 relevant tools and stays focused
Advanced Usage
Multiple Toolsets
Load tools from multiple related toolsets:cookbook/tools/mcp/mcp_toolbox_for_db.py
Custom Authentication and Parameters
For production scenarios with authentication:Manual Connection Management
For explicit control over connections:Toolkit Params
Parameter | Type | Default | Description |
---|---|---|---|
url | str | - | Base URL for the toolbox service (automatically appends “/mcp” if missing) |
toolsets | Optional[List[str]] | None | List of toolset names to filter tools by. Cannot be used with tool_name . |
tool_name | Optional[str] | None | Single tool name to load. Cannot be used with toolsets . |
headers | Optional[Dict[str, Any]] | None | HTTP headers for toolbox client requests |
transport | str | "streamable-http" | MCP transport protocol. Options: "stdio" , "sse" , "streamable-http" |
Only one of
toolsets
or tool_name
can be specified. The implementation validates this and raises a ValueError
if both are provided.Toolkit Functions
Function | Description |
---|---|
async connect() | Initialize and connect to both MCP server and toolbox client |
async load_tool(tool_name, auth_token_getters={}, bound_params={}) | Load a single tool by name with optional authentication |
async load_toolset(toolset_name, auth_token_getters={}, bound_params={}, strict=False) | Load all tools from a specific toolset |
async load_multiple_toolsets(toolset_names, auth_token_getters={}, bound_params={}, strict=False) | Load tools from multiple toolsets |
async load_toolset_safe(toolset_name) | Safely load a toolset and return tool names for error handling |
get_client() | Get the underlying ToolboxClient instance |
async close() | Close both toolbox client and MCP client connections |
Demo Examples
The complete demo includes multiple working patterns:- Basic Agent: Simple hotel assistant with toolset filtering
- AgentOS Integration: Integration with AgentOS control plane
- Workflow Integration: Using MCPToolbox in Agno workflows
- Type-Safe Agent: Implementation with Pydantic models
include_tools
or exclude_tools
to modify the list of tools the agent has access to. Learn more about selecting tools.