Skip to main content
Glama
Local Database Analytics MCP Server

Local Database Analytics MCP Server

by manohar135

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個)

ツール

説明

list_tables

データベース内のすべてのテーブルを一覧表示

describe_table

特定のテーブルのスキーマ/カラムを表示

get_sample_rows

テーブルからN件のサンプル行を返す

get_row_count

オプションのWHEREフィルターで行数をカウント

run_sql_query

安全なSELECTクエリを実行

summarize_column

統計: 任意のカラムの最小値/最大値/平均値/ヌル数/ユニーク数

find_top_n

カラムでソートした上位N行

group_and_aggregate

GROUP BY + SUM/AVG/COUNT/MIN/MAX

detect_nulls

欠損データのあるカラムを検出

compute_correlation

2つのカラム間のピアソン相関

time_series_summary

日/週/月単位でデータを集計

リソース

URI

説明

db://schema

データベース全体のスキーマ

db://tables/{name}

特定のテーブルのスキーマ

プロンプト

  • analyze_table — 任意のテーブルの完全な統計分析

  • business_summary — 経営層向けのeコマースレポート

  • find_anomalies — データ品質と外れ値の検出


Related MCP server: db-mcp

データベーススキーマ

customers ──< orders ──< order_items >── products
  • customers: 名前、メール、都市、登録日を含む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-Server

2. 仮想環境を作成して依存関係をインストール

python -m venv .venv
source .venv/bin/activate       # On Windows: .venv\Scripts\activate
pip install -r requirements.txt

3. データベースにシードデータを投入

python database/seed_data.py

4. MCP Inspectorを起動 (開発モード)

fastmcp dev server.py

5. テストを実行

pytest tests/ -v

技術スタック

技術

役割

FastMCP

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…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables 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.
      -
    • F
      license
      A
      quality
      D
      maintenance
      Enables 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
      -
    • F
      license
      A
      quality
      D
      maintenance
      Gives 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
      -
    • F
      license
      A
      quality
      D
      maintenance
      Enables AI agents to analyze an SQLite e-commerce database via secure read-only SQL queries, providing tools for table inspection and analytical requests.
      2
      -