local-mysql
A local development MCP server that exposes MySQL databases to VSCode and Copilot CLI with read-only SELECT queries and INSERT/UPDATE operations. It provides secure, schema-specific database access for development environments only.
README
local-mysql MCP サーバー
FO MySQL データベースを VSCode(および Copilot CLI)に公開する、ローカル開発用 MCP サーバーです。query(SELECT 専用)と execute(INSERT / UPDATE 専用)の 2 つのツールを提供します。
本サーバーはローカル開発専用です。本番環境にデプロイしたり、本番 DB に接続したりしないでください。
接続設定
デフォルト値は src/main/resources/application.yml と揃えています。
| 項目 | デフォルト | 環境変数での上書き |
|---|---|---|
| host | localhost |
FO_DB_HOST |
| port | 3306 |
FO_DB_PORT |
| user | root |
FO_DB_USER |
| password | admin |
FO_DB_PASS |
コネクションプールは スキーマ非依存 で、デフォルトのデータベースにはバインドしません。呼び出しごとに schema パラメータでスキーマを指定するか、oa.t_xxx のような完全修飾名を使用してください。許可されているスキーマ: fo、oa、bo、cm、nepro。
インストールとビルド
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 プロトコルのフレーム専用です
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.