MCP Marketplace
BrowseHow It WorksFor CreatorsDocs
Sign inSign up
MCP Marketplace

The curated, security-first marketplace for AI tools.

Product

Browse ToolsSubmit a ToolDocumentationHow It WorksBlogFAQ

Legal

Terms of ServicePrivacy PolicyCommunity Guidelines

Connect

support@mcp-marketplace.ioTwitter / XDiscord

MCP Marketplace ยฉ 2026. All rights reserved.

Back to Browse

Tokenlite Mysql MCP Server

by Andezdev
Data & AnalyticsLow Risk8.0MCP RegistryLocal
Free

Server data from the Official MCP Registry

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

About

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

Security Report

8.0
Low Risk8.0Low Risk

Valid MCP server (2 strong, 2 medium validity signals). 2 known CVEs in dependencies (0 critical, 2 high severity) Package registry verified. Imported from the Official MCP Registry.

8 files analyzed ยท 3 issues found

Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.

Permissions Required

This plugin requests these system permissions. Most are normal for its category.

env_vars

Check that this permission is expected for this type of plugin.

database

Check that this permission is expected for this type of plugin.

file_system

Check that this permission is expected for this type of plugin.

What You'll Need

Set these up before or after installing:

MySQL Host address (defaults to localhost)Optional

Environment variable: DB_HOST

MySQL Port (defaults to 3306)Optional

Environment variable: DB_PORT

MySQL Username (defaults to root)Optional

Environment variable: DB_USER

MySQL Password (defaults to empty string)Required

Environment variable: DB_PASSWORD

MySQL Database nameOptional

Environment variable: DB_NAME

Threshold for EXPLAIN to block unindexed Full Table Scans (defaults to 1000)Optional

Environment variable: MCP_SAFE_QUERY_MAX_ROWS

Enable or disable the EXPLAIN guardrail (defaults to true)Optional

Environment variable: MCP_SAFE_QUERY_ENABLE_BLOCKING

Absolute path to your custom metadata.json dictionaryOptional

Environment variable: MCP_METADATA_PATH

Absolute path to your custom templates.json pre-approved queriesOptional

Environment variable: MCP_TEMPLATES_PATH

Prefix for tool names, e.g., to run multiple instances (defaults to random prefix like db_a1b2_)Optional

Environment variable: TOOL_PREFIX

Max execution time for a query in milliseconds to protect against DoS (defaults to 15000)Optional

Environment variable: MYSQL_QUERY_TIMEOUT

Max concurrent pool connections (defaults to 10)Optional

Environment variable: MYSQL_CONNECTION_LIMIT

Max time to wait for a connection socket to establish in milliseconds (defaults to 10000)Optional

Environment variable: MYSQL_CONNECT_TIMEOUT

Max retries on transient connection errors (defaults to 3)Optional

Environment variable: MYSQL_RETRY_ATTEMPTS

Base delay in milliseconds for exponential backoff between retries (defaults to 1000)Optional

Environment variable: MYSQL_RETRY_DELAY_MS

Max queued requests when all pool connections are busy to prevent memory leak (defaults to 50)Optional

Environment variable: MYSQL_QUEUE_LIMIT

Time-to-live in seconds for cached DDL statements (defaults to 60)Optional

Environment variable: MCP_DDL_CACHE_TTL

Minimum severity level for MCP log notifications (defaults to info). Levels: debug, info, notice, warning, error, critical, alert, emergencyOptional

Environment variable: MCP_LOG_LEVEL

Enable INSERT and REPLACE queries (defaults to false)Optional

Environment variable: ALLOW_INSERT_OPERATION

Enable UPDATE queries (defaults to false)Optional

Environment variable: ALLOW_UPDATE_OPERATION

Enable DELETE and TRUNCATE queries (defaults to false)Optional

Environment variable: ALLOW_DELETE_OPERATION

Enable Data Definition Language queries like CREATE, ALTER, DROP, RENAME (defaults to false)Optional

