mcp-data-server
mcp-data-server
本番環境でのWebスクレイピング/自動化パターンを示すサンプルプロジェクト。
Claude(または任意のMCPクライアント)にビジネスデータベースへの読み取り専用アクセスを提供するMCPサーバー — LLMを実際の企業データに接続する際に許容されるガードレール(読み取り専用接続、テーブル許可リスト、PIIマスキング、行数上限、クエリタイムアウト、完全な監査ログ)を備えています。
Claude Desktopで 「どの国が最も注文しているか、そして先四半期の返金コストはいくらだったか?」 と尋ねると、実際のデータベースから回答が得られます — モデルが許可されていないテーブルに書き込み、削除、アタッチ、または読み取りを行う方法はありません。
なぜこれが存在するのか
「AIを自社データに接続する」プロジェクトの大半で障害となるのは、配線ではなく、データベースの所有者からの最初の質問です:「これによって、読み取りや破損が起こらないという保証は?」 このサーバーは、その質問にコードで答えます。
Related MCP server: Database Assistant MCP Server
4つの独立した障壁
# | 障壁 | 防止するもの |
1 | 接続が | 上記のすべてのチェックを回避した場合でも、あらゆる書き込み |
2 | ステートメント解析 | 複数のステートメント、 |
3 | キーワードブロックリスト |
|
4 | 許可リスト + マスキング + 上限 | 許可されていないテーブル、PII列、過大な結果、暴走クエリ |
実行されたすべてのステートメントは、行数と実行時間とともに監査ログに追加されるため、データ所有者はモデルが何を要求したかを正確に確認できます。
2026-08-18T11:22:41 6 rows in 1ms SELECT country, COUNT(*) FROM customers GROUP BY 1 LIMIT 201
2026-08-18T11:22:44 error: rejected DELETE FROM customers公開ツール
ツール | 目的 |
| 読み取り可能なテーブル + 行数 |
| 列、型、マスクされているもの、3つのサンプル行 |
| 1つの読み取り専用 |
| SQLを書かずに部分文字列検索 |
| NULL、個別値数、最小/最大、上位5つの値 |
さらに schema://tables リソースもあり、クライアントはツール呼び出しを消費せずにスキーマ全体を読み込めます。
クイックスタート
git clone https://github.com/dkautomation23/mcp-data-server.git
cd mcp-data-server
python -m venv .venv && . .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
python -m mcp_data_server.seed # creates demo.db
cp .env.example .env # then point DATABASE_PATH at your file
python -m mcp_data_server # serves over stdioPython 3.10以上。デモデータベースには customers、orders、order_items、および以下で許可リストによるアクセスブロックを示すために使用される意図的に機密性の高い internal_notes テーブルが含まれています。
Claude Desktopに接続する
claude_desktop_config.json に追加します(完全な例は examples/claude_desktop_config.json にあります):
{
"mcpServers": {
"business-data": {
"command": "python",
"args": ["-m", "mcp_data_server"],
"cwd": "C:/path/to/mcp-data-server",
"env": {
"DATABASE_PATH": "C:/path/to/your.db",
"ALLOWED_TABLES": "customers,orders,order_items",
"MASKED_COLUMNS": "customers.email,customers.phone"
}
}
}
}Claude Codeに接続する
claude mcp add business-data -- python -m mcp_data_serverセッションの様子
実行中のサーバーからの実際の出力(完全なトランスクリプトは examples/demo_session.md を参照):
// run_sql("SELECT status, COUNT(*) n, ROUND(SUM(total_eur)) revenue FROM orders GROUP BY 1 ORDER BY 3 DESC")
{
"sql": "SELECT status, COUNT(*) n, ROUND(SUM(total_eur)) revenue FROM orders GROUP BY 1 ORDER BY 3 DESC LIMIT 201",
"columns": ["status", "n", "revenue"],
"rows": [["paid", 92, 149914.0], ["pending", 39, 64596.0], ["refunded", 31, 45911.0]],
"row_count": 3, "truncated": false, "elapsed_ms": 0
}
// run_sql("DELETE FROM customers")
{ "error": "only SELECT (or WITH ... SELECT) statements are allowed" }
// run_sql("SELECT * FROM internal_notes")
{ "error": "table 'internal_notes' is not in the allowlist (allowed: customers, orders, order_items)" }
// run_sql("SELECT id, name, email FROM customers LIMIT 2")
{ "rows": [[1, "Customer 001", "***"], [2, "Customer 002", "***"]] }設定
変数 | デフォルト | 目的 |
|
| 公開するSQLiteファイル(常に読み取り専用で開かれる) |
| すべて | カンマ区切りの許可リスト;それ以外は非表示 |
| – |
|
|
| 呼び出しごとのハード上限;それを超えた結果は |
|
| より長いクエリはキャンセルされる |
|
| すべてのステートメントの追記専用ログ;空の場合は無効 |
テスト
pytest -q............................... [100%]
31 passed in 1.77s3つのレイヤー:SQLガードレール(インジェクション、2番目のステートメント、コメントのすり抜け、禁止テーブル)、実際のシードファイルに対するデータベースレイヤー(SQLite自体が拒否する書き込み試行を含む)、そして実際のMCPプロトコルを介してサーバーを駆動する7つのテスト — デスクトップクライアントが実行するのと同じハンドシェイク、list_tools、call_tool フローです。
クライアントのスタックに適応させる
Postgres / MySQL:
db.pyの接続をプールドライバーとSET TRANSACTION READ ONLYセッションに置き換えます;検証レイヤーは変更されません。ビジネス固有のツール:
server.pyに@mcp.tool()を付けた関数を追加します — 適切に名前付けられたtop_customers(period)は、モデルにSQLを書かせるよりも優れています。stdioの代わりにHTTPトランスポート:
mcp.run(transport="streamable-http")を使用し、独自の認証の背後に配置します。
ライセンス
MIT — LICENSE を参照。
This server cannot be installed
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
- Alicense-qualityAmaintenanceProvides a read-only PostgreSQL SQL surface for LLM agents via MCP, with defense-in-depth security layers for safe database queries.3MIT
- FlicenseAqualityCmaintenanceEnables read-only exploration and querying of PostgreSQL or MySQL databases via MCP, with schema discovery, safe SQL validation, natural language to SQL conversion, and CSV export.111
- Alicense-qualityBmaintenanceEnables governed, agent-agnostic data exploration by allowing users to ask natural language questions through MCP-compatible agents, executing safe, permission-scoped queries against data sources and returning interactive charts.48Apache 2.0
- Flicense-qualityCmaintenanceEnables read-only access to company data across PostgreSQL, MongoDB Atlas, and flat files through MCP tools, allowing AI assistants to query and retrieve information via natural language.
Related MCP Connectors
Official Microsoft MCP Server to query Microsoft Entra data using natural language
A paid remote MCP for AI SDK data query MCP, built to return verdicts, receipts, usage logs, and aud
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
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/dkautomation23/mcp-data-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server