ต้นแบบ · รุ่นทดลอง: มีทุก server ในทะเบียนทางการ อัปเดตทุก 30 นาที รีวิวและบัญชีผู้ใช้จะมาในขั้นถัดไป
PopNx MCPที่รวม MCP สำหรับคนใช้ AI · อธิบายเป็นภาษาคน

Tokenlite Mysql MCP

โดย andezdevรุ่น 4.1.0i★ –iรันบนเครื่อง
ชื่อใน registryio.github.andezdev/tokenlite-mysql-mcp

ติดตั้ง

ภาพรวม

คำอธิบายจากผู้ทำ (ภาษาอังกฤษตามต้นฉบับ)

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

สามเสาของ PopNx MCP

สามเรื่องนี้ไม่รวมเป็นคะแนนเดียว เพราะความเห็น การวัด และความนิยม เป็นคนละเรื่องกัน

ใช้ทำอะไรได้

ตัวนี้ยังไม่ได้เรียบเรียงเป็นภาษาไทย ด้านล่างคือข้อเท็จจริงที่เราอ่านจาก registry

  • การเชื่อมต่อ: รันบนเครื่อง
  • ช่องทาง (transport): stdio
  • หมวด: ฐานข้อมูลและชุดข้อมูล
  • ต้องใส่ค่าเหล่านี้: DB_PASSWORD, DB_NAME

ติดตั้ง

เลือกโปรแกรม AI ที่คุณใช้ แล้วคัดลอกค่าตั้งไปวาง

ก่อนติดตั้ง

  • ผลตรวจเบื้องต้น: ผ่าน 1 จาก 1 ข้อ
  • รันในเครื่องคุณด้วยสิทธิ์ของผู้ใช้คุณ (ไฟล์ อินเทอร์เน็ต แอปต่าง ๆ)
  • ค่าที่คุณต้องใส่เอง: DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME, MCP_EXPLAIN_MAX_SCAN_ROWS, MCP_QUERY_ROW_LIMIT, MCP_SAFE_QUERY_MAX_ROWS, MCP_SAFE_QUERY_ENABLE_BLOCKING, MCP_METADATA_PATH, MCP_TEMPLATES_PATH, TOOL_PREFIX, MCP_RATE_LIMIT_RPM, MYSQL_QUERY_TIMEOUT, MYSQL_CONNECTION_LIMIT, MYSQL_CONNECT_TIMEOUT, MYSQL_RETRY_ATTEMPTS, MYSQL_RETRY_DELAY_MS, MYSQL_QUEUE_LIMIT, MCP_DDL_CACHE_TTL, MCP_LOG_LEVEL, ALLOW_INSERT_OPERATION, ALLOW_UPDATE_OPERATION, ALLOW_DELETE_OPERATION, ALLOW_DDL_OPERATION, DB_SSL, DB_SSL_REJECT_UNAUTHORIZED

ค่าที่ติดป้ายความลับคือกุญแจของบัญชีคุณ อย่าส่งให้ใคร และอย่าวางในแชต

ต้องเตรียมก่อน

  • npmติดตั้ง Node.js (มีคำสั่ง npx) ในเครื่อง

คุณใช้แอปไหน

เลือกแอปด้านบน เราจำไว้ให้ ครั้งหน้าปุ่มจะขึ้นว่า “ติดตั้งลง …”

เปิด Claude Desktop → Settings → Developer → Edit Config แล้ววางค่านี้ในไฟล์ claude_desktop_config.json

