How dpflucas/mysql-mcp-server works
This repository is a read-only MySQL MCP server. An MCP client discovers and invokes database tools over stdio; the server dispatches each request, validates arbitrary SQL, executes it through a pooled MySQL connection, and returns rows as JSON text. The tools cover database listing, table listing, schema description, and read-only queries. The connection layer also applies timeouts, row limits, and exact large-number handling. Relationships are based on the shown entry point and connection/validator source; README capability descriptions supplement the documented tool surface.
Main entry points: index.ts MCP entrypoint · connection.ts Query execution · validators.ts SQL validator
Components 11
MCP server
- MCP entrypoint
src/index.ts - Tool discovery
src/index.ts - Tool dispatch
src/index.ts - Result formatting
src/index.ts - Stdio transport
src/index.ts
Database access
- Environment config
src/connection.ts - Connection pool
src/connection.ts - Query execution
src/connection.ts
Query safety
- SQL validator
src/validators.ts
Other components
- MCP client
- MySQL database
Connections 13
- MCP client → Stdio transport: sends requests
src/index.ts - MCP entrypoint → Tool discovery: registers tools
src/index.ts - MCP entrypoint → Tool dispatch: handles calls
src/index.ts - MCP entrypoint → Stdio transport: connects transport
src/index.ts - Tool dispatch → SQL validator: validates SQL
src/index.ts - Tool dispatch → Query execution: executes tools
src/index.ts - Tool dispatch → Result formatting: formats rows
src/index.ts - MCP entrypoint → Environment config: loads settings
src/index.ts - MCP entrypoint → Connection pool: creates pool
src/index.ts - Query execution → Connection pool: acquires connection
src/connection.ts - Query execution → MySQL database: runs SQL
src/connection.ts - Connection pool → MySQL database: connects
src/connection.ts - Stdio transport → MCP client: returns responses
src/index.ts