Environment variable: ALLOW_DDL_OPERATION

How to Install

Add this to your MCP configuration file:

{
  "mcpServers": {
    "io-github-andezdev-tokenlite-mysql-mcp": {
      "env": {
        "DB_HOST": "your-db-host-here",
        "DB_NAME": "your-db-name-here",
        "DB_PORT": "your-db-port-here",
        "DB_USER": "your-db-user-here",
        "DB_PASSWORD": "your-db-password-here",
        "TOOL_PREFIX": "your-tool-prefix-here",
        "MCP_LOG_LEVEL": "your-mcp-log-level-here",
        "MCP_DDL_CACHE_TTL": "your-mcp-ddl-cache-ttl-here",
        "MCP_METADATA_PATH": "your-mcp-metadata-path-here",
        "MYSQL_QUEUE_LIMIT": "your-mysql-queue-limit-here",
        "MCP_TEMPLATES_PATH": "your-mcp-templates-path-here",
        "ALLOW_DDL_OPERATION": "your-allow-ddl-operation-here",
        "MYSQL_QUERY_TIMEOUT": "your-mysql-query-timeout-here",
        "MYSQL_RETRY_ATTEMPTS": "your-mysql-retry-attempts-here",
        "MYSQL_RETRY_DELAY_MS": "your-mysql-retry-delay-ms-here",
        "MYSQL_CONNECT_TIMEOUT": "your-mysql-connect-timeout-here",
        "ALLOW_DELETE_OPERATION": "your-allow-delete-operation-here",
        "ALLOW_INSERT_OPERATION": "your-allow-insert-operation-here",
        "ALLOW_UPDATE_OPERATION": "your-allow-update-operation-here",
        "MYSQL_CONNECTION_LIMIT": "your-mysql-connection-limit-here",
        "MCP_SAFE_QUERY_MAX_ROWS": "your-mcp-safe-query-max-rows-here",
        "MCP_SAFE_QUERY_ENABLE_BLOCKING": "your-mcp-safe-query-enable-blocking-here"
      },
      "args": [
        "-y",
        "@andezdev/tokenlite-mysql-mcp"
      ],
      "command": "npx"
    }
  }
}

Documentation

View on GitHub

From the project's GitHub README.

TokenLite MySQL MCP

npm version

A robust and secure MySQL database server implemented under Anthropic's Model Context Protocol (MCP). Designed specifically to solve the shortcomings of current generic MCP servers through Graceful Degradation, Active Performance Protection, and Aggressive Token Optimization.


๐ŸŒŸ Core Pillars

  1. Safe-Query Optimizer (AST & EXPLAIN): Protects production databases by pre-analyzing queries. Blocks unindexed Full Table Scans that exceed configurable thresholds and injects strict LIMIT clauses automatically at the AST level.
  2. Granular AST-Based Write Permissions: By default, TokenLite is 100% Read-Only. You can surgically enable specific write operations (INSERT, UPDATE, DELETE, DDL) via environment variables. The firewall uses strict AST parsing to prevent SQL injection and comment-bypass attacks, and strictly prohibits privilege escalation commands (like GRANT or CALL).
  3. Session-Level Defense in Depth: If the server is configured in strict Read-Only mode (all write variables disabled), TokenLite injects SET SESSION TRANSACTION READ ONLY directly into the connection pool sockets. This guarantees that even if a theoretical bypass exists in the AST parser, the MySQL engine itself will physically reject any data modification.
  4. Business Intelligence Injection: Bridges the gap between raw data and company logic. Automatically attaches semantic dictionaries (metadata.json) to database schema exploration, and exposes Semantic Templates via the official MCP Prompts API (templates.json) so the LLM uses pre-approved analytical queries instead of hallucinating them.
  5. Graph-Based Semantic Schema: Avoids sending giant schemas to the LLM that saturate the context window. When a table is searched, the engine uses heuristics to deduce implicit relationships and packages the exact "Auto-Join Context".
  6. CSV Token Compression: Database results are efficiently transformed into tabular CSV markdown, saving up to 60% of Output Tokens compared to verbose JSON.

