- Home
- MCP servers
- MySQL
MySQL
- javascript
4
GitHub Stars
javascript
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
This MCP server provides a lightweight local bridge to your MySQL database, exposing a RESTful API and SSE notifications so you can query, inspect schemas, and stream results from your local setup in a secure, programmatic way.
How to use
You can connect to this MCP server from an MCP client in two primary ways: through the HTTP API or via a local command interface. Use the HTTP method to query databases, fetch table structures, or run parameterized SELECT queries against your local MySQL instance. If you want real-time updates, connect via Server-Sent Events (SSE) to receive ongoing results or notifications. All interactions can be guarded with an API key for basic access control.
How to install
Prerequisites you need on your machine before running this server: a supported Node.js runtime and a running MySQL server.
Run these commands in your terminal to set up and start the service:
# 1) Install dependencies
npm install
# 2) Create and configure environment variables
# Example .env content (adjust values to your setup)
PORT=3000
NODE_ENV=development
DB_HOST=localhost
DB_PORT=3306
DB_USER=your_username
DB_PASSWORD=your_password
DB_NAME=your_database
API_KEY=your_api_key
# 3) Start the server
npm start
# Development mode (auto-restarts on changes)
npm run dev
Additional configuration and usage notes
The service is intended for local use and should not be exposed directly to the public internet. Access to the API is protected by an API key. The default operation restricts queries to SELECT statements to minimize risk.
Security and troubleshooting
- Use a strong API key and keep it secret. Treat it as a credential for local services.
- Ensure your MySQL user has appropriate privileges and uses parameterized queries to prevent SQL injection.
- If the server fails to start, verify that the port is not in use and that Node.js can bind to PORT. Check that MySQL is reachable with the configured host, port, user, and database.
Available tools
getDatabases
Fetch the list of databases available on the local MySQL connection.
getTables
Retrieve all tables for a specific database.
getTableStructure
Obtain the structure/schema of a specific table.
executeQuery
Run a parameterized SQL query against the local database and return results.
sseStream
Establish an SSE stream to receive real-time query results or updates.