Skip to main content
Glama
riefer02

mysql-db-reader

by riefer02

MySQL Reader (read-only)

Read-only MySQL tools for xmcp. Connect via a connection-string env var; all operations are read-only.

Prerequisites

  • Node 20+

  • pnpm

Install & build

pnpm i
pnpm build

Configure database connection

Set one of (first found wins): MYSQL_URL, MYSQL_CONNECTION_STRING, or DATABASE_URL.

export MYSQL_URL="mysql://user:password@localhost:3306/mydb"

SSL is controlled by MYSQL_SSL (default: "true"):

Value

Behavior

true (default)

Encrypted, skips cert hostname validation — use when connecting through a tunnel or proxy

strict

Encrypted, validates server certificate — use for direct connections with a valid cert

false

No SSL — local dev only

export MYSQL_SSL=true    # tunnel / hosted DB (default)
export MYSQL_SSL=strict  # direct connection, valid cert
export MYSQL_SSL=false   # local dev, no SSL

Use in Cursor (STDIO)

Via npx (after publishing to npm — no local clone needed):

{
  "mcpServers": {
    "mysql-reader": {
      "command": "npx",
      "args": ["-y", "mysql-db-reader"],
      "env": { "MYSQL_URL": "mysql://user:password@host:3306/db" }
    }
  }
}

Local build (after pnpm build):

{
  "mcpServers": {
    "mysql-reader": {
      "command": "node",
      "args": ["/ABSOLUTE/PATH/TO/mysql-db-reader/dist/stdio.js"],
      "env": { "MYSQL_URL": "mysql://user:password@host:3306/db" }
    }
  }
}

Use via HTTP (optional)

pnpm dev

Then point your MCP client to http://localhost:3002/mcp.

To use a different port (e.g., 3001):

export MYSQL_URL="mysql://user:password@localhost:3306/mydb"
PORT=3001 pnpm dev

Example HTTP client config (TOML):

[mcp_servers.mysql-reader]
transport = "http"
url = "http://127.0.0.1:3001/mcp"
project = "/ABSOLUTE/PATH/TO/your/project"

Tools

  • mysql_list_databases(includeSystem=false) — list databases

  • mysql_list_tables(database, includeViews=true) — list tables/views

  • mysql_get_table_schema(database, table) — columns/constraints/indexes

  • mysql_preview_table(database, table, limit=50, orderBy?) — sample rows

  • mysql_query(sql, params?) — read-only SQL (SELECT/SHOW/DESC/EXPLAIN/WITH), max 10k rows

  • mysql_explain_query(sql) — EXPLAIN a SELECT

Codex compatibility

Tool names use lowercase snake_case (underscores, no dots) to comply with Codex's tool name pattern ^[a-zA-Z0-9_-]+$ (Codex models prefer lower_snake). See: MCP in Codex docs

Read-only is enforced via session settings and SQL guards.

Docs: xmcp docs

Available Tools

6 tools
mysql_explain_queryA
Read-onlyIdempotent

Run EXPLAIN on a SELECT query to show the query execution plan. Use this to analyze query performance and identify missing indexes.

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYesA read-only SELECT query to EXPLAIN. Use the same SQL you would run in mysql

TDQS

A3.8/5.0
Behavior3/5

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

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint. The description adds context about showing execution plans but does not disclose potential output limitations or error conditions. Given annotations, it is adequate.

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 short, front-loaded sentences with no unnecessary words, efficiently conveying purpose and usage.

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?

No output schema exists, yet the description does not explain the return format or mention that only SELECT queries are allowed (though the schema implies it). This leaves a gap in completeness.

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?

Schema coverage is 100% and the schema description already explains the sql parameter. The tool description does not add further parameter meaning, meeting the baseline.

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 runs EXPLAIN on a SELECT query to show the execution plan, distinguishing it from sibling tools like mysql_query which execute queries.

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 explicitly recommends the tool for analyzing query performance and identifying missing indexes, providing clear usage context. However, it does not explicitly exclude non-SELECT queries or mention alternatives like mysql_query.

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

