Skip to main content
Glama

DB-MCP

Give AI assistants governed access to your databases through the Model Context Protocol. Connect any supported database, define governance rules, and let AI query your data safely.

Supported databases: PostgreSQL, MySQL, BigQuery, Snowflake, Redshift, ClickHouse

Quick Start

Demo Data (try it in 2 minutes)

git clone https://github.com/syam/db-mcp.git
cd db-mcp
docker compose up
  1. Open http://localhost:3000 and click Try with Demo Data

  2. The demo sets up a sample e-commerce database with cubes and governance rules pre-configured

  3. Your MCP endpoint is live at http://localhost:3000/mcp/default

Add to Claude Desktop (Settings > MCP Servers):

{
  "mcpServers": {
    "db-mcp": {
      "url": "http://localhost:3000/mcp/default"
    }
  }
}

Your Own Database

git clone https://github.com/syam/db-mcp.git
cd db-mcp
cp .env.example .env   # optionally set ANTHROPIC_API_KEY for AI chat
docker compose up
  1. Open http://localhost:3000 and click Add Database

  2. Fill in the connection form and click Test Connection to verify

  3. Generate cubes — go to the Tables page, click Generate All Cubes (or generate per-table). This creates the YAML definitions that tell the semantic layer what's queryable.

  4. Configure governance (optional) — go to the Governance page to mark PII fields, control member exposure, and set query restrictions

  5. Your MCP endpoint is live at http://localhost:3000/mcp/{your-database-id}

Important: Without generating cubes (step 3), MCP tools will return no data. The semantic layer automatically picks up new and changed cube files — no restart needed.

Related MCP server: Metabase MCP Plus

How It Works

Your Database → Cube Definitions (YAML) → Semantic Layer → Governance Rules → MCP Tools → AI Assistant
  • Cube definitions map your database tables into queryable measures and dimensions

  • Governance rules control which members AI can access (PII blocking, exposure, query limits)

  • MCP tools expose the governed semantic layer to any MCP-compatible AI assistant

Cube Definitions

Cubes are YAML files that define what AI can query. Each cube maps a database table to typed measures (aggregations) and dimensions (attributes).

