# tokenlite-mysql-mcp [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/andezdev/tokenlite-mysql-mcp  
**GitHub Stars:** 0  
**npm Downloads (last month):** 484  
**Views:** 2  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/tokenlite-mysql-mcp

## Description
A secure, efficient, and intelligent MySQL server for the Model Context Protocol

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "tokenlite-mysql-mcp": {
    "command": "npx",
    "args": ["-y","@andezdev/tokenlite-mysql-mcp"],
    "env": {
      "DB_NAME": ""
    }
  }
}
```

**Requires environment variables:** `DB_NAME` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What tokenlite-mysql-mcp does

tokenlite-mysql-mcp exposes MySQL database access through the Model Context Protocol. It is intended for agent workflows that need to inspect schemas, run queries, and optionally modify database contents under explicit policy controls.

The default posture is read-only. INSERT, UPDATE, DELETE, and DDL operations can be enabled independently through environment variables. SQL is parsed before execution, including nested subqueries, common table expressions, and UNION branches. The policy rejects access to other schemas and system schemas, several information-disclosure and server-control statements, locking reads, executable comments, and selected dangerous functions.

## How it works

The `execute_safe_query` path uses two separate protections. An EXPLAIN-based gate can reject an unindexed full-table scan when its estimated row count exceeds `MCP_EXPLAIN_MAX_SCAN_ROWS`. A separate `MCP_QUERY_ROW_LIMIT` value caps returned rows by injecting a LIMIT into the parsed query. If the cap is reached, the response includes a truncation marker so an agent can distinguish partial results from a complete result set.

When all write permissions remain disabled, the connection pool also uses a MySQL session-level read-only transaction setting. This adds a database-engine safeguard alongside the SQL parser. Connection pooling, retry controls, queue limits, query timeouts, and request-rate limits provide additional operational controls.

Query results are formatted as CSV-style markdown rather than verbose JSON. NULL values are represented with `∅`, reducing repeated structural tokens in agent context.

Schema exploration can use a custom metadata dictionary and infer likely relationships between tables. When a table is searched, the server packages related join context instead of requiring the full database schema in every response. Semantic templates are exposed through the MCP Prompts API, and table names and template keywords support MCP completion requests.

## Setup and configuration

Run the package with Node.js 20 or newer and connect it to MySQL 5.7 or newer; MySQL 8.0 or later is recommended. The database user should have SELECT permission. `SHOW VIEW` is only relevant when view-definition output is needed.

The required database setting is `DB_NAME`. `DB_HOST`, `DB_PORT`, `DB_USER`, and `DB_PASSWORD` configure the connection and have defaults. A typical stdio launch uses `npx -y @andezdev/tokenlite-mysql-mcp`, with these values supplied in the MCP client's environment configuration.

Set `MCP_METADATA_PATH` and `MCP_TEMPLATES_PATH` to absolute paths when using custom semantic dictionaries or query templates. `TOOL_PREFIX` can distinguish tool names when multiple database instances are configured. Enable TLS with `DB_SSL` for supported managed or cloud database connections.

## Tools and capabilities

- Execute bounded SQL through the safe-query flow.
- Search database schema information and refresh cached DDL.
- Apply EXPLAIN-based full-scan protection and AST-injected row limits.
- Discover tables through the `mysql://tables/{name}` resource template and MCP completions.
- Expose approved analytical query templates through the `query_templates` MCP prompt.
- Enable INSERT, UPDATE, DELETE, or DDL independently through environment settings.
- Return compact CSV-formatted results with explicit NULL and truncation markers.

## Limitations and notes

The SQL policy is defense in depth and does not replace MySQL grants. Write and DDL permissions are disabled by default, but enabling them changes the server's access profile and should match the database user's privileges. Full-table scans can be rejected before execution when their EXPLAIN estimates exceed the configured threshold. Result limits and scan thresholds are independent settings, so increasing one does not change the other.

The server blocks access to schemas outside the configured database, including `information_schema`, `mysql`, `performance_schema`, and `sys`. It also rejects statements and functions associated with file access, delays, locks, server or user variables, and privilege escalation.

_Full upstream README: https://allmcps.com/mcp/tokenlite-mysql-mcp/readme_

