Local Database Analytics MCP Server
Local Database Analytics MCP Server
ローカルSQLite eコマースデータベースをClaudeなどのAIアシスタントに公開する、PythonベースのModel Context Protocol (MCP) サーバーです。FastMCP、SQLAlchemy、Pandasで構築されています。
MCPとは? Model Context Protocol (Anthropic製) は、AIモデルがローカルのツールやデータと安全にやり取りできるようにするものです。このサーバーはClaudeにデータベースの情報を教え、自然言語だけでデータのクエリ、分析、説明を可能にします。
機能
ツール (全11個)
ツール | 説明 |
| データベース内のすべてのテーブルを一覧表示 |
| 特定のテーブルのスキーマ/カラムを表示 |
| テーブルからN件のサンプル行を返す |
| オプションのWHEREフィルターで行数をカウント |
| 安全なSELECTクエリを実行 |
| 統計: 任意のカラムの最小値/最大値/平均値/ヌル数/ユニーク数 |
| カラムでソートした上位N行 |
| GROUP BY + SUM/AVG/COUNT/MIN/MAX |
| 欠損データのあるカラムを検出 |
| 2つのカラム間のピアソン相関 |
| 日/週/月単位でデータを集計 |
リソース
URI | 説明 |
| データベース全体のスキーマ |
| 特定のテーブルのスキーマ |
プロンプト
analyze_table— 任意のテーブルの完全な統計分析business_summary— 経営層向けのeコマースレポートfind_anomalies— データ品質と外れ値の検出
Related MCP server: db-mcp
データベーススキーマ
customers ──< orders ──< order_items >── productscustomers: 名前、メール、都市、登録日を含む15件のレコード
products: エレクトロニクス、書籍、スポーツ、ホーム、文房具にわたる15製品
orders: ステータス (完了/保留/キャンセル) と合計金額を含む60件の注文
order_items: 注文と製品を結びつける明細項目
プロジェクト構成
MCP_Server/
├── server.py # FastMCP server entry point
├── requirements.txt # Python dependencies
├── database/
│ ├── engine.py # SQLAlchemy DB connection
│ └── seed_data.py # Seed script (creates + populates DB)
├── tools/
│ ├── query.py # Core SQL tools (Phase 2)
│ └── analytics.py # Analytics tools (Phase 3)
├── resources/
│ └── schema.py # DB schema as MCP resources
├── prompts/
│ └── templates.py # Pre-built analyst prompts
├── tests/
│ └── test_tools.py # Unit tests
└── data/
└── analytics.db # SQLite database (auto-created)はじめに
1. リポジトリをクローン
git clone https://github.com/manohar135/Local-Database-Analytics-MCP-Server.git
cd Local-Database-Analytics-MCP-Server2. 仮想環境を作成して依存関係をインストール
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt3. データベースにシードデータを投入
python database/seed_data.py4. MCP Inspectorを起動 (開発モード)
fastmcp dev server.py5. テストを実行
pytest tests/ -v技術スタック
技術 | 役割 |
MCPサーバーフレームワーク | |
SQLite | 設定不要のローカルデータベース |
SQLAlchemy | DBエンジン & ORM |
Pandas | 分析 & 集計 |
Pydantic | 入力検証 |
Pytest | ユニットテスト |
Claudeとの会話例
Claude Desktopに接続したら、以下を試してみてください:
「どのテーブルにアクセスできますか?」
「売上データのビジネスサマリーを教えて」
「最も売れている製品はどれですか?」
「ordersテーブルにデータ品質の問題はありますか?」
「過去1年間の月次売上トレンドを見せて」
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Text-to-SQL for Claude & ChatGPT: OAuth sign-in, read-only Postgres/MySQL/SQL Server, free demo_shop
Run your ecommerce ads from Claude & ChatGPT: Meta, Google, Amazon, Shopify (150 tools)
Connects Claude, ChatGPT and other AI agents to a SIGNLD workspace. SIGNLD reads your business systems (QuickBooks, HubSpot, Salesforce, Shopify and 800+ more) through read-only connections and keeps a Knowledge Graph of how the business fits together. The agent can list data connections and table schemas, run read-only SQL, read the Knowledge Graph, entities, metrics and topics, save definitions and topics in the workspace, and build charts and dashboards. Nothing is ever written back to your source systems. Every answer traces to the source row. Private LLM powered by AWS Bedrock; we never train on customer data.
Ask questions across Shopify, Klaviyo, GA4 and 20+ e-commerce sources in plain English.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables natural-language querying of an e-commerce dataset by providing a LangChain agent that uses tools to execute parameterized SQL queries on a SQLite database, with short-term memory and Streamlit or Claude Desktop interfaces.-
- FlicenseAqualityDmaintenanceEnables AI agents to safely interact with a SQLite shop database through schema discovery, read-only SQL queries, and pre-built analytics reports like top customers, top products, and revenue summaries.6-
- FlicenseAqualityDmaintenanceGives AI agents read-only analytical access to an e-commerce SQLite database (customers, orders, order_items, products) via SQL queries, table listing, and schema inspection.3-
- FlicenseAqualityDmaintenanceEnables AI agents to analyze an SQLite e-commerce database via secure read-only SQL queries, providing tools for table inspection and analytical requests.2-