Loomal

MCP Toolbox for Databases in LangChain governed SQL tools for your Python agents.

Connect Google's MCP Toolbox for Databases to a LangChain agent through langchain-mcp-adapters. Because the Toolbox serves MCP over HTTP natively, the cleanest wiring is a running container plus a URL — no subprocess management in your agent code.

MCP Toolbox for Databases (github.com/googleapis/genai-toolbox, 15.5k stars) is Google's open-source MCP server for database access. Sources and tools are declared in a tools.yaml — named, parameterized queries against engines including PostgreSQL, MySQL, SQL Server, BigQuery, and Spanner — so a LangChain agent gets a vetted query vocabulary instead of a raw SQL executor.

LangChain has no MCP config file; servers are declared in code. Install langchain-mcp-adapters, describe the Toolbox to MultiServerMCPClient, and get_tools() hands back LangChain-native tools your agent can bind like any others.

Run the Toolbox as a service

The Toolbox ships as an OCI container image and speaks MCP over HTTP out of the box, which fits LangChain deployments well: one long-running container, many agent processes connecting to it. Start it with your tools.yaml mounted, the listen address opened up for Docker's port mapping, and port 5000 published:

docker run -d -p 5000:5000 -v /abs/path/tools.yaml:/config/tools.yaml us-central1-docker.pkg.dev/database-toolbox/toolbox/toolbox:latest --tools-file /config/tools.yaml --address 0.0.0.0

Connect from your agent code

With the container up, the LangChain side is a transport, a URL, and a get_tools() call. pip install langchain-mcp-adapters first.

agent.py
# pip install langchain-mcp-adapters langgraph
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent

client = MultiServerMCPClient({
    "toolbox": {
        "transport": "streamable_http",
        "url": "http://localhost:5000/mcp",
    }
})

tools = await client.get_tools()
agent = create_react_agent("anthropic:claude-sonnet-4-5", tools)

Why this beats a raw SQL tool

It's tempting to hand a LangChain agent a generic run_sql function. The Toolbox's design is the safer trade: every tool is a fixed, parameterized statement you wrote, so the model chooses which query to run and with what parameters — never what SQL to compose. For production agents touching real data, that distinction is the difference between an audit log you can read and one you fear.

Troubleshooting in LangChain

Connection refused from get_tools() means the container isn't listening where you think. Check docker ps for the port mapping, and confirm you started the Toolbox with --address 0.0.0.0 — its default loopback bind isn't reachable through Docker's port forwarding. If your agent code itself runs inside a container, localhost is the wrong host: use host.docker.internal or a shared Docker network.

An empty tools list with a healthy connection points at tools.yaml: run docker logs on the container and the Toolbox's startup output says which tool definitions loaded and which failed validation. Database connection errors surface the same way. There's nothing to restart on the LangChain side — fix the container, re-run your script. And get_tools() is async; awaiting it outside an event loop is a Python error, not an MCP one.

The live listing

You can see the Toolbox's live-probed tool surface on its Loomal marketplace listing at https://loomal.ai/marketplace/mcp-toolbox-for-databases. If you operate your own MCP server, claiming its listing on Loomal verifies ownership and lets you publish per-call pricing that agent frameworks like LangChain can transact against over x402.

FAQ

How do I install the Toolbox for Databases in LangChain?

Run the Toolbox container with your tools.yaml mounted and port 5000 published, then install langchain-mcp-adapters and point MultiServerMCPClient at http://localhost:5000/mcp with streamable_http transport. get_tools() returns LangChain tools ready for any agent.

Where is LangChain's MCP config file?

LangChain doesn't have one — MCP servers are declared in Python or JS code through the langchain-mcp-adapters package. Your Toolbox connection details live in the same codebase as your agent, which is better for versioning anyway.

Why does the client get connection refused?

Usually the Toolbox bound to loopback inside the container. Start it with --address 0.0.0.0 so Docker's -p 5000:5000 mapping can reach it, and verify with docker ps. Agents running inside their own containers need host.docker.internal instead of localhost.

Can multiple agents share one Toolbox instance?

Yes — that's a strength of running it as an HTTP service rather than a per-agent subprocess. Many LangChain processes can connect to the same container, all governed by the same tools.yaml contract.

Browse more MCP servers for LangChain.

Find HTTP-ready servers with live-probed tool lists.

Browse the marketplace