{
  "mcpServers": {
    "tokenlite-mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@andezdev/tokenlite-mysql-mcp"
      ],
      "env": {
        "DB_HOST": "ใส่ค่าของคุณ",
        "DB_PORT": "ใส่ค่าของคุณ",
        "DB_USER": "ใส่ค่าของคุณ",
        "DB_PASSWORD": "ใส่ค่าของคุณ",
        "DB_NAME": "ใส่ค่าของคุณ",
        "MCP_EXPLAIN_MAX_SCAN_ROWS": "ใส่ค่าของคุณ",
        "MCP_QUERY_ROW_LIMIT": "ใส่ค่าของคุณ",
        "MCP_SAFE_QUERY_MAX_ROWS": "ใส่ค่าของคุณ",
        "MCP_SAFE_QUERY_ENABLE_BLOCKING": "ใส่ค่าของคุณ",
        "MCP_METADATA_PATH": "ใส่ค่าของคุณ",
        "MCP_TEMPLATES_PATH": "ใส่ค่าของคุณ",
        "TOOL_PREFIX": "ใส่ค่าของคุณ",
        "MCP_RATE_LIMIT_RPM": "ใส่ค่าของคุณ",
        "MYSQL_QUERY_TIMEOUT": "ใส่ค่าของคุณ",
        "MYSQL_CONNECTION_LIMIT": "ใส่ค่าของคุณ",
        "MYSQL_CONNECT_TIMEOUT": "ใส่ค่าของคุณ",
        "MYSQL_RETRY_ATTEMPTS": "ใส่ค่าของคุณ",
        "MYSQL_RETRY_DELAY_MS": "ใส่ค่าของคุณ",
        "MYSQL_QUEUE_LIMIT": "ใส่ค่าของคุณ",
        "MCP_DDL_CACHE_TTL": "ใส่ค่าของคุณ",
        "MCP_LOG_LEVEL": "ใส่ค่าของคุณ",
        "ALLOW_INSERT_OPERATION": "ใส่ค่าของคุณ",
        "ALLOW_UPDATE_OPERATION": "ใส่ค่าของคุณ",
        "ALLOW_DELETE_OPERATION": "ใส่ค่าของคุณ",
        "ALLOW_DDL_OPERATION": "ใส่ค่าของคุณ",
        "DB_SSL": "ใส่ค่าของคุณ",
        "DB_SSL_REJECT_UNAUTHORIZED": "ใส่ค่าของคุณ"
      }
    }
  }
}

พิมพ์คำสั่งนี้ใน Terminal

claude mcp add tokenlite-mysql --env DB_HOST='ใส่ค่าของคุณ' --env DB_PORT='ใส่ค่าของคุณ' --env DB_USER='ใส่ค่าของคุณ' --env DB_PASSWORD='ใส่ค่าของคุณ' --env DB_NAME='ใส่ค่าของคุณ' --env MCP_EXPLAIN_MAX_SCAN_ROWS='ใส่ค่าของคุณ' --env MCP_QUERY_ROW_LIMIT='ใส่ค่าของคุณ' --env MCP_SAFE_QUERY_MAX_ROWS='ใส่ค่าของคุณ' --env MCP_SAFE_QUERY_ENABLE_BLOCKING='ใส่ค่าของคุณ' --env MCP_METADATA_PATH='ใส่ค่าของคุณ' --env MCP_TEMPLATES_PATH='ใส่ค่าของคุณ' --env TOOL_PREFIX='ใส่ค่าของคุณ' --env MCP_RATE_LIMIT_RPM='ใส่ค่าของคุณ' --env MYSQL_QUERY_TIMEOUT='ใส่ค่าของคุณ' --env MYSQL_CONNECTION_LIMIT='ใส่ค่าของคุณ' --env MYSQL_CONNECT_TIMEOUT='ใส่ค่าของคุณ' --env MYSQL_RETRY_ATTEMPTS='ใส่ค่าของคุณ' --env MYSQL_RETRY_DELAY_MS='ใส่ค่าของคุณ' --env MYSQL_QUEUE_LIMIT='ใส่ค่าของคุณ' --env MCP_DDL_CACHE_TTL='ใส่ค่าของคุณ' --env MCP_LOG_LEVEL='ใส่ค่าของคุณ' --env ALLOW_INSERT_OPERATION='ใส่ค่าของคุณ' --env ALLOW_UPDATE_OPERATION='ใส่ค่าของคุณ' --env ALLOW_DELETE_OPERATION='ใส่ค่าของคุณ' --env ALLOW_DDL_OPERATION='ใส่ค่าของคุณ' --env DB_SSL='ใส่ค่าของคุณ' --env DB_SSL_REJECT_UNAUTHORIZED='ใส่ค่าของคุณ' -- npx -y @andezdev/tokenlite-mysql-mcp

