local-mysql
local-mysql MCP サーバー
FO MySQL データベースを VSCode(および Copilot CLI)に公開する、ローカル開発用 MCP サーバーです。query(SELECT 専用)と execute(INSERT / UPDATE 専用)の 2 つのツールを提供します。
本サーバーはローカル開発専用です。本番環境にデプロイしたり、本番 DB に接続したりしないでください。
接続設定
デフォルト値は 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