local-mysql
local-mysql MCP 服务器
这是一个用于本地开发的 MCP 服务器,将 FO MySQL 数据库暴露给 VSCode(以及 Copilot CLI)。它提供了两个工具:query(仅限 SELECT)和 execute(仅限 INSERT / UPDATE)。
本服务器仅供本地开发使用。请勿将其部署到生产环境或连接到生产数据库。
连接设置
默认值与 src/main/resources/application.yml 一致。
项目 | 默认值 | 环境变量覆盖 |
host |
|
|
port |
|
|
user |
|
|
password |
|
|
连接池是 模式无关的,不会绑定到默认数据库。请在每次调用时通过 schema 参数指定模式,或使用完全限定名(如 oa.t_xxx)。允许的模式:fo、oa、bo、cm、nepro。
Related MCP server: MySQL MCP Server
安装与构建
cd mcp-server
npm install
npm run build构建完成后,请重启 MCP 客户端(VSCode / Copilot CLI)以重新加载配置。
如果希望在不重新构建的情况下进行迭代开发:
npm run dev工具
query — 只读 SELECT
{
"sql": "SELECT id, name FROM m_article WHERE id = ?",
"params": [123],
"schema": "fo" // 省略可
}返回值:
{
"schema": "fo",
"rowCount": 1,
"truncated": false,
"maxRows": 1000,
"fields": [{ "name": "id", "type": 3 }, { "name": "name", "type": 253 }],
"rows": [{ "id": 123, "name": "..." }]
}限制:
仅限单条语句(拒绝多条语句)
必须以
SELECT开头(v1 版本不支持 CTE /WITH)结果上限:1000 行。如果
truncated: true,则表示存在更多行
execute — INSERT 或 UPDATE
{
"sql": "UPDATE m_article SET name = ? WHERE id = ?",
"params": ["new name", 123],
"schema": "fo"
}返回值:
{
"schema": "fo",
"affectedRows": 1,
"insertId": 0,
"changedRows": 1,
"warningStatus": 0
}限制:
仅限单条语句
必须以
INSERT或UPDATE开头DELETE、DROP、ALTER、CREATE、TRUNCATE、RENAME、GRANT、REVOKE、REPLACE、MERGE、CALL、LOAD、HANDLER、LOCK、UNLOCK、SET、USE、START、BEGIN、COMMIT、ROLLBACK、SAVEPOINT— 全部拒绝
集成方式
将此仓库克隆到使用本服务器的项目同级目录下,并采用以下目录结构:
parent/
├── mcp-local-mysql/ ← このリポジトリ
└── your-project/
└── .vscode/mcp.json (Copilot CLI の場合は .mcp.json)VSCode
在项目根目录下添加 .vscode/mcp.json。根键为 servers:
{
"servers": {
"local-mysql": {
"command": "node",
"args": ["../mcp-local-mysql/dist/index.js"],
"env": {}
}
}
}如果需要为每个工作区覆盖凭据,请编辑 env 对象。例如:
"env": { "FO_DB_USER": "devuser", "FO_DB_PASS": "devpass" }此外,为了让 VSCode 识别 .vscode/mcp.json,请在 .vscode/settings.json 中启用 MCP 发现功能:
{
"chat.mcp.discovery.enabled": true
}Copilot CLI
在项目根目录下添加 .mcp.json。根键为 mcpServers:
{
"mcpServers": {
"local-mysql": {
"command": "node",
"args": ["../mcp-local-mysql/dist/index.js"],
"env": {}
}
}
}安全注意事项
在驱动程序级别设置
multipleStatements: false(作为验证器之外的多层防御)所有查询均已参数化 — 值必须通过
params传递,请勿直接嵌入 SQL 字符串中模式名称在与白名单匹配后会被嵌入到
USE `...`中服务器日志仅输出到 stderr。stdout 仅用于 MCP 协议帧
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that provides secure, multi-database MySQL access with configurable security levels, enabling SQL queries across multiple databases directly from VS Code.5191MIT
- AlicenseNot gradedqualityDmaintenanceA MySQL MCP server for secure database interaction, enabling schema inspection, query execution, and RBAC via AI coding assistants.6555MIT
- AlicenseNot gradedqualityBmaintenanceA MySQL MCP server for local stdio clients, enabling database queries and management with read-only/write modes, audit logging, and configurable security.655MIT
- AlicenseNot gradedqualityDmaintenanceA read-only MCP server that enables Claude Code to access MySQL databases, allowing safe querying with SELECT, SHOW, DESCRIBE, and EXPLAIN.29MIT
Related MCP Connectors
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
Hosted Amazon Seller and Vendor MCP server for Claude, ChatGPT, Cursor, Codex, Gemini, Copilot.
MCP server for managing Prisma Postgres.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/nhs-ayamura/mcp-local-mysql'
If you have feedback or need assistance with the MCP directory API, please join our Discord server