เติมค่าที่เว้นว่างไว้ก่อนรัน

เปิดใน Cursor

หรือคัดลอกค่าตั้งเอง

วางในไฟล์ .cursor/mcp.json ของโปรเจกต์ หรือ ~/.cursor/mcp.json

{
  "mcpServers": {
    "tokenlite-mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@andezdev/tokenlite-mysql-mcp"
      ],
      "env": {
        "DB_HOST": "ใส่ค่าของคุณ",
        "DB_PORT": "ใส่ค่าของคุณ",
        "DB_USER": "ใส่ค่าของคุณ",
        "DB_PASSWORD": "ใส่ค่าของคุณ",
        "DB_NAME": "ใส่ค่าของคุณ",
        "MCP_EXPLAIN_MAX_SCAN_ROWS": "ใส่ค่าของคุณ",
        "MCP_QUERY_ROW_LIMIT": "ใส่ค่าของคุณ",
        "MCP_SAFE_QUERY_MAX_ROWS": "ใส่ค่าของคุณ",
        "MCP_SAFE_QUERY_ENABLE_BLOCKING": "ใส่ค่าของคุณ",
        "MCP_METADATA_PATH": "ใส่ค่าของคุณ",
        "MCP_TEMPLATES_PATH": "ใส่ค่าของคุณ",
        "TOOL_PREFIX": "ใส่ค่าของคุณ",
        "MCP_RATE_LIMIT_RPM": "ใส่ค่าของคุณ",
        "MYSQL_QUERY_TIMEOUT": "ใส่ค่าของคุณ",
        "MYSQL_CONNECTION_LIMIT": "ใส่ค่าของคุณ",
        "MYSQL_CONNECT_TIMEOUT": "ใส่ค่าของคุณ",
        "MYSQL_RETRY_ATTEMPTS": "ใส่ค่าของคุณ",
        "MYSQL_RETRY_DELAY_MS": "ใส่ค่าของคุณ",
        "MYSQL_QUEUE_LIMIT": "ใส่ค่าของคุณ",
        "MCP_DDL_CACHE_TTL": "ใส่ค่าของคุณ",
        "MCP_LOG_LEVEL": "ใส่ค่าของคุณ",
        "ALLOW_INSERT_OPERATION": "ใส่ค่าของคุณ",
        "ALLOW_UPDATE_OPERATION": "ใส่ค่าของคุณ",
        "ALLOW_DELETE_OPERATION": "ใส่ค่าของคุณ",
        "ALLOW_DDL_OPERATION": "ใส่ค่าของคุณ",
        "DB_SSL": "ใส่ค่าของคุณ",
        "DB_SSL_REJECT_UNAUTHORIZED": "ใส่ค่าของคุณ"
      }
    }
  }
}

เบราว์เซอร์จะถามก่อนเปิดแอป จากนั้นแอปแสดงค่าตั้งให้ตรวจแล้วกดยืนยัน ช่อง key เว้นว่างไว้ให้คุณใส่เอง

เปิดใน VS Code

หรือคัดลอกค่าตั้งเอง

วางในไฟล์ .vscode/mcp.json ของโปรเจกต์

