Skip to main content
Glama
stucchi

db-mcp-server

by stucchi

db-mcp-server

MCP server for MySQL, PostgreSQL, MongoDB, and SQLite databases. One instance per database, no Docker required.

Installation

uvx db-mcp-server

Related MCP server: MCP Database Server

Configuration

Configure via environment variables. Each instance connects to a single database.

MySQL

Variable

Required

Default

Description

DB_TYPE

Yes

mysql

DB_DATABASE

Yes

Database name

DB_PASSWORD

Yes

Password

DB_HOST

No

localhost

Host

DB_PORT

No

3306

Port

DB_USER

No

root

User

DB_MODE

No

read-only

read-only or read-write

PostgreSQL

Variable

Required

Default

Description

DB_TYPE

Yes

postgresql

DB_DATABASE

Yes

Database name

DB_PASSWORD

Yes

Password

DB_HOST

No

localhost

Host

DB_PORT

No

5432

Port

DB_USER

No

postgres

User

DB_MODE

No

read-only

read-only or read-write

MongoDB

Variable

Required

Default

Description

DB_TYPE

Yes

mongodb

DB_DATABASE

Yes

Database name

DB_URL

Yes

Connection URL (mongodb://...)

DB_MODE

No

read-only

read-only or read-write

SQLite

Variable

Required

Default

Description

DB_TYPE

Yes

sqlite

DB_PATH

Yes

Path to .db file (local or remote with SSH)

DB_DATABASE

No

filename

Display name

DB_MODE

No

read-only

read-only or read-write

SSH Tunnel (MySQL / PostgreSQL)

Optionally connect through an SSH bastion host. Set SSH_HOST to activate.

For SQLite over SSH, the remote .db file is downloaded via SFTP before querying. In read-write mode, changes are uploaded back on shutdown.

Variable

Required

Default

Description

SSH_HOST

No

SSH bastion host (activates tunneling)

SSH_PORT

No

22

SSH port

SSH_USER

No

Current OS user

SSH username

SSH_KEY

No

Path to private key (~/.ssh/id_rsa)

SSH_PASSWORD

No

SSH password (if no key)

At least one of SSH_KEY or SSH_PASSWORD is required when SSH_HOST is set. SSH tunneling is not supported for MongoDB.

Usage in .mcp.json

SQLite (local)

{
  "mcpServers": {
    "db-local": {
      "command": "uvx",
      "args": ["db-mcp-server"],
      "env": {
        "DB_TYPE": "sqlite",
        "DB_PATH": "/path/to/database.db"
      }
    }
  }
}

SQLite over SSH

{
  "mcpServers": {
    "db-remote": {
      "command": "uvx",
      "args": ["db-mcp-server"],
      "env": {
        "DB_TYPE": "sqlite",
        "DB_PATH": "/remote/path/to/database.db",
        "SSH_HOST": "server.example.com",
        "SSH_USER": "deploy",
        "SSH_KEY": "~/.ssh/id_rsa"
      }
    }
  }
}
{
  "mcpServers": {
    "db-prod": {
      "command": "uvx",
      "args": ["db-mcp-server"],
      "env": {
        "DB_TYPE": "mysql",
        "DB_MODE": "read-only",
        "DB_HOST": "db.example.com",
        "DB_PORT": "3306",
        "DB_USER": "root",
        "DB_PASSWORD": "secret",
        "DB_DATABASE": "myapp"
      }
    }
  }
}

With SSH tunnel

{
  "mcpServers": {
    "db-behind-bastion": {
      "command": "uvx",
      "args": ["db-mcp-server"],
      "env": {
        "DB_TYPE": "postgresql",
        "DB_HOST": "10.0.0.5",
        "DB_PORT": "5432",
        "DB_USER": "postgres",
        "DB_PASSWORD": "secret",
        "DB_DATABASE": "myapp",
        "SSH_HOST": "bastion.example.com",
        "SSH_USER": "deploy",
        "SSH_KEY": "~/.ssh/id_rsa"
      }
    }
  }
}

For multiple databases, add multiple instances:

{
  "mcpServers": {
    "db-prod": {
      "command": "uvx",
      "args": ["db-mcp-server"],
      "env": { "DB_TYPE": "mysql", "DB_DATABASE": "prod", "..." : "..." }
    },
    "db-analytics": {
      "command": "uvx",
      "args": ["db-mcp-server"],
      "env": { "DB_TYPE": "postgresql", "DB_DATABASE": "analytics", "..." : "..." }
    },
    "db-staging": {
      "command": "uvx",
      "args": ["db-mcp-server"],
      "env": { "DB_TYPE": "mongodb", "DB_DATABASE": "staging", "..." : "..." }
    }
  }
}

Tools

MySQL

  • query — Execute read-only SQL (SELECT, SHOW, DESCRIBE, EXPLAIN, WITH)

  • execute — Execute write SQL (INSERT, UPDATE, DELETE) — requires DB_MODE=read-write

  • describe — Describe table structure

  • list_tables — List all tables

  • status — Show connection info

PostgreSQL

  • query — Execute read-only SQL (SELECT, SHOW, DESCRIBE, EXPLAIN, WITH)

  • execute — Execute write SQL (INSERT, UPDATE, DELETE) — requires DB_MODE=read-write

  • describe — Describe table structure (column info from information_schema)

  • list_tables — List all tables in the public schema

  • status — Show connection info

SQLite

  • query — Execute read-only SQL (SELECT, SHOW, DESCRIBE, EXPLAIN, WITH)

  • execute — Execute write SQL (INSERT, UPDATE, DELETE) — requires DB_MODE=read-write

  • describe — Describe table structure (PRAGMA table_info)

  • list_tables — List all tables

  • status — Show connection info

MongoDB

  • query — Find documents in a collection

  • describe — Collection stats ($collStats)

  • list_collections — List all collections

  • aggregate — Execute aggregation pipelines ($out/$merge blocked on read-only)

  • status — Show connection info

License

MIT

Available Tools

5 tools
describeA

Describe the structure of a SQLite table (PRAGMA table_info).

ParametersJSON Schema
NameRequiredDescriptionDefault
tableYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/5.0
Behavior4/5

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

The description discloses the underlying SQL command (PRAGMA table_info), indicating a read-only introspection behavior. It does not mention error handling (e.g., for non-existent tables) or permissions, but given no annotations, the description sufficiently conveys the tool's safety profile.

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?

A single sentence that is precise and frontloaded with the core purpose, followed by the technical detail in parentheses. No unnecessary words or redundancy.

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

Completeness5/5

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

The tool is simple with one parameter and an output schema. The description fully explains what the tool does and how it works (via PRAGMA table_info). No additional context is needed for correct invocation.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must add meaning. It clarifies the 'table' parameter as the name of the SQLite table to describe, which is evident from the tool's purpose. This goes beyond the bare schema definition.

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

Purpose5/5

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

The description clearly states the verb 'describe' and the resource 'structure of a SQLite table', with the specific implementation detail 'PRAGMA table_info'. This is distinct from sibling tools like 'execute' (runs arbitrary SQL) and 'list_tables' (lists table names).

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 by stating what it does, but it does not explicitly specify when to use this tool over alternatives like 'query' or 'list_tables'. No 'when not to use' guidance is provided, leaving the agent to infer the context.

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

executeB

Execute a write query on the SQLite database. Only works if the database is configured with mode='read-write'.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.3/5.0
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavioral traits. It confirms the tool is write-only (mutation) but fails to mention error behavior, transaction handling, return value format, or impact on database state. The existence of an output schema partially compensates, but the description itself lacks detail.

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?

Two sentences, front-loaded with purpose and critical condition. No redundant information; every word is necessary.

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?

For a tool with one required parameter, no annotations, and an output schema not described, the description is incomplete. It does not explain what the tool returns or error scenarios. While the output schema might cover return values, the agent cannot infer behavior from the description alone.

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

Parameters1/5

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

The input schema has zero description coverage for the 'query' parameter. The description merely refers to it as a 'write query' with no additional context on allowed SQL syntax, statement composition, or parameter handling. This provides minimal added value beyond the schema itself.

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

Purpose5/5

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

The description clearly states 'Execute a write query on the SQLite database', specifying both the action (execute) and resource (SQLite database). It implicitly distinguishes from sibling tools like 'query' (likely read) and 'describe'/'list_tables' (schema exploration).

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

Usage Guidelines4/5

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

The description provides a clear condition: 'Only works if the database is configured with mode='read-write''. This tells agents when to use the tool and implicitly when not to (read-only mode). However, it does not explicitly name alternative tools for read operations.

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

list_tablesA

List all tables in the SQLite database.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.2/5.0
Behavior3/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. It only states the purpose but does not disclose any behavioral traits like read-only nature or performance implications, though the operation is obviously safe.

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 extremely concise (five words) and front-loaded, containing no unnecessary information.

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

Completeness4/5

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

Given zero parameters and a presumably simple output schema, the description is sufficient. It could mention that it returns table names, but the output schema likely covers that.

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

Parameters4/5

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

The tool has no parameters and schema coverage is 100%, so the description does not need to add parameter info. It appropriately omits such details.

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

Purpose5/5

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

The description explicitly states the action ('List') and the resource ('all tables in the SQLite database'), which is specific and clearly distinguishes from siblings like 'execute' or 'query'.

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

Usage Guidelines4/5

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

The description implies when to use (to get all tables), but does not provide explicit guidance on when not to use or mention alternatives. For a simple tool, this is acceptable but lacks some clarity.

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

queryA

Execute a read-only query on the SQLite database. Only SELECT, SHOW, DESCRIBE, EXPLAIN, WITH are allowed on read-only databases.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior3/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. It discloses the read-only nature and allowed statements, but does not cover error behavior, authentication needs, or what happens if non-allowed queries are attempted. It provides adequate but not exhaustive 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?

Two concise sentences that front-load the purpose and immediately provide constraints. No extraneous information, every word adds value.

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

Completeness4/5

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

For a tool with one parameter and an output schema, the description is fairly complete: it defines allowed queries and read-only semantics. It could mention that results are returned in the output schema, but that is likely documented elsewhere. Overall sufficient for correct usage.

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 one required string parameter without any description. The tool description adds meaning by specifying the query must be a read-only SQL statement (SELECT, etc.), but lacks examples or syntax requirements. This partially compensates for the 0% schema coverage.

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

Purpose5/5

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

The description clearly states the tool executes a read-only query on an SQLite database, listing specific allowed SQL commands (SELECT, SHOW, DESCRIBE, EXPLAIN, WITH). This verb+resource structure effectively distinguishes it from sibling tools like 'execute' (for writes) and 'describe'.

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

Usage Guidelines4/5

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

The description specifies that only certain commands are allowed and that the database is read-only, providing clear context for when to use this tool. However, it does not explicitly mention alternatives like 'execute' for writes, though the sibling list implies such tools exist.

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

statusA

Show connection info: type, host, database, mode, status.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.8/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. It only states 'Show connection info', without mentioning side effects (likely none) or any behavioral traits. For a simple status tool, this is minimal disclosure; it does not explicitly confirm read-only or safe operation.

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 a single, front-loaded sentence with no wasted words. It efficiently conveys the tool's purpose.

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

Completeness4/5

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

Given the tool has no parameters and an output schema exists (which the description is not required to detail), the description adequately lists the information shown. It is complete for a simple status tool, though it could mention that it is a read-only operation.

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

Parameters4/5

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

The tool has zero parameters, so schema coverage is trivially 100%. Per the guidelines, a baseline of 4 is applied since no parameter info is needed; the description does not add parameter semantics beyond the empty schema.

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

Purpose5/5

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

The description clearly states the tool shows connection info, listing specific attributes (type, host, database, mode, status). This distinguishes it from sibling tools like 'describe', 'execute', 'list_tables', and 'query', which serve different purposes.

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 the tool is for retrieving connection details but does not provide explicit guidance on when to use it versus alternatives or any exclusions. The context is clear but lacks explicit usage boundaries.

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

TDQS

A4/5.0
Disambiguation5/5

Each tool has a clear and distinct purpose: describe for table structure, execute for write queries, list_tables for listing tables, query for read queries, and status for connection info. No overlap.

Naming Consistency5/5

All tool names are lowercase, use verbs or verb phrases consistently, and follow a simple pattern (e.g., describe, list_tables). No mixing of conventions.

Tool Count5/5

With 5 tools, the server provides a focused yet complete set for basic SQLite database operations: schema inspection, read/write queries, and status checks. The count feels appropriate for its scope.

Completeness4/5

The tool set covers essential CRUD operations via generic query and execute tools, but lacks specialized tools for common DDL operations like creating tables. This gap is minor given the generic SQL approach.

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

  • A
    license
    Not graded
    quality
    D
    maintenance
    A modular MCP server that enables interaction with multiple database types including PostgreSQL, MySQL, SQLite, Redis, MongoDB, and LDAP. It provides tools for executing queries, managing SQL commands, and exploring database schemas with configurable read-only security.
    20
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A secure multi-database MCP server supporting MySQL, PostgreSQL, and SQLite with read-only enforcement, SQL injection prevention, and tools for schema analysis, performance optimization, and visualization.
    4
  • F
    license
    Not graded
    quality
    D
    maintenance
    A versatile MCP server that connects to multiple relational databases (MySQL, PostgreSQL, Oracle, SQL Server, SQLite) and enables secure read-only SQL query execution and metadata access.
    4
  • F
    license
    Not graded
    quality
    D
    maintenance
    A multi-database MCP server supporting PostgreSQL, ClickHouse, and MySQL that enables database exploration and SQL execution through MCP stdio or HTTP API.

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/stucchi/db-mcp-server'

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