sales-db
Provides tools to interact with a SQLite database containing sales data, enabling AI agents to inspect database structure and execute SQL queries to retrieve customer, product, and sales transaction information.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@sales-db先月いちばん売れたGPUは?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
売上データベース MCP サーバー チュートリアル
「先月いちばん売れた GPU はどれ?」とふつうの日本語で聞くと、AI が自分で SQL を組み立てて 売上データベースに問い合わせ、集計結果まで答えてくれる——それを実現する MCP サーバーのサンプルです。
Python + FastMCP で書かれていて、git clone から 3 コマンドで動きます。
解説記事は Qualiteg Blog に掲載しています。
クイックスタート
git clone https://github.com/qualiteg/mcp-server-tutorial.git
cd mcp-server-tutorial
pip install -r requirements.txt
python db_setup.py # ダミーデータ入りの SQLite を生成
python mcp_server_sales.py # MCP サーバーを起動(stdio)db_setup.py は固定シードで架空のデータを生成します(実在の企業・人物・価格とは関係ありません)。
誰が実行しても同じデータになるので、記事の実行結果と一致します。
customers … 顧客マスター 500 人
products … 商品マスター 72 種類(PC パーツ 8 カテゴリ)
sales_transactions … 売上明細 4,000 件(2024-01-01 〜 2026-12-31)
Related MCP server: JVLink MCP Server
AI から使う
Claude Code
claude mcp add sales-db -- python /path/to/mcp-server-tutorial/mcp_server_sales.pyClaude Desktop
claude_desktop_config.json に追記します。
{
"mcpServers": {
"sales-db": {
"command": "python",
"args": ["/path/to/mcp-server-tutorial/mcp_server_sales.py"]
}
}
}登録できたら、こんなふうに話しかけてみてください。
「職業別の売上トップ3を教えて」
「2025年に発売されたハイエンドGPUで、売上が多い順に並べて」
「月別の売上推移を出して、いちばん売れた月は?」
AI はまず get_database_stats でテーブル構造を確認し、そのうえで execute_sql_query に SQL を
渡して答えます。SQL を書いたことがない人でも、売上データベースに"話しかけられる"ようになります。
提供しているツール
ツール | 役割 |
| テーブル構造・件数・データ期間・カテゴリ別売上の要約を返す(AI が最初に呼ぶ) |
| SELECT 文を実行して結果を返す |
業務ごとに「売上集計ツール」「顧客分析ツール」と関数を並べる設計もできますが、SQL を書けるのは AI 側なので、汎用の SQL 実行ツールを 1 本渡すほうが応用が利きます。そのぶん安全側の手当ては サーバーの責任になるので、次の 3 つを実装しています。
読み取り専用: SQLite を
mode=roで開き、加えて SELECT 以外の文と書き換え系キーワードを拒否実行時間の上限: 10 秒を超えるクエリは中断(
set_progress_handler)返却行数の上限: 50 行まで。AI は平気で
SELECT * FROM sales_transactionsを投げてくるので、 AI に返す量はサーバー側で制御します
HTTP サーバーとして動かす
社内サーバーに常駐させて複数人・複数 AI から使う場合は Streamable HTTP で起動します。
python mcp_server_sales.py --http --port 9904MCP エンドポイント:
http://<サーバー>:9904/mcpヘルスチェック:
http://<サーバー>:9904/health
Web 版の ChatGPT・Claude から使いたい場合
Web 版の ChatGPT や Claude のコネクタに登録するには、①インターネットから到達できる HTTPS の URL と、 ②MCP Authorization 仕様に沿った OAuth 認証が必要です。社内サーバーをそのまま公開するわけにもいかず、 OAuth を自前で実装するのも簡単ではありません。
この部分は WireCanal を使うと、受信ポートを開けずに解決できます。 MCP canal と OAuth 認証はフリープラン(無料・期間制限なし)でも利用できるので、このサンプルを そのまま Web 版 ChatGPT・Claude から試せます。手順は解説記事の後編で紹介しています。
動作環境
Python 3.10 以降
fastmcp 2.0 以降(動作確認: 3.4.5)
ライセンス
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
- FlicenseBqualityDmaintenanceProvides access to bakery POS transaction data, product catalogs, and sales analytics from SQLite database through natural language queries and custom SQL execution.Last updated7
- FlicenseBqualityBmaintenanceEnables natural language queries and analysis of Japanese horse racing data from JRA-VAN without writing SQL. Supports analyzing race results, jockey performance, breeding trends, and track conditions through conversation with Claude.Last updated2513
- Flicense-qualityDmaintenanceProvides a suite of business tools for interacting with a SQLite sales database, including SQL query execution, KPI calculations, and report generation. It enables AI agents to analyze sales data across customers, products, and orders using the Model Context Protocol.Last updated
- Flicense-qualityBmaintenanceEnables natural language sales analysis by connecting to a SQLite database, generating charts, and exporting results to CSV/Excel.Last updated
Related MCP Connectors
Run SOQL queries to explore and retrieve Salesforce data. Access accounts, contacts, opportunities…
Provide real-time data querying and visualization by integrating Tako with your agents. Generate o…
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/qualiteg/mcp-server-tutorial'
If you have feedback or need assistance with the MCP directory API, please join our Discord server