XAMPP管理服务器

用于通过MCP协议从客户端(如VS Code、Copilot代理等)管理Windows上的XAMPP和MySQL的服务。

  • by dony-aep
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 dony-aep/xampp-mcp

使用说明

xampp-mcp

English | Español

MCP server for administering XAMPP and MySQL on Windows from MCP clients over stdio (VS Code, Copilot agents, Claude Code, etc.).

It speaks MCP protocol revision 2026-07-28 as well as the legacy (initialize) era, so current clients keep connecting unchanged.

Requirements

  • Windows
  • Node.js 22+
  • XAMPP installed (C:\xampp by default)

Installation

npm package:

  • https://www.npmjs.com/package/xampp-mcp

Global install:

npm install -g xampp-mcp

Local install in a project:

npm i xampp-mcp

MCP client configuration

There are two possible locations and they are not equivalent — even the root key differs:

File Read by Root key
.vscode/mcp.json VS Code servers
.mcp.json in the project root Claude Code and Copilot's Agent Host mcpServers

Neither is deprecated. But VS Code's documentation warns that "when Agent Host is enabled, the Agent Host doesn't read .vscode/mcp.json directly", and recommends the root file "for MCP configuration that is portable across the Agent Host and other Copilot tools". If you use both clients you need both files: the schemas differ, so they cannot be merged.

VS Code — .vscode/mcp.json

Recommended example:

{
  "servers": {
    "xamppMcp": {
      "type": "stdio",
      "command": "xampp-mcp",
      "args": [],
      "env": {
        "XAMPP_DIR": "C:\\xampp",
        "XAMPP_MCP_DATA_DIR": "${workspaceFolder}/mcp-data"
      }
    }
  }
}

If you installed the package locally (npm i xampp-mcp), you can use:

{
  "servers": {
    "xamppMcp": {
      "type": "stdio",
      "command": "node",
      "args": ["${workspaceFolder}/node_modules/xampp-mcp/dist/server.js"],
      "env": {
        "XAMPP_DIR": "C:\\xampp",
        "XAMPP_MCP_DATA_DIR": "${workspaceFolder}/mcp-data"
      }
    }
  }
}

Claude Code and Agent Host — .mcp.json in the root

{
  "mcpServers": {
    "xampp": {
      "command": "npx",
      "args": ["-y", "xampp-mcp"],
      "env": {
        "XAMPP_DIR": "C:\\xampp",
        "XAMPP_MCP_DATA_DIR": "${XAMPP_MCP_DATA_DIR:-./mcp-data}"
      }
    }
  }
}

Claude Code expands ${VAR} and ${VAR:-default} in command, args and env, which lets you commit this file and still let each machine override the path through its own environment variable.

${CLAUDE_PROJECT_DIR} does not help here, even though it exists: Claude Code sets it in the spawned server's environment, not in its own, so it has no value yet when .mcp.json is expanded and has to be written as ${CLAUDE_PROJECT_DIR:-.} — which in practice falls back to .. A server that genuinely wants the project root should read process.env.CLAUDE_PROJECT_DIR at runtime.

Environment variables

Variable Default What it does
XAMPP_DIR C:\xampp XAMPP installation
XAMPP_APACHE_SERVICE Apache2.4 Apache Windows service name
XAMPP_MYSQL_SERVICE mysql MySQL Windows service name
MYSQL_HOST 127.0.0.1 Default MySQL host
MYSQL_PORT 3306 Default MySQL port
MYSQL_USER root Default MySQL user
MYSQL_PASSWORD (empty) Default MySQL password
XAMPP_MCP_DATA_DIR working directory Root every file path is confined to (export, import, diagrams)
XAMPP_PHP_SCRIPTS_DIR <XAMPP_DIR>\htdocs Root php_cli_run may execute scripts from
XAMPP_MCP_REMOTE_RENDER (disabled) Set to 1 to let diagram_render upload the diagram to the remote renderer

The last three are security boundaries. Read SECURITY.md before widening them.

Confirming destructive operations

The writing tools (db_create, query_execute, db_import, user_create, grant_manage, db_export) do not act without confirmation.

If your MCP client supports elicitation, it asks you: "Create the database "ventas"?". Accept and it proceeds; decline and nothing is touched. If your client does not support it, the tool returns an error asking to resend with confirmed: true, as before.

You can still pass confirmed: true explicitly to skip the prompt — useful in scripts.

Important usage notes

  • If Apache/MySQL are down, you must start them yourself from the XAMPP Control Panel. The server never starts them on its own: it asks you and waits for your confirmation.
  • Use snake_case (_) for database and table names, and avoid -.
  • The server uses UTF-8 (utf8mb4) so accents and special characters survive.

ER diagrams (recommended flow)

When you ask for a database diagram in VS Code chat:

  1. Run diagram_er to get Mermaid from the real schema. It never leaves the machine.
  2. Preview it in chat with renderMermaidDiagram, using structuredContent.previewRequest.args.markup.
  3. If the user confirms they want SVG, run diagram_render with structuredContent.renderRequest.args.

Step 3 requires XAMPP_MCP_REMOTE_RENDER=1: it renders through Kroki, a remote service, so your real table and column names leave the machine. Without that variable the tool validates the Mermaid and returns only the text block.

Compatibility notes:

  • renderMermaidDiagram is a VS Code chat capability, not something this server provides: VS Code controls its name and availability. It was introduced in 1.109 (January 2026) and since 1.121 lives in the built-in Mermaid Markdown Features extension.
  • Use VS Code 1.131 or later: between 1.129.1 and 1.130.x a regression prevented the tool from being registered, and the call fails with Tool "renderMermaidDiagram" was not contributed.
  • The preview step is optional: if the tool does not exist in your client, the Mermaid is already in diagram_er's text output. For SVG, use diagram_render.

Development

npm install
npm run lint    # typechecks src and tests
npm test        # node:test, no extra dependencies
npm run build

Documentation

License

This project is MIT licensed. See LICENSE.