mysql_get_table_schemaA
Read-onlyIdempotent

Get table column definitions, primary key, indexes, and constraints. Use this to understand table structure before writing queries.

ParametersJSON Schema
NameRequiredDescriptionDefault
tableYesTable name
databaseYesDatabase (schema) name

TDQS

A4/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false. Description adds the kinds of information returned (columns, pk, indexes, constraints), but no extra behavioral details like error conditions or performance impact.

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, no redundancy, front-loaded with essential information and a usage hint. Every sentence earns its place.

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's simplicity (two required params, no output schema) and the presence of annotations, the description is complete enough for an agent to understand purpose and usage without gaps.

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?

Schema coverage is 100% with each parameter having a description. The description does not add additional meaning beyond the schema's parameter descriptions.

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?

Description uses a specific verb ('Get') and resource ('table column definitions, primary key, indexes, and constraints'), clearly distinguishing it from siblings like mysql_query or mysql_preview_table.

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?

Includes explicit usage hint: 'Use this to understand table structure before writing queries.' Lacks explicit when-not-to-use or alternative references, but context is clear.

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

mysql_list_databasesA
Read-onlyIdempotent

List available databases (schemas) on the MySQL server. Use this first to discover what databases exist before querying tables.

ParametersJSON Schema
NameRequiredDescriptionDefault
includeSystemNoWhether to include system schemas like mysql, information_schema, performance_schema, sys

TDQS

A3.8/5.0
Behavior3/5

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

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint. The description adds minor behavioral context (usage order) but does not disclose additional traits beyond annotations.

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, front-loaded with the action and purpose. No unnecessary words or repetition.

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 simple list tool with good annotations and clear schema, the description covers the essential purpose and usage. It does not specify output format or the default exclusion of system schemas, but the parameter description fills that gap.

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?

Schema description coverage is 100% for the only parameter (includeSystem). The description adds no extra meaning beyond the schema, so baseline 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 verb 'list' and resource 'databases (schemas)'. It implies this is the first step before querying tables, which distinguishes it from siblings like mysql_list_tables and mysql_query, but does not explicitly name alternatives.

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?

Explicitly says 'Use this first to discover what databases exist before querying tables', providing clear when-to-use guidance. Does not state when not to use, but the context is sufficient.

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

mysql_list_tablesA
Read-onlyIdempotent

List tables (and optionally views) in a database. Use this after mysql_list_databases to discover available tables before querying or inspecting schema.

ParametersJSON Schema
NameRequiredDescriptionDefault
databaseYesDatabase (schema) name
includeViewsNoInclude views in result

TDQS

A4/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true, destructiveHint=false, so the description carries a low burden. It adds that views can be included optionally, which is useful but not beyond what annotations provide. No contradictions.

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 long, front-loaded with the purpose, followed by usage guidance. Every sentence adds value, no redundancy or filler.

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's simplicity, strong annotations, and complete parameter schema, the description is mostly sufficient. It lacks explicit mention of the return format (likely a list of table names), but the name implies it, making it adequate for an agent.

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?

Schema description coverage is 100%, so baseline is 3. The description does not add meaning beyond the schema; it merely restates the database parameter and the optional includeViews. No additional parameter context is provided.

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 'List' and the resource 'tables in a database', including optional views. It also provides a usage context (after mysql_list_databases), making the purpose unambiguous and distinct from siblings.

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 explicitly says 'Use this after mysql_list_databases to discover available tables before querying or inspecting schema.', providing clear context and sequence. It does not explicitly exclude cases or mention alternatives, but the sibling list implies differentiation.

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

mysql_preview_tableA
Read-onlyIdempotent

Preview first N rows from a table with optional ordering. Use this to quickly inspect sample data without writing SQL.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoMax rows to return
tableYesTable name
orderByNoOptional ORDER BY clause of the form 'column [ASC|DESC]'
databaseYesDatabase (schema) name

TDQS

A4/5.0
Behavior3/5

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

Annotations already provide readOnlyHint and idempotentHint, covering safety. Description adds preview behavior but no additional behavioral context beyond what's in schema and annotations.

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, front-loaded with purpose. No fluff.

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?

