# googleapis/mcp-toolbox architecture

> Architecture diagram of the GitHub repository googleapis/mcp-toolbox, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/googleapis/mcp-toolbox
- Repository: https://github.com/googleapis/mcp-toolbox

## Overview

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: [`internal/server/server.go`](https://github.com/googleapis/mcp-toolbox/blob/main/internal/server/server.go) (Server core), [`internal/tools/toolsets.go`](https://github.com/googleapis/mcp-toolbox/blob/main/internal/tools/toolsets.go) (Manifests), [`cmd/root.go`](https://github.com/googleapis/mcp-toolbox/blob/main/cmd/root.go) (Root cmd), [`internal/tools/tools.go`](https://github.com/googleapis/mcp-toolbox/blob/main/internal/tools/tools.go) (Tools index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI & packaging"]
  node_main["Main<br/>go entrypoint<br/>[main.go]"]
  node_rootcmd["Root cmd<br/>cli root<br/>[root.go]"]
  node_servecmd["Serve cmd<br/>cli subcommand<br/>[command.go]"]
  node_invokecmd["Invoke cmd<br/>cli subcommand<br/>[command.go]"]
  node_migratecmd["Migrate cmd<br/>cli subcommand<br/>[command.go]"]
  node_skillscmd["Skills cmd<br/>cli subcommand<br/>[command.go]"]
  node_skillgen["Skill gen<br/>packager<br/>[generator.go]"]
end

subgraph group_server["Server runtime"]
  node_servercore["Server core<br/>MCP server<br/>[server.go]"]
  node_webui["Web UI<br/>browser UI<br/>[web.go]"]
  node_resources["Resources<br/>resource catalog<br/>[resources.go]"]
end

subgraph group_protocol["MCP protocol"]
  node_mcpcore["MCP core<br/>protocol router<br/>[mcp.go]"]
  node_jsonrpc["JSON-RPC<br/>transport framing<br/>[jsonrpc.go]"]
  node_mcpv1["MCP v20251125<br/>versioned schema<br/>[manifests.go]"]
end

subgraph group_manifest["Config model"]
  node_configmodel["Manifests<br/>config model<br/>[toolsets.go]"]
  node_prompts["Prompts<br/>prompt model<br/>[prompts.go]"]
  node_prebuilt["Prebuilt configs<br/>packaged config<br/>[prebuiltconfigs.go]"]
end

subgraph group_connect["Connectors"]
  node_sources["Sources<br/>adapter registry<br/>[sources.go]"]
end

subgraph group_tools["Tools"]
  node_toolsroot["Tools index<br/>tool registry<br/>[tools.go]"]
  node_sqltools["SQL tools<br/>tool family"]
  node_cloudtools["Cloud tools<br/>tool family"]
  node_graphtools["Graph tools<br/>tool family"]
end

subgraph group_crosscut["Cross-cutting"]
  node_shared["Shared infra<br/>cross-cutting<br/>[util.go]"]
end

subgraph group_docs["Docs & samples"]
  node_docssite["Docs site<br/>hugo docs<br/>[_index.md]"]
  node_samples["Samples<br/>examples<br/>[quickstart.go]"]
  node_integrationtests["Integration tests<br/>validation suite<br/>[server.go]"]
end

subgraph group_release["Build & release"]
  node_releaseci["CI & release<br/>automation<br/>[tests.yaml]"]
  node_npmdist["NPM dist<br/>launcher packaging<br/>[run.js]"]
  node_container["Container<br/>image packaging"]
end

node_main -->|"starts"| node_rootcmd
node_rootcmd -->|"dispatches"| node_servecmd
node_rootcmd -->|"dispatches"| node_invokecmd
node_rootcmd -->|"dispatches"| node_migratecmd
node_rootcmd -->|"dispatches"| node_skillscmd
node_skillscmd -->|"uses"| node_skillgen
node_servecmd -->|"runs"| node_servercore
node_servercore -->|"hosts"| node_mcpcore
node_servercore -->|"serves"| node_webui
node_servercore -->|"publishes"| node_resources
node_mcpcore -->|"frames"| node_jsonrpc
node_mcpcore -->|"implements"| node_mcpv1
node_mcpv1 -->|"maps"| node_configmodel
node_configmodel -->|"includes"| node_prompts
node_configmodel -->|"loads"| node_prebuilt
node_configmodel -->|"references"| node_sources
node_configmodel -->|"registers"| node_toolsroot
node_toolsroot -->|"groups"| node_sqltools
node_toolsroot -->|"groups"| node_cloudtools
node_toolsroot -->|"groups"| node_graphtools
node_sqltools -->|"calls"| node_sources
node_cloudtools -->|"calls"| node_sources
node_graphtools -->|"calls"| node_sources
node_sources -->|"uses"| node_shared
node_toolsroot -->|"uses"| node_shared
node_servercore -->|"uses"| node_shared
node_docssite -->|"documents"| node_configmodel
node_samples -->|"exercises"| node_servercore
node_integrationtests -->|"validates"| node_mcpcore
node_releaseci -->|"builds"| node_servercore
node_releaseci -->|"publishes"| node_docssite
node_npmdist -->|"wraps"| node_main
node_container -->|"packages"| node_servercore

click node_main "https://github.com/googleapis/mcp-toolbox/blob/main/main.go"
click node_rootcmd "https://github.com/googleapis/mcp-toolbox/blob/main/cmd/root.go"
click node_servecmd "https://github.com/googleapis/mcp-toolbox/blob/main/cmd/internal/serve/command.go"
click node_invokecmd "https://github.com/googleapis/mcp-toolbox/blob/main/cmd/internal/invoke/command.go"
click node_migratecmd "https://github.com/googleapis/mcp-toolbox/blob/main/cmd/internal/migrate/command.go"
click node_skillscmd "https://github.com/googleapis/mcp-toolbox/blob/main/cmd/internal/skills/command.go"
click node_skillgen "https://github.com/googleapis/mcp-toolbox/blob/main/cmd/internal/skills/generator.go"
click node_servercore "https://github.com/googleapis/mcp-toolbox/blob/main/internal/server/server.go"
click node_webui "https://github.com/googleapis/mcp-toolbox/blob/main/internal/server/web.go"
click node_resources "https://github.com/googleapis/mcp-toolbox/blob/main/internal/server/resources/resources.go"
click node_mcpcore "https://github.com/googleapis/mcp-toolbox/blob/main/internal/server/mcp/mcp.go"
click node_jsonrpc "https://github.com/googleapis/mcp-toolbox/blob/main/internal/server/mcp/jsonrpc/jsonrpc.go"
click node_mcpv1 "https://github.com/googleapis/mcp-toolbox/blob/main/internal/server/mcp/v20251125/manifests.go"
click node_configmodel "https://github.com/googleapis/mcp-toolbox/blob/main/internal/tools/toolsets.go"
click node_prompts "https://github.com/googleapis/mcp-toolbox/blob/main/internal/prompts/prompts.go"
click node_prebuilt "https://github.com/googleapis/mcp-toolbox/blob/main/internal/prebuiltconfigs/prebuiltconfigs.go"
click node_sources "https://github.com/googleapis/mcp-toolbox/blob/main/internal/sources/sources.go"
click node_toolsroot "https://github.com/googleapis/mcp-toolbox/blob/main/internal/tools/tools.go"
click node_sqltools "https://github.com/googleapis/mcp-toolbox/blob/main/internal/tools/postgres/postgresexecutesql/postgresexecutesql.go"
click node_cloudtools "https://github.com/googleapis/mcp-toolbox/blob/main/internal/tools/cloudsql/cloudsqlcloneinstance/cloudsqlcloneinstance.go"
click node_graphtools "https://github.com/googleapis/mcp-toolbox/blob/main/internal/tools/neo4j/neo4jexecutecypher/neo4jexecutecypher.go"
click node_shared "https://github.com/googleapis/mcp-toolbox/blob/main/internal/util/util.go"
click node_docssite "https://github.com/googleapis/mcp-toolbox/blob/main/docs/en/documentation/_index.md"
click node_samples "https://github.com/googleapis/mcp-toolbox/blob/main/docs/en/documentation/getting-started/quickstart/go/genAI/quickstart.go"
click node_integrationtests "https://github.com/googleapis/mcp-toolbox/blob/main/tests/server.go"
click node_releaseci "https://github.com/googleapis/mcp-toolbox/blob/main/.github/workflows/tests.yaml"
click node_npmdist "https://github.com/googleapis/mcp-toolbox/blob/main/npm/server/bin/run.js"
click node_container "https://github.com/googleapis/mcp-toolbox/tree/main/Dockerfile"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_rootcmd,node_servecmd,node_invokecmd,node_migratecmd,node_skillscmd,node_skillgen,node_shared toneBlue
class node_servercore,node_webui,node_resources,node_docssite,node_samples,node_integrationtests toneAmber
class node_mcpcore,node_jsonrpc,node_mcpv1,node_releaseci,node_npmdist,node_container toneMint
class node_configmodel,node_prompts,node_prebuilt toneRose
class node_sources toneIndigo
class node_toolsroot,node_sqltools,node_cloudtools,node_graphtools toneTeal
```

## Components

### CLI & packaging

Entry commands, packaging, and generated skill artifacts.

- [Main](https://github.com/googleapis/mcp-toolbox/blob/main/main.go): go entrypoint · Process startup for the toolbox binary. · `main.go`
- [Root cmd](https://github.com/googleapis/mcp-toolbox/blob/main/cmd/root.go): cli root · Top-level command dispatcher and shared flags. · `cmd/root.go`
- [Serve cmd](https://github.com/googleapis/mcp-toolbox/blob/main/cmd/internal/serve/command.go): cli subcommand · Runs the server and UI modes. · `cmd/internal/serve/command.go`
- [Invoke cmd](https://github.com/googleapis/mcp-toolbox/blob/main/cmd/internal/invoke/command.go): cli subcommand · Executes a tool directly from the CLI. · `cmd/internal/invoke/command.go`
- [Migrate cmd](https://github.com/googleapis/mcp-toolbox/blob/main/cmd/internal/migrate/command.go): cli subcommand · Migrates or reshapes configuration. · `cmd/internal/migrate/command.go`
- [Skills cmd](https://github.com/googleapis/mcp-toolbox/blob/main/cmd/internal/skills/command.go): cli subcommand · Generates distributable agent skill packages. · `cmd/internal/skills/command.go`
- [Skill gen](https://github.com/googleapis/mcp-toolbox/blob/main/cmd/internal/skills/generator.go): packager · Transforms toolsets into skill artifacts. · `cmd/internal/skills/generator.go`

### Server runtime

MCP serving, UI, and resource presentation.

- [Server core](https://github.com/googleapis/mcp-toolbox/blob/main/internal/server/server.go): MCP server · Orchestrates server lifecycle, endpoints, and request routing. · `internal/server/server.go`
- [Web UI](https://github.com/googleapis/mcp-toolbox/blob/main/internal/server/web.go): browser UI · Serves the operator interface and static assets. · `internal/server/web.go`
- [Resources](https://github.com/googleapis/mcp-toolbox/blob/main/internal/server/resources/resources.go): resource catalog · 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](https://github.com/googleapis/mcp-toolbox/blob/main/internal/server/mcp/mcp.go): protocol router · Routes protocol requests to versioned manifests and methods. · `internal/server/mcp/mcp.go`
- [JSON-RPC](https://github.com/googleapis/mcp-toolbox/blob/main/internal/server/mcp/jsonrpc/jsonrpc.go): transport framing · JSON-RPC framing and transport helpers for MCP. · `internal/server/mcp/jsonrpc/jsonrpc.go`
- [MCP v20251125](https://github.com/googleapis/mcp-toolbox/blob/main/internal/server/mcp/v20251125/manifests.go): versioned schema · 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](https://github.com/googleapis/mcp-toolbox/blob/main/internal/tools/toolsets.go): config model · Declarative sources, tools, toolsets, and prompts model. · `internal/tools/toolsets.go`
- [Prompts](https://github.com/googleapis/mcp-toolbox/blob/main/internal/prompts/prompts.go): prompt model · Prompt argument handling and custom prompt sets. · `internal/prompts/prompts.go`
- [Prebuilt configs](https://github.com/googleapis/mcp-toolbox/blob/main/internal/prebuiltconfigs/prebuiltconfigs.go): packaged config · Loads bundled ready-to-use configurations. · `internal/prebuiltconfigs/prebuiltconfigs.go`

### Connectors

Backend adapters for databases and external services.

- [Sources](https://github.com/googleapis/mcp-toolbox/blob/main/internal/sources/sources.go): adapter registry · Backend connectivity and source-specific metadata access. · `internal/sources/sources.go`

### Tools

Concrete MCP tool implementations grouped by domain.

- [Tools index](https://github.com/googleapis/mcp-toolbox/blob/main/internal/tools/tools.go): tool registry · Registers tool families and exposes shared tool metadata. · `internal/tools/tools.go`
- [SQL tools](https://github.com/googleapis/mcp-toolbox/blob/main/internal/tools/postgres/postgresexecutesql/postgresexecutesql.go): tool family · Relational query and introspection tools across SQL backends. · `internal/tools/postgres/postgresexecutesql/postgresexecutesql.go`
- [Cloud tools](https://github.com/googleapis/mcp-toolbox/blob/main/internal/tools/cloudsql/cloudsqlcloneinstance/cloudsqlcloneinstance.go): tool family · Cloud admin, storage, analytics, and observability tools. · `internal/tools/cloudsql/cloudsqlcloneinstance/cloudsqlcloneinstance.go`
- [Graph tools](https://github.com/googleapis/mcp-toolbox/blob/main/internal/tools/neo4j/neo4jexecutecypher/neo4jexecutecypher.go): tool family · 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](https://github.com/googleapis/mcp-toolbox/blob/main/internal/util/util.go): cross-cutting · Logging, auth, telemetry, parameters, and ordered-map utilities. · `internal/util/util.go`

### Docs & samples

Documentation site, examples, and validation flows.

- [Docs site](https://github.com/googleapis/mcp-toolbox/blob/main/docs/en/documentation/_index.md): hugo docs · Generated documentation, integrations, quickstarts, and references. · `docs/en/documentation/_index.md`
- [Samples](https://github.com/googleapis/mcp-toolbox/blob/main/docs/en/documentation/getting-started/quickstart/go/genAI/quickstart.go): examples · Runnable sample programs and integration exercises. · `docs/en/documentation/getting-started/quickstart/go/genAI/quickstart.go`
- [Integration tests](https://github.com/googleapis/mcp-toolbox/blob/main/tests/server.go): validation suite · End-to-end MCP and service tests across integrations. · `tests/server.go`

### Build & release

Automation for testing, docs publishing, and distribution.

- [CI & release](https://github.com/googleapis/mcp-toolbox/blob/main/.github/workflows/tests.yaml): automation · Build, lint, publish, and docs deployment workflows. · `.github/workflows/tests.yaml`
- [NPM dist](https://github.com/googleapis/mcp-toolbox/blob/main/npm/server/bin/run.js): launcher packaging · Platform-specific npm launchers for the Go server binary. · `npm/server/bin/run.js`
- [Container](https://github.com/googleapis/mcp-toolbox/tree/main/Dockerfile): image packaging · Docker container distribution for the server. · `Dockerfile`

## Connections

- 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.
