Skip to main content
Database tool functions powered by the googleapis/genai-toolbox MCP. Loads tools from the running MCP Toolbox for Databases server, which provides prebuilt tools for MSSQL and Neo4j, plus custom MongoDB tools defined in database_tools.yaml.

react_agent.custom_tools.mcp_database.modify_toolbox_sources

View Source Dynamically write database connection configurations to the MCP Toolbox settings file. Extracts connection strings (MSSQL, Neo4j, MongoDB) from the provided runtime Context, translates localhost URIs to Docker host gateway IPs (since the toolbox runs in Docker), and overwrites the custom_config.yaml used by the external MCP Database Toolbox. Arguments:
  • context Context - The agent’s runtime context containing database connection strings.
Raises:
  • Exception - If writing the configuration file fails.

react_agent.custom_tools.mcp_database.load_toolbox_tools

View Source Asynchronously connect to the MCP Toolbox for Databases and expose its tools. This context manager connects to the generic database MCP server (which provides schema inspection tools for SQL and Graph databases) and converts them into LangChain-compatible Tool objects for the ReAct agent. If the connection fails, it gracefully yields an empty list. Yields:
  • list[BaseTool] - A list of LangChain-compatible tool objects ready to be bound to an LLM.

react_agent.custom_tools.mcp_database.load_mongodb_tools

View Source Asynchronously connect to the MongoDB MCP server and expose its tools. This context manager establishes an SSE connection to a dedicated MongoDB MCP server. It registers the custom tools prefix to avoid naming collisions and converts the remote capabilities into LangChain Tool objects. Fails gracefully by yielding an empty list. Yields:
  • list[BaseTool] - A list of LangChain-compatible tool objects for MongoDB interactions.