VM

verygoodplugins/mcp-local-wp

数据库管理官方

本页由 AI 翻译,技术细节请以原文为准。 查看原文

34 stars 5 forks 质量 77 趋势 32NOASSERTION

通过Flywheel本地访问WordPress数据库的MCP服务器

概览

一个模型上下文协议(MCP)服务器,为像Claude和Cursor这样的AI助手提供直接、只读访问你的本地Flywheel WordPress数据库。不再需要猜测表格结构。不再盲目编写SQL查询。你的AI现在能够理解你的实际数据。 可以把MCP(模型上下文协议)看作是AI助手与开发工具之间的安全桥梁。MCP服务器无需复制粘贴数据库模式或查询结果,而是让AI助手直接与你的工具交互,而你则保持完全控制。 :“嘿,AI,我记得有个叫wp_something的表,里面有一列可能叫user_meta......你能写个查询吗?”:“嘿,AI,看看我数据库里有什么,写我需要的准确查询。” 想象一下:你正在调试一个LearnDash集成问题。测验结果没有正确同步。

概述(AI 翻译)

** 🎯 如果你的AI助手真的能看到你的WordPress数据库呢?**

一个模型上下文协议(MCP)服务器,为像Claude和Cursor这样的AI助手提供直接、只读访问你的本地Flywheel WordPress数据库。不再需要猜测表格结构。不再盲目编写SQL查询。你的AI现在能够理解你的实际数据。

升级到2.0

2.0 版本要求 Node.js 24 或更新版本,使用 MCP SDK v2。现有工具名称和站点选择器依然可用。查询结果现为 { "rows": [...] };模式列表返回 { "tables": [...], "hasMore": false, "nextAfter": null },表名页面有界。成功工具返回匹配的结构化和 JSON 文本结果,失败设置为 isError: true。

数据库和本地配置解析较为懒散,因此MCP工具发现无需运行站点即可完成。显式MYSQL_HOST或MYSQL_SOCKET_PATH选择手动连接。保持stdin开放,直到所有工具响应到达;EOF关闭会话。父看门狗还清理废弃的stdio服务器。

🤔 什么是MCP服务器?

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MCP Server Local WP

🎯 What if your AI assistant could actually SEE your WordPress database?

A Model Context Protocol (MCP) server that gives AI assistants like Claude and Cursor direct, read-only access to your Local by Flywheel WordPress database. No more guessing table structures. No more writing SQL queries blind. Your AI can now understand your actual data.

Upgrading to 2.0

Version 2.0 requires Node.js 24 or newer and uses MCP SDK v2. Existing tool names and site selectors remain available. Query results are now { "rows": [...] }; schema listing returns { "tables": [...], "hasMore": false, "nextAfter": null } with bounded pages of table names. Successful tools return matching structured and JSON-text results, and failures set isError: true.

Database and Local configuration are resolved lazily, so MCP tool discovery works without a running site. Explicit MYSQL_HOST or MYSQL_SOCKET_PATH selects the manual connection. Keep stdin open until all tool responses arrive; EOF closes the session. The parent watchdog also cleans up abandoned stdio servers.

🤔 What’s an MCP Server?

Think of MCP (Model Context Protocol) as a secure bridge between AI assistants and your development tools. Instead of copying and pasting database schemas or query results, MCP servers let AI assistants directly interact with your tools while you maintain complete control.

Without MCP: “Hey AI, I think there’s a table called wp_something with a column that might be named user_meta… can you write a query?”
With MCP: “Hey AI, check what’s in my database and write the exact query I need.”

💡 The WordPress Developer’s Dilemma

Picture this: You’re debugging a LearnDash integration issue. Quiz results aren’t syncing properly. You fire up Cursor to help diagnose the problem, but without database access, even the most advanced AI is just making educated guesses about your table structures.

The Real-World Impact

Here’s an actual support ticket we were working on. The task was simple: fetch quiz activity data from LearnDash tables.

❌ Before MCP Server (AI Flying Blind):

The AI tried its best, suggesting this query:

$quiz_activities = $wpdb->get_results(
  $wpdb->prepare(
    'SELECT post_id, activity_meta FROM ' . esc_sql( LDLMS_DB::get_table_name( 'user_activity' ) ) . '
     WHERE user_id=%d AND activity_type=%s AND activity_status=1 AND activity_completed IS NOT NULL',
    $user_id,
    'quiz'
  ),
  ARRAY_A
);
在 GitHub 查看完整 README

安装

npx -y @verygoodplugins/mcp-local-wp@latest
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "wordpress-dev": { "command": "npx", "args": ["-y", "@verygoodplugins/mcp-local-wp@latest"], "env": { "SITE_NAME": "dev" } } } }