mcp-data-agent
MCP Data Agent
販売データベース上でデータアナリスト向けツールを公開する、本格的なModel Context Protocol (MCP) サーバーです。さらに、実行時にそれらのツールを発見し、質問に答えるためにどのツールを呼び出すかを決定するLLMエージェント(Gemini)も備えています。MCPの本質は、ツール定義がサーバー側に存在し、エージェントにハードコードされていないことです。
これがモックではなく本物のMCP実装である理由
src/mcp_server.pyは、公式のmcpPython SDK 上に構築された本物のMCPサーバーであり、標準のstdioトランスポートを介して4つのツール(list_tables、run_sql_query、get_column_stats、plot_bar_chart)を公開しています。src/smoke_test_client.pyは、LLMを一切関与させないプロトコルレベルのテストです。サーバーを実際のサブプロセスとして起動し、stdio経由で接続してlist_tools()を呼び出し、実際のMCPワイヤプロトコルを通じてrun_sql_queryを呼び出します。これこそが、その上で動くエージェントが機能するかどうかとは無関係に、サーバーが機能することを証明するものです。src/mcp_client_agent.pyはエージェントです。サーバーのツールを一覧表示し、そのJSONスキーマを直接Geminiの関数宣言に変換し(parameters_json_schema=tool.input_schema— 手動でのスキーマ変換は不要)、標準的なツール呼び出しループを実行します。モデルに問い合わせる → 実際のMCPセッションを介して要求されたツール呼び出しを実行する → 結果をフィードバックする → モデルが最終回答を返すまで繰り返します。
Related MCP server: agente-ecommerce-mcp-memoria
Python 3.10+ が必要です
mcp パッケージはPython 3.9をサポートしていません。デフォルトの python が古い場合は、以下のすべてのコマンドで py -3.12(またはお持ちの3.10以降のインタープリタ)を使用してください。
パイプライン
pip install -r requirements.txt
python src/generate_data.py # -> data/sales.db (3,000 synthetic orders)
python src/smoke_test_client.py # protocol-only sanity check, no LLM
python src/mcp_client_agent.py "Which category has the highest revenue?"GEMINI_API_KEY が設定されていない場合、mcp_client_agent.py は手動フォールバックを実行します。稼働中のサーバーから発見したツールを一覧表示し、そのうちの1つを直接呼び出すため、APIキーがゼロでもMCPの配管を実演できます。キーを設定すると(.env.example を .env にコピー)、完全なエージェントループが実行されます。
テスト
tests/test_pipeline.py は、サーバーのツール関数を直接呼び出します(スキーマのイントロスペクション、非SELECT文のSQL拒否、統計)。そして、これが機能するMCP実装であることの本当の証明として、smoke_test_client.py を実行します。これはサーバーを実際のサブプロセスとして起動し、実際のstdioプロトコルで通信します。APIキーは不要なので、Python 3.12でプッシュのたびにCIで実行されます。
pip install -r requirements.txt pytest
pytest tests/ -vサーバーが公開するツール
ツール | 目的 |
| スキーマのイントロスペクション |
| 読み取り専用SQL — データベースに到達する前に |
|
|
| 地域/カテゴリ別に集計し、PNGを保存します |
検証済み vs. 独立検証は未実施
検証済み: MCPサーバーとプロトコルの配線(ツール発見、stdio経由のツール実行)—
smoke_test_client.pyはLLMをループに含めずにエンドツーエンドで実行し、mcp_client_agent.pyの手動フォールバックパスも同じ実際のプロトコルを実行します。現在の
google-genaiSDK に対して実装済みだが、この環境ではライブキーで実行されていない: Geminiのツール呼び出しループ自体です。関数宣言と関数応答の型はインストール済みSDKに対して直接確認しましたが、実際のマルチターン呼び出しにはこの環境にはないAPIキーが必要です。ご自身のGEMINI_API_KEYで実行して、そのパスを試してください。
プロジェクト構成
data/ generated sales.db
src/ mcp_server, smoke_test_client, mcp_client_agent, generate_data
reports/ charts saved by plot_bar_chartスタック
Python 3.12 · mcp(公式Model Context Protocol SDK)· google-genai · SQLite · matplotlib
ライセンス
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
- AlicenseAqualityCmaintenanceA production-grade MCP server for enterprise sales analytics, enabling LLM clients to query, analyze, and visualize sales data from a SQLite database through structured tools, resources, and prompts.6MIT
- FlicenseNot gradedqualityBmaintenanceAn MCP server that exposes a LangChain agent with short-term memory to analyze real e-commerce data through predefined SQL tools, enabling natural language queries on sales, customers, and logistics.
- FlicenseNot gradedqualityCmaintenanceMCP server that routes natural language queries to backend analytics tools (Sales, Finance, Customer, Service) using Google Gemini's function calling.
- AlicenseNot gradedqualityCmaintenanceA production-style MCP server exposing six business tools (web search, database, CRM, email, calendar, analytics) to AI clients via a secure, authenticated interface, with mock mode and a reference agent client.MIT
Related MCP Connectors
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Hosted MCP endpoint with realistic fake data for prototyping agents. 12 tools, no setup.
GibsonAI MCP server: manage your databases with natural language
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/dhandashreya/mcp-data-agent'
If you have feedback or need assistance with the MCP directory API, please join our Discord server