{
  "servers": {
    "tokenlite-mysql": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@andezdev/tokenlite-mysql-mcp"
      ],
      "env": {
        "DB_HOST": "ใส่ค่าของคุณ",
        "DB_PORT": "ใส่ค่าของคุณ",
        "DB_USER": "ใส่ค่าของคุณ",
        "DB_PASSWORD": "ใส่ค่าของคุณ",
        "DB_NAME": "ใส่ค่าของคุณ",
        "MCP_EXPLAIN_MAX_SCAN_ROWS": "ใส่ค่าของคุณ",
        "MCP_QUERY_ROW_LIMIT": "ใส่ค่าของคุณ",
        "MCP_SAFE_QUERY_MAX_ROWS": "ใส่ค่าของคุณ",
        "MCP_SAFE_QUERY_ENABLE_BLOCKING": "ใส่ค่าของคุณ",
        "MCP_METADATA_PATH": "ใส่ค่าของคุณ",
        "MCP_TEMPLATES_PATH": "ใส่ค่าของคุณ",
        "TOOL_PREFIX": "ใส่ค่าของคุณ",
        "MCP_RATE_LIMIT_RPM": "ใส่ค่าของคุณ",
        "MYSQL_QUERY_TIMEOUT": "ใส่ค่าของคุณ",
        "MYSQL_CONNECTION_LIMIT": "ใส่ค่าของคุณ",
        "MYSQL_CONNECT_TIMEOUT": "ใส่ค่าของคุณ",
        "MYSQL_RETRY_ATTEMPTS": "ใส่ค่าของคุณ",
        "MYSQL_RETRY_DELAY_MS": "ใส่ค่าของคุณ",
        "MYSQL_QUEUE_LIMIT": "ใส่ค่าของคุณ",
        "MCP_DDL_CACHE_TTL": "ใส่ค่าของคุณ",
        "MCP_LOG_LEVEL": "ใส่ค่าของคุณ",
        "ALLOW_INSERT_OPERATION": "ใส่ค่าของคุณ",
        "ALLOW_UPDATE_OPERATION": "ใส่ค่าของคุณ",
        "ALLOW_DELETE_OPERATION": "ใส่ค่าของคุณ",
        "ALLOW_DDL_OPERATION": "ใส่ค่าของคุณ",
        "DB_SSL": "ใส่ค่าของคุณ",
        "DB_SSL_REJECT_UNAUTHORIZED": "ใส่ค่าของคุณ"
      }
    }
  }
}

เบราว์เซอร์จะถามก่อนเปิดแอป จากนั้นแอปแสดงค่าตั้งให้ตรวจแล้วกดยืนยัน ช่อง key เว้นว่างไว้ให้คุณใส่เอง

ตัวนี้รันในเครื่องคุณ แต่ ChatGPT ต่อได้เฉพาะ server บนอินเทอร์เน็ต ลองเลือกแอปอื่น

ตัวเลือกเก็บในคุกกี้บนเครื่องนี้ ไม่ต้องมีบัญชี

