Skip to main content
Glama
dkautomation23

mcp-data-server

mcp-data-server

本番環境でのWebスクレイピング/自動化パターンを示すサンプルプロジェクト。

Claude(または任意のMCPクライアント)にビジネスデータベースへの読み取り専用アクセスを提供するMCPサーバー — LLMを実際の企業データに接続する際に許容されるガードレール(読み取り専用接続、テーブル許可リスト、PIIマスキング、行数上限、クエリタイムアウト、完全な監査ログ)を備えています。

Claude Desktopで 「どの国が最も注文しているか、そして先四半期の返金コストはいくらだったか?」 と尋ねると、実際のデータベースから回答が得られます — モデルが許可されていないテーブルに書き込み、削除、アタッチ、または読み取りを行う方法はありません。


なぜこれが存在するのか

「AIを自社データに接続する」プロジェクトの大半で障害となるのは、配線ではなく、データベースの所有者からの最初の質問です:「これによって、読み取りや破損が起こらないという保証は?」 このサーバーは、その質問にコードで答えます。

Related MCP server: Database Assistant MCP Server

4つの独立した障壁

#

障壁

防止するもの

1

接続が mode=ro で開かれる

上記のすべてのチェックを回避した場合でも、あらゆる書き込み

2

ステートメント解析

複数のステートメント、SELECT / WITH 以外のもの

3

キーワードブロックリスト

ATTACHPRAGMA、DDL、VACUUMGRANT

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

公開ツール

ツール

目的

list_tables()

読み取り可能なテーブル + 行数

describe_table(table)

列、型、マスクされているもの、3つのサンプル行

run_sql(sql)

1つの読み取り専用 SELECT、上限付きで監査対象

search(table, column, term, limit)

SQLを書かずに部分文字列検索

summarize_column(table, column)

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 stdio

Python 3.10以上。デモデータベースには customersordersorder_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", "***"]] }

設定

変数

デフォルト

目的

DATABASE_PATH

demo.db

公開するSQLiteファイル(常に読み取り専用で開かれる)

ALLOWED_TABLES

すべて

カンマ区切りの許可リスト;それ以外は非表示

MASKED_COLUMNS

table.column リスト。すべての結果で *** に置き換えられる

MAX_ROWS

200

呼び出しごとのハード上限;それを超えた結果は truncated とフラグ付けされる

QUERY_TIMEOUT_SECONDS

10

より長いクエリはキャンセルされる

AUDIT_LOG_PATH

audit.log

すべてのステートメントの追記専用ログ;空の場合は無効

テスト

pytest -q
...............................                                          [100%]
31 passed in 1.77s

3つのレイヤー:SQLガードレール(インジェクション、2番目のステートメント、コメントのすり抜け、禁止テーブル)、実際のシードファイルに対するデータベースレイヤー(SQLite自体が拒否する書き込み試行を含む)、そして実際のMCPプロトコルを介してサーバーを駆動する7つのテスト — デスクトップクライアントが実行するのと同じハンドシェイク、list_toolscall_tool フローです。

クライアントのスタックに適応させる

  • Postgres / MySQLdb.py の接続をプールドライバーと SET TRANSACTION READ ONLY セッションに置き換えます;検証レイヤーは変更されません。

  • ビジネス固有のツールserver.py@mcp.tool() を付けた関数を追加します — 適切に名前付けられた top_customers(period) は、モデルにSQLを書かせるよりも優れています。

  • stdioの代わりにHTTPトランスポートmcp.run(transport="streamable-http") を使用し、独自の認証の背後に配置します。

ライセンス

MIT — LICENSE を参照。

A
license - permissive license
-
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

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

  • A
    license
    -
    quality
    A
    maintenance
    Provides a read-only PostgreSQL SQL surface for LLM agents via MCP, with defense-in-depth security layers for safe database queries.
    3
    MIT
  • F
    license
    A
    quality
    C
    maintenance
    Enables 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.
    11
    1
  • A
    license
    -
    quality
    B
    maintenance
    Enables 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.
    48
    Apache 2.0
  • F
    license
    -
    quality
    C
    maintenance
    Enables 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.

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

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