Tool is simple; description plus schema and annotations cover purpose, parameters, and safety. Lacks mention of output format but acceptable without output schema.

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?

Schema has 100% coverage with descriptions for all 4 parameters. Description adds general behavior but no additional meaning beyond the 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?

Description clearly states the actions (preview first N rows, optional ordering) and distinguishes from siblings like mysql_explain_query and mysql_query by focusing on quick inspection without writing SQL.

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?

Description explicitly says 'use this to quickly inspect sample data without writing SQL', providing clear context. However, it does not explicitly state when not to use or compare to alternatives.

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

mysql_queryA
Read-onlyIdempotent

Run a read-only SQL query with optional positional parameters. For complex queries or when you need JOINs, aggregations, or filtering. Results are limited to 10,000 rows; use LIMIT for large tables.

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYesA read-only SQL statement starting with SELECT, SHOW, DESCRIBE/DESC, EXPLAIN or WITH (select). Include LIMIT clause for large tables.
paramsNoPositional parameters for the query (use ? placeholders in SQL)

TDQS

A4.4/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false. The description adds value beyond these by stating the row limit (10,000) and advising to include LIMIT for large tables. This provides practical behavioral context that the annotations alone do not.

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 concise, with two sentences plus a salient note about row limits. It front-loads the purpose and key guidelines, with no extraneous 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 the absence of an output schema, the description appropriately covers the allowed SQL types (SELECT, SHOW, DESCRIBE, EXPLAIN, WITH select) and the row limit. It does not explain error behavior or response format, but the tool's structure (SQL in, rows out) is standard enough that this is acceptable.

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 coverage is 100%, so the schema fully documents both parameters. The description adds usage guidance (e.g., 'include LIMIT clause for large tables' for the sql parameter, and 'use ? placeholders' for params), which enriches the meaning beyond the schema's basic descriptions.

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 runs a read-only SQL query with optional parameters. It distinguishes from sibling tools by specifying 'For complex queries or when you need JOINs, aggregations, or filtering', which contrasts with the more specialized sibling tools like mysql_list_databases.

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 clear guidance on when to use this tool (complex queries, JOINs, aggregations) and implies when not to (simpler operations). It also gives a practical constraint: 'Results are limited to 10,000 rows; use LIMIT for large tables.' However, it does not explicitly mention alternatives for simpler tasks.

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

TDQS

A4.2/5.0
Disambiguation5/5

Each tool has a clearly distinct purpose: listing databases, listing tables, getting schema, previewing rows, explaining queries, and running arbitrary queries. There is no overlap or ambiguity.

Naming Consistency5/5

All tools follow a consistent 'mysql_verb_noun' pattern (e.g., mysql_list_databases, mysql_preview_table). The naming is uniform and predictable.

Tool Count5/5

With 6 tools, the set is well-scoped for a read-only database server. Each tool earns its place by covering a distinct operation without redundancy or unnecessary bloat.

Completeness4/5

The tool set covers the main workflow: discovery (list databases, list tables), schema inspection, data preview, query execution, and performance analysis. Minor gaps like 'SHOW CREATE TABLE' or view support exist, but the core read-only operations are complete.

Maintenance

ActivitySlowing
ResponsivenessSyncing

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
    C
    maintenance
    Enables read-only interaction with SQL databases through MCP, providing database metadata exploration, sample data retrieval, and secure query execution. Supports MySQL with multiple transport options and built-in security features including SQL injection protection and data sanitization.
    19
    5
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables safe querying and optional writing to MySQL databases via MCP tools, with support for schema inspection, connection management, and read-only mode.
    44
    3
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Enables read-only MySQL database access, allowing listing databases, tables, describing schemas, and executing SELECT/SHOW/DESCRIBE/EXPLAIN queries.
    7
    89
    4
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Provides read-only access to MySQL databases, enabling schema exploration, table inspection, and safe SELECT query execution via MCP.
    1

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/riefer02/mysql-db-reader'

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