MCP Toolbox for Databases

repository·main·Indexed 10 days ago

https://github.com/googleapis/mcp-toolbox

An open-source Model Context Protocol (MCP) server that bridges AI agents and IDEs with enterprise databases. It provides prebuilt tools for instant database access and a configuration-driven framework via tools.yaml to develop custom, secure database tools. Supports Google Cloud services (AlloyDB, BigQuery, Cloud SQL, Spanner, Firestore) as well as PostgreSQL, MySQL, MongoDB, Redis, and Snowflake.

Tokens
463.4K
Snippets
1.2K
Records
1.8K
Agent score
93%

What's inside MCP Toolbox

  1. Overview of Toolbox Client SDKs

    main

    The Toolbox Client SDKs allow you to integrate the MCP Toolbox directly into custom applications and AI agents. They handle the underlying Model Context Protocol (MCP) communication, enabling your application to dynamically request tools, bind parameters, add authentication, and execute commands at runtime.

    Supported languages and integrations include:

    • Python: Core SDK with native integrations for LangChain, LlamaIndex, and the ADK.
    • JavaScript / TypeScript: Node.js Core SDK with integrations for the Agent Development Kit (ADK).
    • Go: Core SDK with dedicated packages for Genkit (tbgenkit) and the ADK.
  2. What is MCP Toolbox for Databases?

    main

    MCP Toolbox for Databases is an open-source Model Context Protocol (MCP) server that connects AI agents, IDEs, and applications to enterprise databases. It serves two primary purposes:

    1. Ready-to-use MCP Server (Build-Time): Provides prebuilt generic tools (like list_tables or execute_sql) to instantly connect MCP clients (e.g., Gemini CLI, Claude Code, Google Antigravity) to your databases for schema exploration and data querying.
    2. Custom Tools Framework (Run-Time): A framework for building specialized, secure AI tools. You can define structured queries, semantic search, and NL2SQL capabilities using a configuration-driven approach.

    It supports a wide range of databases including Google Cloud services (AlloyDB, BigQuery, Cloud SQL, Spanner, Firestore) and others like PostgreSQL, MySQL, MongoDB, Redis, and Snowflake.

  3. Overview of the MCP Toolbox Java SDK

    main

    The MCP Toolbox Java SDKs act as clients for the MCP Toolbox service. They allow Java applications or AI orchestration frameworks to interact with tools (such as API connectors and database query tools) managed by an MCP Toolbox instance.

    Key capabilities include:

    • Fetching tool definitions from a running MCP Toolbox instance.
    • Providing Java objects or functions that represent those tools.
    • Invoking tools to call underlying APIs or services.
    • Managing authentication and parameter binding.
  4. Postgres Tools for Cloud SQL

    main
    The Cloud SQL Postgres integration provides a set of prebuilt tools designed to allow MCP-compatible agents to interact with PostgreSQL databases. These tools are sourced from the /integrations/postgres/tools definition and are intended to be used within the MCP Toolbox ecosystem to enable database querying, schema inspection, and management capabilities for AI agents.
  5. Understand the MCP Toolbox issue lifecycle

    main

    The MCP Toolbox project follows a structured pipeline for managing bugs and feature requests from initial report to final release:

    1. Identify Issue: An issue is opened in a GitHub repository.
    2. Triage: A team member acknowledges the issue, verifies reproducibility, and applies appropriate labels (Priority, Type, Product).
    3. Resolution: The issue is assigned to a developer for implementation or a fix.
    4. Review & Merge: The Pull Request (PR) undergoes review. Once approved and checks pass, a maintainer merges it.
    5. Release: Merged changes are bundled into a versioned release and published.
  6. Use the yugabytedb-sql tool

    main

    The yugabytedb-sql tool type allows you to execute pre-defined SQL statements against a YugabyteDB database. It supports two ways of handling dynamic data:

    1. Parameterized Queries (Recommended): The SQL statement is executed as a prepared statement. Parameters are inserted based on their position using $1, $2, etc. This method is secure against SQL injection and is recommended for performance and safety.
    2. Template Parameters: These are resolved before the prepared statement is executed. This allows you to dynamically change identifiers like table names or column names, but it makes the tool vulnerable to SQL injection. Use this only when necessary.

    Important Security Note: Parameters cannot be used as substitutes for identifiers, column names, or table names; for those, you must use templateParameters.

    # Example of a secure parameterized query
    kind: tool
    name: search_flights_by_number
    type: yugabytedb-sql
    source: my-yb-instance
    statement: |
      SELECT * FROM flights
      WHERE airline = $1
      AND flight_number = $2
      LIMIT 10
    parameters:
      - name: airline
        type: string
      - name: flight_number
        type: string
  7. Choose between Pure Go and OCI-based Oracle drivers

    main

    The Oracle source supports two different drivers depending on your feature requirements and environment capabilities:

    1. Pure Go Driver (useOCI: false, default)

    • Library: go-ora.
    • Pros: Simple setup; no local Oracle software installation required.
    • Cons: Does not support advanced features like Oracle Wallets or Kerberos authentication.
    • Wallet Support: Use the walletLocation field to specify the directory containing wallet files.

    2. OCI-Based Driver (useOCI: true)

    • Library: godror.
    • Pros: Supports advanced features like Digital Wallet and Kerberos.
    • Cons: Requires the Oracle Instant Client libraries to be installed on the host machine.
    • Wallet Support: Triggered by setting tnsAdmin to the wallet directory and connecting via a tnsAlias.
  8. Use dynamic command parameters in Valkey tools

    main

    You can template command arguments using the $variableName syntax. When a parameter is defined with type: array, the toolbox will expand the array into multiple individual arguments during execution (flattening).

    commands:
      - [SADD, userNames, $userNames]
    parameters:
      - name: userNames
        type: array
        description: The user names to be set.

    Example expansion:

    If input is ["Alice", "Sid", "Bob"],

    the executed command becomes: [SADD, userNames, Alice, Sid, Bob]

  9. Configure Networking for AlloyDB Sources

    main

    AlloyDB supports connections via both public and private networks. You must configure the ipType parameter in your source configuration to match your cluster's setup:

    • public: For connecting over the internet via a public IP.
    • private: For connecting via an internal network (private IP).

    Note: Regardless of the ipType selected, all connections are encrypted with mTLS and use IAM-based authorization.

  10. Authenticate with Cloud SQL for MySQL

    main

    The Cloud SQL for MySQL source supports two authentication methods:

    Standard Authentication

    Use a standard MySQL user and password. Provide the user and password fields in your configuration.

    IAM Authentication

    Uses Application Default Credentials (ADC) and the Cloud SQL Go Connector to establish mTLS connections.

    1. Ensure your database instance and user are prepared for IAM logins.
    2. To authenticate, either:
      • Specify your IAM email as the user.
      • Leave the user field blank (Toolbox will automatically fetch the email from your ADC).
    3. Leave the password field blank.
  11. What are Prompts in MCP Toolbox?

    main

    A prompt is a reusable template for a message or a series of messages designed to be sent to a Large Language Model (LLM). The Toolbox server implements the Model Context Protocol (MCP) prompts/list and prompts/get methods, allowing MCP clients to discover and retrieve these templates.

    To organize prompts, you can use Groups. When connecting to a specific group's endpoint, prompts/list will only return the prompts belonging to that group. The default endpoint returns all available prompts.

    kind: prompt
    name: code_review
    description: "Asks the LLM to analyze code quality and suggest improvements."
    messages:
      - content: "Please review the following code for quality, correctness, and potential improvements: \n\n{{.code}}"
    arguments:
      - name: "code"
        description: "The code to review"