ค่าที่ต้องใส่เอง

  • DB_HOST env
    MySQL Host address (defaults to localhost)
  • DB_PORT env
    MySQL Port (defaults to 3306)
  • DB_USER env
    MySQL Username (defaults to root)
  • DB_PASSWORD ความลับ env
    MySQL Password (defaults to empty string)
  • DB_NAME จำเป็น env
    MySQL Database name
  • MCP_EXPLAIN_MAX_SCAN_ROWS env
    EXPLAIN guardrail: max estimated rows for unindexed full table scans before blocking (defaults to 1000). MCP_SAFE_QUERY_MAX_ROWS is a deprecated alias.
  • MCP_QUERY_ROW_LIMIT env
    Max rows returned per SELECT; injected as LIMIT at the AST level (defaults to 500)
  • MCP_SAFE_QUERY_MAX_ROWS env
    Deprecated alias for MCP_EXPLAIN_MAX_SCAN_ROWS
  • MCP_SAFE_QUERY_ENABLE_BLOCKING env
    Enable or disable the EXPLAIN guardrail (defaults to true)
  • MCP_METADATA_PATH env
    Absolute path to your custom metadata.json dictionary
  • MCP_TEMPLATES_PATH env
    Absolute path to your custom templates.json pre-approved queries
  • TOOL_PREFIX env
    Prefix for tool names, e.g., to run multiple instances (defaults to DB_NAME, e.g. mydb_). Only set to override.
  • MCP_RATE_LIMIT_RPM env
    Max tool invocations per minute, sliding window (defaults to 60). Set to 0 to disable.
  • MYSQL_QUERY_TIMEOUT env
    Max execution time for a query in milliseconds to protect against DoS (defaults to 15000)
  • MYSQL_CONNECTION_LIMIT env
    Max concurrent pool connections (defaults to 10)
  • MYSQL_CONNECT_TIMEOUT env
    Max time to wait for a connection socket to establish in milliseconds (defaults to 10000)
  • MYSQL_RETRY_ATTEMPTS env
    Max retries on transient connection errors (defaults to 3)
  • MYSQL_RETRY_DELAY_MS env
    Base delay in milliseconds for exponential backoff between retries (defaults to 1000)
  • MYSQL_QUEUE_LIMIT env
    Max queued requests when all pool connections are busy to prevent memory leak (defaults to 50)
  • MCP_DDL_CACHE_TTL env
    Time-to-live in seconds for cached DDL statements (defaults to 60)
  • MCP_LOG_LEVEL env
    Minimum severity level for MCP log notifications (defaults to info). Levels: debug, info, notice, warning, error, critical, alert, emergency
  • ALLOW_INSERT_OPERATION env
    Enable INSERT and REPLACE queries (defaults to false)
  • ALLOW_UPDATE_OPERATION env
    Enable UPDATE queries (defaults to false)
  • ALLOW_DELETE_OPERATION env
    Enable DELETE and TRUNCATE queries (defaults to false)
  • ALLOW_DDL_OPERATION env
    Enable Data Definition Language queries like CREATE, ALTER, DROP, RENAME (defaults to false)
  • DB_SSL env
    Enable TLS for the MySQL connection (defaults to false)
  • DB_SSL_REJECT_UNAUTHORIZED env
    Reject self-signed or untrusted TLS certificates when DB_SSL is true (defaults to true)

ค่าตั้งนี้สร้างจากข้อมูลใน registry ของผู้ทำ ถ้าไม่ตรงกับ README ให้เชื่อ README

ทำอะไรได้บ้าง

รันในเครื่องคุณ รายการเครื่องมือจะขึ้นในแอป AI หลังติดตั้ง

ผลตรวจเบื้องต้นi

เราตรวจจากข้อมูลที่ใครก็เปิดดูได้ ยังไม่ได้อ่านโค้ด ข้อที่ไม่เกี่ยวกับตัวนี้ไม่นับในตัวหาร · ตรวจเมื่อ 6 พ.ย. 2569

  • ✓ ผ่าน

    ตัวตนผู้ทำตรงกับ repo

    ชื่อใน registry ยืนยันด้วยบัญชี GitHub andezdev ซึ่งเป็นเจ้าของ repo

  • … ยังไม่ตรวจ

    ยังมีคนดูแล

    ยังไม่ได้อ่านข้อมูล repo จาก GitHub

  • … ยังไม่ตรวจ

    มีสัญญาอนุญาต (license)

    ยังไม่ได้อ่านข้อมูล repo จาก GitHub

  • – ไม่เกี่ยว

    endpoint ตอบ

    ตัวนี้รันบนเครื่องคุณ ไม่มี endpoint บนอินเทอร์เน็ต

  • – ไม่เกี่ยว

    ล็อกอินแบบ OAuth

    ตัวนี้รันบนเครื่อง ใช้ค่าที่ตั้งในเครื่องแทน

  • … ยังไม่ตรวจ

    คำอธิบายเครื่องมือไม่มีคำสั่งแอบแฝง

    รันในเครื่องคุณ เราอ่านรายการเครื่องมือได้เฉพาะตัวที่มี endpoint บนอินเทอร์เน็ต

