This server provides automated read-only MySQL database access specifically for Local by Flywheel WordPress development environments, enabling comprehensive querying of WordPress data through specialized tools.
Automatically connect to Local by Flywheel's MySQL instance by detecting active site configuration and handling dynamic environments, with fallback support for non-Local setups
Retrieve WordPress posts with filtering by limit, offset, search terms, author ID, post type, and status using
wp_get_posts
, or fetch specific posts by ID withwp_get_post
Access user data by retrieving users with role filtering, pagination, and search by login/email/display name using
wp_get_users
, or get specific users by ID withwp_get_user
Query WordPress options/settings with search capabilities or retrieve specific options by name using
wp_get_options
Get plugin information including installation status and active state using
wp_get_plugins
Retrieve active theme details using
wp_get_theme_info
Execute custom read-only SQL queries directly against the WordPress database using
wp_execute_query
with parameterized query support for securityExplore database structure and get table information using
wp_get_database_info
Access post meta data for specific posts with optional meta key filtering using
wp_get_post_meta
Provides WordPress database access via Local by Flywheel, with auto-detection of active Local MySQL instances and WordPress-specific tools for content management, user management, and site configuration.
Enables read-only SQL query execution against WordPress databases, with automatic connection to Local by Flywheel MySQL instances via Unix sockets.
Offers comprehensive WordPress database interaction including posts, users, options, plugins, themes, and meta data management through purpose-built tools for local WordPress development sites.
MCP Server Local WP
A simplified Model Context Protocol (MCP) server that provides MySQL database access specifically designed for Local by Flywheel WordPress development environments. This server solves the "difficult to get working" problem of connecting MCP servers to Local's dynamic MySQL configurations.
The Problem We Solved
When using the original mcp-server-mysql with Local by Flywheel, developers face several challenges:
- Dynamic Paths: Local by Flywheel generates unique identifiers for each site (like
lx97vbzE7
) that change when sites are restarted - Socket vs Port Confusion: Local uses both Unix sockets and TCP ports, but the configuration can be tricky
- Hardcoded Configurations: Most setups require manual path updates every time Local restarts
Our Solution
This MCP server automatically detects your active Local by Flywheel MySQL instance by:
- Process Detection: Scans running processes to find active
mysqld
instances - Config Parsing: Extracts MySQL configuration from the active Local site
- Dynamic Connection: Connects using the correct socket path or port automatically
- Fallback Support: Falls back to environment variables for non-Local setups
Tools Available
mysql_query
Execute SQL queries against your Local by Flywheel WordPress database. Supports all standard MySQL queries with read-only safety built in.
Example Usage:
Installation
Prerequisites
- Local by Flywheel installed and running
- An active Local site running
- Node.js 18+ (for local development only)
Quick Setup (Recommended)
The easiest way to get started - no installation required:
Cursor IDE Configuration
Add this to your Cursor MCP configuration file (.cursor/mcp.json
):
Claude Desktop Configuration
Add this to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\\Claude\\claude_desktop_config.json
Advanced Setup (Local Development)
For customization or local development:
Install from Source
Local Configuration
Custom Environment Variables
For non-Local setups or custom configurations:
How It Works with Local by Flywheel
This MCP server was created because connecting to Local by Flywheel MySQL was "kind of difficult to get working" with existing MCP servers. Here's the story of what we solved:
The Original Problem
When we first tried to use mcp-server-mysql with Local by Flywheel, we encountered several issues:
- Dynamic Socket Paths: Local generates paths like
/Users/.../Local/run/lx97vbzE7/mysql/mysqld.sock
wherelx97vbzE7
changes each time you restart Local - Configuration Complexity: The original server required hardcoded paths that would break every time Local restarted
- Host/Port Confusion: Local's MySQL configuration can be tricky with both socket and TCP connections available
Our Solution Process
We solved this step by step:
1. Process-Based Detection
Instead of guessing paths, we scan for the actual running MySQL process:
This finds the active MySQL instance and extracts its configuration file path.
2. Dynamic Path Resolution
3. Automatic Configuration
The server automatically configures itself with:
- Correct socket path for the active Local site
- Proper database name (
local
) - Default credentials (
root
/root
) - Fallback to environment variables if needed
Why This Approach Works
✅ Restart Resilient: Works every time you restart Local by Flywheel
✅ Site Switching: Automatically adapts if you switch between Local sites
✅ Zero Maintenance: No need to manually update paths ever again
✅ Error Handling: Provides clear error messages if MySQL isn't running
Local Directory Structure We Handle
The server intelligently finds the active site and connects to the right MySQL instance.
Usage Examples
Once connected, you can use the mysql_query
tool to execute any SQL query against your Local WordPress database:
Getting Recent Posts
Exploring Database Structure
WordPress-Specific Queries
Development Setup
Running from Source
- Start a Local site: Make sure you have an active Local by Flywheel site running
- Clone and build:
- Test the connection:
Development Mode
This runs the server with TypeScript watching for changes.
Troubleshooting
Common Issues
- "No active MySQL process found"
- Ensure Local by Flywheel is running
- Make sure at least one site is started in Local
- Check that the site's database is running
- "MySQL socket not found"
- Verify the Local site is fully started
- Try stopping and restarting the site in Local
- Check Local's logs for MySQL startup issues
- Connection refused
- Ensure the Local site's MySQL service is running
- Check if another process is using the MySQL port
- Try restarting Local by Flywheel
- Permission denied
- Make sure the MySQL socket file has correct permissions
- Check if your user has access to Local's directories
Manual Configuration
If auto-detection fails, you can manually configure the connection:
Debugging
Enable debug logging:
Security
- Read-only operations: All database operations are restricted to SELECT queries
- Local development only: Designed specifically for local development environments
- No external connections: Only connects to local MySQL instances via socket
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development Guidelines
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name
- Make your changes and add tests
- Ensure TypeScript compiles:
npm run build
- Submit a pull request
License
MIT License - see the LICENSE file for details.
Support
- GitHub Issues: Report bugs or request features
- Documentation: This README and inline code documentation
- Community: Join the Model Context Protocol community discussions
Related Projects
- mcp-server-mysql - The original MySQL MCP server that inspired this WordPress-specific version
- Local by Flywheel - The local WordPress development environment this server is designed for
- Model Context Protocol - The protocol specification
Built with ❤️ by Very Good Plugins for the WordPress development community.
local-only server
The server can only run on the client's local machine because it depends on local resources.
Tools
Enables direct interaction with local WordPress development sites through Local by Flywheel database connections. Provides read-only access to WordPress data including posts, users, options, and custom queries for development and analysis.