๐Ÿ“‹ Requirements

  • Node.js v20 or higher
  • MySQL 5.7 or higher (MySQL 8.0+ recommended)
  • A MySQL user with SELECT and SHOW VIEW privileges.

๐Ÿš€ Installation & Usage

You can use this MCP server with any compatible client. Below are the configurations for the most popular ones.

1. Claude Desktop

Edit your claude_desktop_config.json (usually located at %APPDATA%\Claude\claude_desktop_config.json on Windows or ~/Library/Application Support/Claude/claude_desktop_config.json on macOS) and add the following:

Using NPX (Recommended)

{
  "mcpServers": {
    "tokenlite-mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@andezdev/tokenlite-mysql-mcp"
      ],
      "env": {
        "DB_HOST": "localhost",
        "DB_PORT": "3306",
        "DB_USER": "your_db_user",
        "DB_PASSWORD": "your_password",
        "DB_NAME": "your_database",
        "MCP_SAFE_QUERY_MAX_ROWS": "1000",
        "MCP_SAFE_QUERY_ENABLE_BLOCKING": "true"
      }
    }
  }
}

2. Claude Code (CLI)

You can easily integrate this server globally into Claude Code:

claude mcp add tokenlite_mysql \
  -e DB_HOST="127.0.0.1" \
  -e DB_PORT="3306" \
  -e DB_USER="root" \
  -e DB_PASSWORD="your_password" \
  -e DB_NAME="your_database" \
  -- npx -y @andezdev/tokenlite-mysql-mcp

3. Cursor IDE

To use within Cursor IDE:

  1. Open Cursor Settings > Features > MCP.
  2. Click + Add New MCP Server.
  3. Set the Type to command.
  4. Name it tokenlite-mysql.
  5. Set the command to:
    npx -y @andezdev/tokenlite-mysql-mcp
    

(Note: Cursor handles environment variables directly in the IDE UI, make sure to add your DB credentials there).


โš™๏ธ Environment Variables Reference

VariableDescriptionDefaultRequired
DB_HOSTMySQL Host addresslocalhostNo
DB_PORTMySQL Port3306No
DB_USERMySQL UsernamerootNo
DB_PASSWORDMySQL Password''No
DB_NAMEMySQL Database nametestYes
MCP_SAFE_QUERY_MAX_ROWSThreshold for EXPLAIN to block unindexed Full Table Scans.1000No
MCP_SAFE_QUERY_ENABLE_BLOCKINGEnable or disable the EXPLAIN guardrail.trueNo
MCP_METADATA_PATHAbsolute path to your custom metadata.json dictionary.(Disabled)No
MCP_TEMPLATES_PATHAbsolute path to your custom templates.json queries.(Disabled)No
TOOL_PREFIXPrefix for tool names (useful when running multiple instances).Random (e.g., db_a1b2_)No
MYSQL_QUERY_TIMEOUTMax execution time for a query (in ms). Aborts heavy queries to protect against DoS.15000No
MYSQL_CONNECTION_LIMITMax concurrent pool connections.10No
MYSQL_CONNECT_TIMEOUTMax time to wait for a socket to establish (in ms).10000No
MYSQL_RETRY_ATTEMPTSMax retries on transient connection errors (ECONNREFUSED, PROTOCOL_CONNECTION_LOST, etc.).3No
MYSQL_RETRY_DELAY_MSBase delay (ms) for exponential backoff between retries (1s, 2s, 4s...).1000No
MYSQL_QUEUE_LIMITMax queued requests when all pool connections are busy. Prevents unbounded growth if MySQL is down.50No
MCP_DDL_CACHE_TTLTime-to-live (in seconds) for cached DDL statements. Reduces latency on repeated search_schema calls. Invalidated by refresh_schema.60No
MCP_LOG_LEVELMinimum severity for MCP log notifications: debug, info, notice, warning, error, critical, alert, emergency.infoNo
ALLOW_INSERT_OPERATIONEnable INSERT and REPLACE queries.falseNo
ALLOW_UPDATE_OPERATIONEnable UPDATE queries.falseNo
ALLOW_DELETE_OPERATIONEnable DELETE and TRUNCATE queries.falseNo
ALLOW_DDL_OPERATIONEnable Data Definition Language (CREATE, ALTER, DROP, RENAME).falseNo