เทียบกับตัวอื่นในหมวด ฐานข้อมูลและชุดข้อมูลi

  • ดาวมากกว่า 0% ของอีก 953 ตัวในหมวดนี้
  • ส่งรุ่นใหม่เข้า registry ล่าสุดกว่า 14% ของอีก 953 ตัวในหมวดนี้
  • ผลตรวจเบื้องต้นดีกว่าหรือเท่ากับ 100% ของอีก 953 ตัวในหมวดนี้

เทียบกับทุก server ที่ยังใช้งานในหมวดนี้ทั้งทะเบียน ดาวนับเฉพาะเมื่อผู้ลงทะเบียนเป็นเจ้าของ repo

คำถามที่พบบ่อย

Tokenlite Mysql MCP ปลอดภัยไหม?

จากการตรวจเบื้องต้นของเรา ผ่าน 1 จาก 1 ข้อที่ตรวจได้ เรายังไม่ได้อ่านโค้ด ก่อนใส่กุญแจหรือ token ให้ดูว่า server ขอสิทธิ์อะไร และเลือกกุญแจที่ทำได้เท่าที่จำเป็น

ต้องใช้กุญแจหรือรหัสอะไรบ้าง?

ต้องใส่ค่าเหล่านี้: DB_PASSWORD, DB_NAME

ตัวนี้รันบนเครื่องหรือบนคลาวด์?

รันบนเครื่องของคุณ โปรแกรม AI จะเปิด server ขึ้นมาเองเมื่อใช้ ข้อมูลไม่ต้องผ่านเซิร์ฟเวอร์ของผู้ทำ (ยกเว้นตัวที่ไปเรียกบริการออนไลน์ต่อ)

ยังมีคนดูแลอยู่ไหม?

repo บน GitHub มีการแก้โค้ดล่าสุด – และส่งรุ่นล่าสุด (4.1.0) เข้า registry 5 เดือนที่ผ่านมา

ใช้กับโปรแกรมไหนได้บ้าง?

โปรแกรมที่รองรับ MCP เช่น Claude Desktop, Claude Code, Cursor และ VS Code ตัวนี้ต้องมี Node.js ในเครื่องด้วย

มีตัวไหนใช้แทนได้บ้าง?

ในหมวดเดียวกันมี Supabase, MongoDB MCP Server, Elasticsearch MCP Server

ตัวที่ใช้แทนได้

server หมวดเดียวกันจากผู้ทำคนอื่น เรียงตามดาว

อ่านการ์ด:★ ดาว GitHubiสามเสา: รีวิว · ผลตรวจ · การใช้งานiอัปเดต = วันที่ส่งรุ่นล่าสุดเข้า registryi

Supabase

โดย supabase

server ทางการของ Supabase ให้ AI สร้างตาราง ถามข้อมูล และดูการตั้งค่าโปรเจกต์ในฐานข้อมูล Supabase ของคุณ

บนเครื่องหรือคลาวด์★ 2,993Apache-2.0อัปเดต วันนี้
ติดตั้ง

MongoDB MCP Server

โดย mongodb-js

MongoDB Model Context Protocol Server

รันบนเครื่อง★ 1,157Apache-2.0อัปเดต เมื่อวานซืน
ติดตั้ง

Elasticsearch MCP Server

โดย cr7258

MCP server for interacting with Elasticsearch

รันบนเครื่อง★ 315Apache-2.0อัปเดต 14 เดือนที่ผ่านมา
ติดตั้ง

README จากผู้ทำ

เปิดอ่าน README

ส่วนนี้คัดจาก repo ของผู้ทำตามต้นฉบับ PopNx MCP ไม่ได้ตรวจหรือรับรองเนื้อหา ตัด HTML รูปภาพ และสคริปต์ออกแล้ว ลิงก์จะพาออกนอกเว็บ

