genai-toolbox icon indicating copy to clipboard operation
genai-toolbox copied to clipboard

Proposal: Enabling MCP Toolbox for Databases as MCP Server

Open tuannvm opened this issue 6 months ago • 25 comments

Prerequisites

What are you trying to do that currently feels hard or impossible?

Overview

Currently, the MCP Toolbox for Databases acts solely as an MCP server, exposing tools to clients (such as IDEs or agent frameworks) via the MCP protocol. To maximize flexibility and composability, we propose extending the Toolbox to also function as an MCP client. This will allow it to dynamically connect to other MCP servers, aggregate their tools, and expose them as a unified toolset to its own clients. This dual role enables federated tool management, cross-organization sharing, and dynamic tool composition.

Suggested Solution(s)

Key Features

1. MCP Client Mode

  • Configurable MCP Servers: Administrators can specify a list of remote MCP servers (with endpoints and credentials) that the Toolbox should connect to as a client.
  • Dynamic Tool Loading: The Toolbox will periodically (or on-demand) fetch tool definitions from these remote MCP servers and merge them into its own tool registry.
  • Conflict Resolution: If tool names or IDs collide, configurable strategies (e.g., namespacing, override, or ignore) can be applied.

Sequence Diagram

Below is a sequence diagram illustrating the interaction when the Toolbox acts as both MCP client and server.

sequenceDiagram
participant Admin
participant Toolbox
participant MCP_A
participant MCP_B
participant Client
%% Admin configures Toolbox as MCP client
Admin->>Toolbox: Configure remote MCP servers (MCP_A, MCP_B)
%% Toolbox fetches tool lists from remote MCP servers
Toolbox->>MCP_A: Fetch tool list
Toolbox->>MCP_B: Fetch tool list
MCP_A-->>Toolbox: Return tool definitions (A1, A2)
MCP_B-->>Toolbox: Return tool definitions (B1, B2)
%% Toolbox merges local and remote tools
Toolbox->>Toolbox: Merge local and remote tools
%% Client requests available tools from Toolbox
Client->>Toolbox: List available tools
Toolbox-->>Client: Return unified tool list (Local, A1, A2, B1, B2)
%% Client invokes a remote tool via Toolbox
Client->>Toolbox: Invoke remote tool (A1)
Toolbox->>MCP_A: Proxy tool invocation (A1)
MCP_A-->>Toolbox: Return result
Toolbox-->>Client: Return result

Example Configuration

# tools.yaml
...
mcp_clients:
- name: remote-mcp-a
endpoint: https://mcp-a.example.com
api_key: "secret"
toolset: "default"
- name: remote-mcp-b
endpoint: https://mcp-b.example.com
api_key: "secret"
toolset: "analytics"
...

Benefits

  • Federation: Aggregate tools from multiple MCP servers, enabling cross-team or cross-org collaboration.
  • Dynamic Composition: Add or remove tool sources without redeploying clients.
  • Centralized Control: Administrators can curate which remote tools are exposed to local clients.
  • Scalability: Enables hierarchical or mesh-like MCP topologies for large organizations.

Implementation Considerations

  • Caching: Optionally cache remote tool definitions for performance and resilience.
  • Tool Invocation Routing: Clearly distinguish between local and remote tool invocations for logging and error handling.
  • Security: Ensure secure communication (TLS, authentication) between Toolbox and remote MCP servers.
  • Extensibility: Design the MCP client interface to support future protocols or authentication schemes.

tuannvm avatar Jun 15 '25 06:06 tuannvm