๐Ÿ›ก๏ธ Business Intelligence Features (Opt-in)

TokenLite can teach the LLM about your company's business rules. To enable this, map the absolute paths of two JSON files via .env or your MCP client config:

metadata.json (Semantic Dictionary)

Translate integer statuses or internal jargon so the LLM understands the data.

{
  "orders.status": {
    "pending": "The order is waiting for payment validation",
    "shipped": "The order has left the warehouse"
  }
}

templates.json (Pre-approved SQL)

Stop the LLM from hallucinating complex metrics by providing vetted templates.

[
  {
    "name": "Customer Lifetime Value (LTV)",
    "description": "Calculates total revenue generated by delivered orders per customer.",
    "sql": "SELECT c.id, SUM(oi.price) FROM customers c JOIN orders o... WHERE o.status='delivered'"
  }
]

๐Ÿ“ˆ Benchmarks & Token Savings

TokenLite includes an automated benchmark suite using o200k_base tokenization (GPT-4o/GPT-5 standard) to measure efficiency improvements. Token counts are approximate โ€” Claude 4.x uses a proprietary tokenizer; actual counts may vary slightly.

To run the benchmark in your own environment:

npm run benchmark

Baseline: Standard MCP Pattern

The benchmark compares against the standard pattern used by generic MySQL MCP servers: full schema exposed as information_schema.columns in pretty-printed JSON, and query results returned as JSON.stringify(rows, null, 2) with execution time metadata.

1. Schema Discovery (Input Tokens)

Standard MCP servers dump the entire schema to the LLM. For large databases, this consumes thousands of input tokens on every turn. TokenLite's relational graph serves a localized Auto-Join Context (target table + direct parent tables + direct child tables).

ScenarioStandard MCP PatternTokenLite๐Ÿ“‰ Savings
Mock (50 tables, Enterprise CRM)15,566 tokens883 tokens94.3%
Live (7 tables, Test DB)1,892 tokens257 tokens86.4%

Savings scale with the number of tables: the more tables in the database, the higher the savings because the standard pattern dumps all of them while TokenLite only fetches the target + 1-hop relationships.

2. Query Result Payloads (Output Tokens)

TokenLite converts raw database rows to a dense, structured CSV layout. This avoids JSON syntax overhead (brackets, braces, repeated keys) and compresses the output payload returned to the LLM.

Mock data (varied: NULLs, long descriptions, mixed lengths):

Rows ReturnedStandard MCP Pattern (Tokens)TokenLite CSV (Tokens)๐Ÿ“‰ Output Savings (%)
10 rows1,16759249.3%
50 rows5,8052,87550.5%
100 rows11,6075,73450.6%
500 rows57,99828,57850.7%

Live data (real MySQL test database with NULLs, ENUMs, variable-length text):

Rows ReturnedStandard MCP Pattern (Tokens)TokenLite CSV (Tokens)๐Ÿ“‰ Output Savings (%)
10 rows1,00757542.9%
50 rows5,0292,84543.4%
100 rows10,0715,69943.4%
500 rows50,32728,44143.5%

๐Ÿ“Š Logging & Observability

TokenLite uses MCP-native logging via notifications/message instead of raw stderr output. Clients that support MCP logging (e.g., MCP Inspector) will receive structured log messages with severity levels, logger names, and JSON data.