TokenLite MySQL MCP

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 with unambiguous NULL representation (∅), saving up to 50% of Output Tokens compared to verbose JSON. When results hit the applied LIMIT, a -- rows: N (truncated at LIMIT X) footer is appended so the LLM does not assume a complete dataset.
  7. MCP Completions: Table names and template keywords support the official completions/complete capability for resource templates (mysql://tables/{name}) and the query_templates prompt.

📋 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_EXPLAIN_MAX_SCAN_ROWS": "1000", "MCP_QUERY_ROW_LIMIT": "500", "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

Understanding Query Limits (two independent knobs)

execute_safe_query applies two separate limits. Do not confuse them:

VariableWhat it controlsDefaultExample
MCP_EXPLAIN_MAX_SCAN_ROWSSecurity gate: blocks queries whose EXPLAIN plan shows a full table scan (type: ALL) with more estimated rows than this threshold. The query is rejected *before* execution.10005000 allows scanning tables up to ~5000 rows without an index
MCP_QUERY_ROW_LIMITResult cap: max rows returned to the LLM. Injected as LIMIT at the AST level. When reached, CSV includes -- rows: N (truncated at LIMIT X).5001000 returns up to 1000 rows per SELECT

Deprecated alias: MCP_SAFE_QUERY_MAX_ROWS still works as a fallback for MCP_EXPLAIN_MAX_SCAN_ROWS only. It does not control the result LIMIT.

Worked example with MCP_EXPLAIN_MAX_SCAN_ROWS=5000 and MCP_QUERY_ROW_LIMIT=500 on a customers table (~1502 rows):

  1. SELECT * FROM customers → passes EXPLAIN (1502 < 5000), executes with LIMIT 500, returns 500 rows + truncation footer.
  2. Same config but table has 8000 rows → blocked by EXPLAIN before execution.
VariableDescriptionDefaultRequired
DB_HOSTMySQL Host addresslocalhostNo
DB_PORTMySQL Port3306No
DB_USERMySQL UsernamerootNo
DB_PASSWORDMySQL Password''No
DB_NAMEMySQL Database nametestYes
MCP_EXPLAIN_MAX_SCAN_ROWSEXPLAIN guardrail: max estimated rows for unindexed full table scans before blocking.1000No
MCP_QUERY_ROW_LIMITMax rows returned per SELECT (AST-injected LIMIT + truncation footer).500No
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).Derived from DB_NAME (e.g., mydb_). Random fallback only if DB_NAME is unset.No
MCP_RATE_LIMIT_RPMMax tool invocations per minute (sliding window). Set to 0 to disable.60No
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
DB_SSLEnable TLS for the MySQL connection (recommended for managed/cloud databases).falseNo
DB_SSL_REJECT_UNAUTHORIZEDReject self-signed or untrusted TLS certificates when DB_SSL=true.trueNo

🛡️ 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" } }

Custom Relationships

Define FK mappings the heuristic engine can't auto-detect (e.g., created_by → users). Add a _relationships key to your metadata.json:

{

"orders.status": { "pending": "...", "shipped": "..." }, "_relationships": { "orders.created_by": "users.id", "categories.parent_id": "categories.id" } }

These are treated as authoritative (not heuristic) and take priority over automatic detection.

The heuristic engine also assigns a confidence score (0–100) to each inferred FK based on name matching (+40), data type validation (+30), primary key verification (+20), and index presence (+10). Only FKs scoring ≥70 are accepted.

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 (9 tables, Test DB)2,208 tokens531 tokens75.9%

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. When the row count reaches the server-injected LIMIT, results include a truncation footer (e.g. -- rows: 500 (truncated at LIMIT 500)) so agents know more data may exist.

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

Rows ReturnedStandard MCP Pattern (Tokens)TokenLite CSV (Tokens)📉 Output Savings (%)
10 rows

ตัดมาแค่ช่วงต้น อ่านต่อใน repo

ถาม PopNx