How googleapis/mcp-toolbox works
1. What this repo is
- This is a Go-based MCP server called MCP Toolbox for Databases.
- Its job is to expose database- and service-oriented actions as MCP tools so external AI clients, IDEs, and agent frameworks can call them over HTTP or stdio.
2. Top-level execution boundary
- main.go and cmd/ define the CLI entrypoint.
- The CLI orchestrates modes such as running the server, serving the web UI, invoking tools, migrating configs, and generating skills.
- cmd/root.go is the root command; cmd/internal/* holds subcommand logic and option parsing.
3. Server runtime boundary
- internal/server/ is the runtime core.
- It serves MCP endpoints, a browser UI, static assets, and resource metadata.
- The server has a split between protocol handling (internal/server/mcp/) and the human-facing web UI/static files (internal/server/static/, internal/server/web.go).
4. MCP protocol layer
- internal/server/mcp/ contains protocol-specific behavior, including multiple versioned packages (v20241105, v20250326, v20250618, v20251125).
- This indicates the server supports multiple MCP schema/protocol revisions and maps requests to manifests/methods for each version.
- internal/server/mcp/jsonrpc/ is the transport/protocol framing layer.
5. Configuration and manifest model
- The repository is centered around declarative manifests for:
- sources: connections to databases or APIs
- tools: callable actions
- toolsets: grouped tool bundles
- prompts: reusable LLM prompts
- internal/util/parameters/, internal/prompts/, and internal/server/resources/ support parsing, validation, and presentation of these manifests.
- internal/prebuiltconfigs/ loads packaged “ready-to-use” configurations that power the --prebuilt=<name> experience.
6. Source adapters: connectivity boundary
- internal/sources/ contains one adapter per backend or service family.
- These adapters encapsulate how Toolbox connects to targets such as PostgreSQL, MySQL, SQL Server, BigQuery, Cloud SQL, AlloyDB, Firestore, MongoDB, Redis, Spanner, Snowflake, Looker, Neo4j, and many others.
- They are the data-access boundary: authentication, connection details, dialect differences, and source-specific metadata retrieval live here.
7. Tool implementations: action boundary
- internal/tools/ contains the concrete MCP tool implementations.
- Tools are grouped by domain, usually mirroring the source families: SQL execution, schema introspection, admin operations, analytics, cloud resource management, and specialized workflows like vector assist or conversational analytics.
- Many tool packages are thin wrappers over a source adapter plus validation/formatting logic; the boundary is “tool contract in, structured result out.”
8. Common SQL and utility abstractions
- Shared logic sits in packages such as internal/sources/sqlcommenter, internal/tools/*common, internal/util/, and internal/log/.
- These layers handle cross-cutting concerns like query annotation, ordered maps, parameter handling, error shaping, and logging.
- This is where the repo avoids duplicating SQL-dialect or request/response plumbing across hundreds of tools.
9. Authentication, embedding models, and telemetry
- internal/auth/ supports auth modes such as generic credentials and Google-based authentication.
- internal/embeddingmodels/ abstracts embedding providers, with Gemini-specific support in the tree.
- internal/telemetry/ emits OpenTelemetry traces/metrics, so the server can be observed externally through OTLP-compatible backends.
10. Web UI and operator experience
- The server includes a built-in UI under internal/server/static/ for browsing tools/toolsets and testing invocations.
- The README’s --ui mode corresponds to this subsystem.
- Static JS files such as loadTools.js, runTool.js, and toolsets.js indicate the UI is primarily a control panel over the same server-side tool registry.
11. Skills generation and packaging
- cmd/internal/skills/ and the README’s skills-generate command show a second output path: converting a toolset into an Agent Skill package.
- This is a packaging boundary rather than an execution boundary; it turns server definitions into distributable artifacts for clients like Gemini CLI.
12. Documentation and sample programs
- docs/ and .hugo/ form the generated documentation site.
- The docs include integration-specific reference pages, quickstarts, and runnable samples in Go, JavaScript, Python, notebooks, and shell scripts.
- The tests/ and .ci/sample_tests/ trees validate those sample flows against real services and MCP behavior.
13. Build, release, and distribution
- The repo is built and released via GitHub Actions and Cloud Build configs in .github/workflows/ and .ci/.
- The npm/ directory packages platform-specific server launchers, while Dockerfile supports container distribution.
- This means the same Go server is shipped as a binary, container image, and npm-installed launcher.
14. How the main data flow works
- A client or IDE connects to the Toolbox server via MCP HTTP/stdio.
- The server loads config or prebuilt manifests, resolves sources, and registers tools/toolsets/prompts.
- When a tool is invoked, the request flows through the MCP layer to a tool implementation, which calls a source adapter or external cloud API, formats the result, and returns it to the client.
- Optional telemetry is emitted along the way, and the UI can exercise the same path interactively.
Main entry points: server.go Server core · toolsets.go Manifests · root.go Root cmd · tools.go Tools index
Components 28
CLI & packaging
Entry commands, packaging, and generated skill artifacts.
- Main · Process startup for the toolbox binary.
main.go - Root cmd · Top-level command dispatcher and shared flags.
cmd/root.go - Serve cmd · Runs the server and UI modes.
cmd/internal/serve/command.go - Invoke cmd · Executes a tool directly from the CLI.
cmd/internal/invoke/command.go - Migrate cmd · Migrates or reshapes configuration.
cmd/internal/migrate/command.go - Skills cmd · Generates distributable agent skill packages.
cmd/internal/skills/command.go - Skill gen · Transforms toolsets into skill artifacts.
cmd/internal/skills/generator.go
Server runtime
MCP serving, UI, and resource presentation.
- Server core · Orchestrates server lifecycle, endpoints, and request routing.
internal/server/server.go - Web UI · Serves the operator interface and static assets.
internal/server/web.go - Resources · Exposes manifests and metadata to MCP clients and UI.
internal/server/resources/resources.go
MCP protocol
Versioned MCP request handling and JSON-RPC transport.
- MCP core · Routes protocol requests to versioned manifests and methods.
internal/server/mcp/mcp.go - JSON-RPC · JSON-RPC framing and transport helpers for MCP.
internal/server/mcp/jsonrpc/jsonrpc.go - MCP v20251125 · Latest protocol package with manifests and method mapping.
internal/server/mcp/v20251125/manifests.go
Config model
Declarative manifests, prompts, parameter parsing, and prebuilt configs.
- Manifests · Declarative sources, tools, toolsets, and prompts model.
internal/tools/toolsets.go - Prompts · Prompt argument handling and custom prompt sets.
internal/prompts/prompts.go - Prebuilt configs · Loads bundled ready-to-use configurations.
internal/prebuiltconfigs/prebuiltconfigs.go
Connectors
Backend adapters for databases and external services.
- Sources · Backend connectivity and source-specific metadata access.
internal/sources/sources.go
Tools
Concrete MCP tool implementations grouped by domain.
- Tools index · Registers tool families and exposes shared tool metadata.
internal/tools/tools.go - SQL tools · Relational query and introspection tools across SQL backends.
internal/tools/postgres/postgresexecutesql/postgresexecutesql.go - Cloud tools · Cloud admin, storage, analytics, and observability tools.
internal/tools/cloudsql/cloudsqlcloneinstance/cloudsqlcloneinstance.go - Graph tools · Graph and document-store tools such as Neo4j and Firestore.
internal/tools/neo4j/neo4jexecutecypher/neo4jexecutecypher.go
Cross-cutting
Shared logging, auth, embeddings, telemetry, and utilities.
- Shared infra · Logging, auth, telemetry, parameters, and ordered-map utilities.
internal/util/util.go
Docs & samples
Documentation site, examples, and validation flows.
- Docs site · Generated documentation, integrations, quickstarts, and references.
docs/en/documentation/_index.md - Samples · Runnable sample programs and integration exercises.
docs/en/documentation/getting-started/quickstart/go/genAI/quickstart.go - Integration tests · End-to-end MCP and service tests across integrations.
tests/server.go
Build & release
Automation for testing, docs publishing, and distribution.
- CI & release · Build, lint, publish, and docs deployment workflows.
.github/workflows/tests.yaml - NPM dist · Platform-specific npm launchers for the Go server binary.
npm/server/bin/run.js - Container · Docker container distribution for the server.
Dockerfile
Connections 33
- Main → Root cmd: starts · Binary startup delegates to the command tree.
- Root cmd → Serve cmd: dispatches · Root command selects server mode.
- Root cmd → Invoke cmd: dispatches · Root command can invoke a tool directly.
- Root cmd → Migrate cmd: dispatches · Root command can migrate configuration.
- Root cmd → Skills cmd: dispatches · Root command can generate skills.
- Skills cmd → Skill gen: uses · Skills command drives artifact generation.
- Serve cmd → Server core: runs · Serve mode launches the server runtime.
- Server core → MCP core: hosts · Server runtime exposes MCP protocol handling.
- Server core → Web UI: serves · Server runtime serves the browser UI and static assets.
- Server core → Resources: publishes · Server runtime exposes resource metadata.
- MCP core → JSON-RPC: frames · Protocol layer relies on JSON-RPC transport framing.
- MCP core → MCP v20251125: implements · Protocol router uses versioned manifest/method packages.
- MCP v20251125 → Manifests: maps · Versioned protocol packages map requests to manifests.
- Manifests → Prompts: includes · Manifests include prompt definitions and arguments.
- Manifests → Prebuilt configs: loads · Manifest model can be seeded from packaged configs.
- Manifests → Sources: references · Sources define the external connectivity boundary.
- Manifests → Tools index: registers · Tool definitions are exposed through the tool registry.
- Tools index → SQL tools: groups · Registry includes SQL-oriented tool family.
- Tools index → Cloud tools: groups · Registry includes cloud/admin tool family.
- Tools index → Graph tools: groups · Registry includes graph/document-store tool family.
- SQL tools → Sources: calls · SQL tools execute through backend adapters.
- Cloud tools → Sources: calls · Cloud tools depend on service adapters.
- Graph tools → Sources: calls · Graph/document tools depend on source adapters.
- Sources → Shared infra: uses · Adapters share common logging, auth, and parameter utilities.
- Tools index → Shared infra: uses · Tool registry reuses shared helpers and formatting.
- Server core → Shared infra: uses · Server runtime uses shared infra for logging, auth, telemetry.
- Docs site → Manifests: documents · Docs describe manifests, sources, tools, and toolsets.
- Samples → Server core: exercises · Samples connect to the running server path.
- Integration tests → MCP core: validates · Integration tests cover MCP behavior and tool execution.
- CI & release → Server core: builds · Workflows build and test the server.
- CI & release → Docs site: publishes · Workflows deploy and lint generated docs.
- NPM dist → Main: wraps · npm launchers download and run the server binary.
- Container → Server core: packages · Docker image distributes the server runtime.