Severity levels (from least to most severe): debug, info, notice, warning, error, critical, alert, emergency.

The server emits logs at info level and above by default. Control the minimum level via MCP_LOG_LEVEL or dynamically at runtime through the MCP logging/setLevel request.

Before the MCP session is established (e.g., during pool initialization), logs fall back to stderr.


๐ŸŒ Advanced Networking & Remote Connections

By design, tokenlite-mysql-mcp adheres to the Unix philosophy: it does one thing (AI-driven MySQL interactions) and does it securely via the standard stdio transport. It deliberately avoids bloating the codebase with HTTP servers or built-in SSH clients.

If you need to connect to remote databases or expose this server over the network, here are the recommended, enterprise-grade alternatives:

1. Connecting to Remote Databases (SSH Tunnels)

Instead of embedding SSH libraries, we recommend using native OS tunnels. This is much more secure, respects your ~/.ssh/config, and supports advanced authentication (2FA, hardware keys).

Simply open a terminal and run:

ssh -N -L 3306:127.0.0.1:3306 user@your-remote-server.com

Then, point tokenlite-mysql-mcp to localhost and port 3306.

2. Exposing the MCP Server over HTTP/Network

If you need to host this MCP Server in the cloud (AWS, GCP) and have multiple Claude desktop clients connect to it remotely via HTTP/SSE, do not modify this codebase to add Express/HTTP logic. Instead, wrap the process using standard open-source MCP proxies like mcp-proxy. This cleanly separates the transport layer security from the AI logic.

๐Ÿ› Troubleshooting

Error: OptimizerError: Full table scan detected... The LLM attempted to execute a query that requires scanning thousands of rows without using an index. Solution: Use explain_query to see the full EXPLAIN output and understand why the query was blocked. Rewrite the query with an indexed WHERE clause. If you truly need to scan the whole table, increase MCP_SAFE_QUERY_MAX_ROWS in your config.

Error: calling "initialize": invalid character... This means the MCP JSON-RPC protocol crashed. Ensure you are passing the correct DB credentials and that the database is running and accessible from the machine where the MCP server runs.


Built for the AI Engineering era.


Reviews

No reviews yet

Be the first to review this server!

0

installs

New

no ratings yet

Is this your server?

Claim ownership to manage your listing, respond to reviews, and track installs from your dashboard.

Claim with GitHub

Sign up with the GitHub account that owns this repo

Links

Source Codenpm Package

Details

Published June 1, 2026
Version 3.1.1
0 installs
Local Plugin

More Data & Analytics MCP Servers

Toleno

Free

by Toleno ยท Developer Tools

Toleno Network MCP Server โ€” Manage your Toleno mining account with Claude AI using natural language.

137
Stars
486
Installs
8.0
Security
4.8
Local

mcp-creator-python

Free

by mcp-marketplace ยท Developer Tools

Create, build, and publish Python MCP servers to PyPI โ€” conversationally.

-
Stars
65
Installs
10.0
Security
4.6
Local

MarkItDown

Free

by Microsoft ยท Content & Media

Convert files (PDF, Word, Excel, images, audio) to Markdown for LLM consumption

120.0K
Stars
22
Installs
6.0
Security
5.0
Local

mcp-creator-typescript

Free

by mcp-marketplace ยท Developer Tools

Scaffold, build, and publish TypeScript MCP servers to npm โ€” conversationally

-
Stars
16
Installs
10.0
Security
5.0
Local

FinAgent

Free

by mcp-marketplace ยท Finance

Free stock data and market news for any MCP-compatible AI assistant.

-
Stars
16
Installs
10.0
Security
No ratings yet
Local

Google Workspace MCP

Free

by Taylorwilsdon ยท Productivity

Control Gmail, Calendar, Docs, Sheets, Drive, and more from your AI

1.6K
Stars
13
Installs
7.0
Security
No ratings yet
Local