Location: data/databases/{id}/cube/model/cubes/*.yml

How to create: Use the Tables page in the admin UI and click Generate All Cubes. If you have ANTHROPIC_API_KEY set, the generator will add rich descriptions to help AI understand your data. You can also write cube YAML manually.

Example:

cubes:
  - name: orders
    sql_table: orders
    measures:
      - name: count
        type: count
      - name: total_amount
        type: sum
        sql: "{CUBE}.amount"
    dimensions:
      - name: status
        sql: "{CUBE}.status"
        type: string
      - name: created_at
        sql: "{CUBE}.created_at"
        type: time

Supported measure types: count, sum, avg, min, max, count_distinct

Supported dimension types: string, number, time, boolean

The semantic layer automatically detects new and changed cube files — no restart needed.

Governance

Governance controls which members AI can access and how. Configure via the Governance page in the admin UI, or edit data/databases/{id}/agent_catalog.yaml directly.

Example:

version: "1.0"
defaults:
  exposed: true
  pii: false
members:
  Users.email:
    exposed: false
    pii: true
  Orders.total_amount:
    allowedGroupBy:
      - Orders.status
      - Orders.created_at

Features:

  • PII Protection — Mark sensitive fields to block them from all queries

  • Member Exposure — Control which measures and dimensions are queryable

  • Query Limits — Enforce maximum row counts per query

  • Group-by Restrictions — Limit which dimensions can be used for grouping

  • Default Filters — Automatically apply security filters (e.g., tenant isolation) to all queries

  • Default Segments — Apply pre-defined segments to all queries

Connect to AI Assistants

Each database gets its own MCP endpoint at /mcp/{databaseId}.

Claude Desktop — Add to Settings > MCP Servers:

{
  "mcpServers": {
    "db-mcp": {
      "url": "http://localhost:3000/mcp/default"
    }
  }
}

Cursor / Other MCP Clients — Point to http://localhost:3000/mcp/{databaseId} as an HTTP MCP endpoint.

Built-in AI Chat — Set ANTHROPIC_API_KEY in your .env and use the Chat page in the admin UI to query your data conversationally.

MCP Tools

Tool

Description

catalog_search

Search for measures, dimensions, and segments with fuzzy matching

catalog_describe

Get detailed member information including governance status

query_semantic

Execute governed queries against the semantic layer

Configuration

For Docker, set these in your .env file or shell before running docker compose up:

Variable

Required

Purpose

CUBE_JWT_SECRET

Auto-set

JWT secret shared with Cube.js (default provided in docker-compose.yml)

ANTHROPIC_API_KEY

No

Enable AI chat and LLM-enhanced cube generation

ADMIN_SECRET

No

Encrypt stored database credentials with AES-256-GCM (min 32 chars)

Copy .env.example to .env to see all available variables.

Local Development

For contributors working on db-mcp itself:

# Start infrastructure with exposed ports
docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d postgres cube

# Install dependencies
npm install

# Copy and edit env file
cp .env.example .env

# Start backend (port 3000)
npm run dev

# Start frontend (port 3001, in another terminal)
cd admin/frontend && npm install && npm run dev
npm run test             # Run tests
npm run lint             # Lint
npm run build            # Build for production
npx playwright test      # E2E tests

Architecture

See docs/architecture.md for detailed architecture, API reference, and troubleshooting.

localhost:3000 (nginx)
├── /api/*          Admin REST API
├── /mcp/:id        MCP endpoints (Streamable HTTP + SSE)
├── /health         Health check
└── /*              Admin UI (React SPA)
        │
        ▼
    Express Backend
        │
        ▼
    Semantic Layer (Cube.js)
        │
        ▼
    Your Databases

License

MIT

Available Tools

3 tools
catalog.describeB

Get detailed information about a specific member including its definition, type, and related members.

ParametersJSON Schema
NameRequiredDescriptionDefault
memberYesFull member name (e.g., "Orders.count")

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It describes a read operation ('Get detailed information'), which implies it is likely non-destructive, but does not address other traits such as authentication requirements, rate limits, error handling, or what happens if the member does not exist. This leaves significant gaps in understanding the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that efficiently conveys the tool's purpose and key details without unnecessary words. It is front-loaded with the main action and resource, making it easy to understand quickly. However, it could be slightly more concise by avoiding minor redundancy (e.g., 'detailed information' might imply 'definition, type, and related members').

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of retrieving detailed member information, the description is incomplete. With no annotations and no output schema, it fails to explain critical aspects such as the format of returned information, potential errors, or any limitations. The description alone does not provide enough context for an agent to fully understand how to use the tool effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the single parameter 'member' documented as 'Full member name (e.g., "Orders.count")'. The description does not add any additional meaning beyond this, such as format constraints or examples beyond the schema. Given the high schema coverage, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Get detailed information') and resource ('a specific member'), and specifies what information is retrieved ('definition, type, and related members'). However, it does not explicitly differentiate from sibling tools like catalog.search, which might also retrieve member information but with different scope or filtering.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when detailed information about a specific member is needed, but it does not provide explicit guidance on when to use this tool versus alternatives like catalog.search or query.semantic. No exclusions or prerequisites are mentioned, leaving the context somewhat open-ended.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

catalog.searchB

Search the data catalog for available measures, dimensions, and segments. Use this to discover what data is available for querying.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query for finding members
typesNoFilter by member types
cubesNoFilter by cube names
limitNoMaximum results (default: 10, max: 50)

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool is for 'searching' and 'discovery,' which suggests a read-only operation, but it doesn't detail behavioral traits such as rate limits, authentication needs, pagination, or what happens on errors. For a search tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded, consisting of two sentences that directly state the purpose and usage. There's no unnecessary information or redundancy. However, it could be slightly more structured by explicitly separating purpose from guidelines, but it's efficient overall.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a search function with 4 parameters), no annotations, and no output schema, the description is moderately complete. It covers the basic purpose and usage but lacks details on behavioral aspects, output format, and sibling tool differentiation. It's adequate as a minimum viable description but has clear gaps in providing full context for effective tool use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so the schema already documents all parameters (query, types, cubes, limit) with details like default values and enums. The description adds no additional parameter semantics beyond what's in the schema, such as examples or usage tips. According to the rules, with high schema coverage (>80%), the baseline is 3 even without param info in the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Search the data catalog for available measures, dimensions, and segments.' It specifies the verb ('search') and resource ('data catalog'), and mentions the target objects. However, it doesn't explicitly distinguish this from sibling tools like 'catalog.describe' or 'query.semantic', which prevents a score of 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides some usage context: 'Use this to discover what data is available for querying.' This implies when to use the tool (for discovery), but it doesn't offer explicit guidance on when to choose this over alternatives like 'catalog.describe' or 'query.semantic', nor does it mention exclusions or prerequisites. The guidance is implied rather than comprehensive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

query.semanticC

Execute a governed semantic query against the data warehouse. Queries are validated against governance policies before execution.

ParametersJSON Schema
NameRequiredDescriptionDefault
measuresNoMeasures to query
dimensionsNoDimensions for grouping
timeDimensionsNoTime dimensions with optional granularity and date range
filtersNoFilter conditions
segmentsNoSegments to apply
orderNoSort order
limitYesMaximum rows to return (required)
offsetNoNumber of rows to skip

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions governance validation, which hints at potential restrictions or errors, but lacks details on execution behavior (e.g., performance, rate limits, error handling, or output format). For a complex query tool with 8 parameters, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with the core purpose and followed by a key behavioral note (governance validation). Every sentence earns its place by providing essential information without redundancy or fluff, making it highly efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (8 parameters, no output schema, and no annotations), the description is incomplete. It lacks details on what the query returns, how results are structured, error conditions, or governance specifics. For a data query tool, this leaves critical gaps for an AI agent to understand and use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, meaning all parameters are documented in the input schema. The description adds no additional meaning beyond the schema, such as examples or usage context for parameters like measures or dimensions. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('execute a governed semantic query') and target ('against the data warehouse'), with the verb 'execute' being specific. However, it doesn't differentiate from sibling tools like catalog.describe or catalog.search, which likely serve different purposes (e.g., metadata exploration vs. data querying).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions that 'queries are validated against governance policies before execution,' which implies a context of compliance or security. However, it provides no explicit guidance on when to use this tool versus alternatives like catalog.describe or catalog.search, nor does it specify prerequisites or exclusions for usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 3 tool updatesv0.1.0
    • First observedcatalog.describe
    • First observedcatalog.search
    • First observedquery.semantic

TDQS

B3.3/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose with no overlap: catalog.describe provides detailed metadata about a specific member, catalog.search enables discovery of available data elements, and query.semantic executes governed queries. The descriptions clearly differentiate between metadata lookup, discovery, and query execution functions.

Naming Consistency5/5

All tools follow a consistent dot-separated naming pattern (catalog.describe, catalog.search, query.semantic) with clear verb-noun combinations. The naming convention is uniform throughout the set, making it easy to understand the tool hierarchy and relationships.

Tool Count3/5

With only 3 tools, the set feels somewhat thin for a database/warehouse MCP server. While the tools cover key functions (metadata, discovery, querying), typical database interfaces would include more operations like data modification, schema management, or connection handling. The count is borderline minimal but functional.

Completeness3/5

The tools cover discovery (search), metadata inspection (describe), and query execution, but there are notable gaps for a complete database interface. Missing are data modification operations (insert/update/delete), schema management tools, connection/configuration management, and monitoring/debugging capabilities. The surface enables read operations but lacks write capabilities.

Maintenance

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that enables AI assistants to query and interact with SQLite databases through natural language. It includes built-in security guardrails such as PII redaction, SQL injection blocking, and query rate limiting.
    -
  • A
    license
    A
    quality
    C
    maintenance
    An MCP server that enables AI assistants to query databases, execute SQL, and manage Metabase resources like dashboards, cards, and collections through natural language.
    22
    MIT
  • -
    license
    Not graded
    quality
    C
    maintenance
    An MCP server that bridges AI assistants with SQL databases, enabling natural language querying across multiple database types with built-in optimization and security.
    3
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that gives AI assistants the ability to connect to, query, profile, and monitor data sources — turning any LLM into an interactive data engineering copilot.
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/scrappymonkey/db-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server