mysql-data-accessor-tool
Facilitates secure, read-only interaction with relational MySQL data stores. This capability allows agents to issue structured query language (SQL) commands and examine database structures, thereby supporting sophisticated data retrieval for application intelligence.
Author

shreyansh-ghl
Quick Info
Actions
Tags
SQL Data Access Proxy for MySQL (MCP Server)
A Model Context Protocol (MCP) endpoint engineered to grant read-only access to MySQL databases. This utility empowers Large Language Models (LLMs) to introspect database schemas and execute non-mutating SQL operations.
Credential Configuration
Authentication is managed entirely through the provided database connection string (URL):
mysql://
Example Connection String:
- Instance:
mysql://agent_user:secret_key@db.internal.net:3306/prod_analytics
Security Warning: Exercise extreme caution to safeguard credentials; avoid hardcoding secrets in publicly accessible scripts or configuration files.
Functionality
Available Operations (Tools)
- execute_readonly_query
- Purpose: Runs specified SQL queries against the linked database.
- Parameter:
sql(string): The precise SQL statement to be executed. - Constraint: Every invocation is strictly wrapped within a read-only transaction boundary.
- Auth: Credentials provided in the connection string are utilized implicitly.
Data Structures (Resources)
The service automatically maps and exposes structural metadata for every accessible table:
- Table Metadata Endpoint (
mysql://<host>/<table>/metadata) - Output: Returns comprehensive JSON describing the schema for the specified table.
- Contents: Details include column identifiers and their respective data types.
- Discovery: Schema information is dynamically sourced from the database's internal catalog.
- Security: Access requires valid credentials.
Deployment Guide
- Obtain the source code repository:
sh git clone https://github.com/yourusername/mysql-mcp-server.git cd mysql-mcp-server
- Resolve and install required packages:
sh npm run prepare npm install
- Globally register the binary for system-wide invocation:
sh npm link
Launch the server instance, pointing it to your database URI:
sh mysql-mcp-server mysql://user:password@localhost:3306/mydb
Integration with Cursor IDE
Setting Up the Data Source in Cursor Settings
-
Access Cursor application settings (Gear icon ⚙️ in the lower-left or shortcut
Shift + Cmd + Jon Mac). -
Navigate to the 'MCP' section within the settings panel.
-
Select 'Add Global MCP Server' and input the following JSON structure:
{ "mcpServers": { "mysql_ro": { "command": "mysql-mcp-server", "args": ["mysql://user:password@localhost:3306/mydb"] } } }
- Finalize by saving the configuration (
Cmd + S) and initiating a restart of the Cursor application.
Operational Usage in Cursor
Engage the Agentic Chat interface within Cursor and formulate natural language questions pertaining to your data. The connected MySQL accessor will provide the necessary contextual database information to formulate the answer.
Security Best Practices Summary
- Credential Isolation: Inject sensitive tokens via environment variables rather than direct arguments:
{ "mcpServers": { "mysql": { "command": "mysql-mcp-server", "args": ["mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@host:3306/mydb"] } } }
- Principle of Least Privilege: Restrict the associated MySQL account strictly to read-only operational rights.
- Utilize robust, complex passwords.
- Never commit configuration files containing plaintext credentials to source control repositories.
Licensing Information
This server software is distributed under the permissive MIT License. Refer to the accompanying LICENSE file within the project directory for full permissions and usage stipulations.
