Mock Store MCP Server
Enables AI agents to explore and query a mock e-commerce store's data including customers, products, inventory, and orders through conversational interactions backed by PostgreSQL.
README
MCP Mock Store Example
This repository contains an end-to-end example of a fastMCP server that exposes a mock e-commerce store backed by a FastAPI application and a PostgreSQL database. It demonstrates how to share the same data source between a REST API and Model Context Protocol (MCP) tools so that conversational AI agents can explore store information such as customers, inventory, and orders.
Project layout
.
├── app/ # FastAPI application (SQLAlchemy models, schemas, CRUD helpers)
├── mcp_server/ # fastMCP server exposing store data as tools
├── sql/ # SQL scripts for schema and seed data
├── docker-compose.yml # Local PostgreSQL instance with preloaded data
├── requirements.txt # Python dependencies for both servers
└── .env.example # Example environment variables
Prerequisites
- Python 3.11+
- Docker and Docker Compose (v2 or newer)
pipfor installing Python dependencies
1. Start the database
docker compose up -d
The PostgreSQL container mounts the sql/ directory into /docker-entrypoint-initdb.d, so the schema (create_tables.sql) and sample data (seed_data.sql) are loaded automatically the first time the container starts.
2. Configure environment variables
Copy the example environment file and adjust it if you changed any credentials or hostnames:
cp .env.example .env
Both the FastAPI service and the fastMCP server read the DATABASE_URL environment variable. The default connection string assumes you are running locally with the docker-compose.yml configuration.
3. Install dependencies
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
4. Run the FastAPI backend
uvicorn app.main:app --reload
Example endpoints
GET /customers– list all customersGET /customers/{id}– retrieve a single customerGET /products– browse available productsGET /inventory– inspect inventory levelsGET /orders– view orders including nested line itemsGET /orders/{id}– fetch a specific order
5. Run the fastMCP server
python -m mcp_server
The server registers the following tools:
| Tool name | Description |
|---|---|
list_customers |
Returns all customers and their metadata. |
list_products |
Lists available products. |
list_inventory |
Provides current inventory levels. |
list_orders |
Retrieves orders with customer and line item data. |
get_order |
Returns a single order by ID, or an error if missing. |
get_store_summary |
Aggregates counts and high-level metrics. |
Each tool responds with JSON derived from the same SQLAlchemy models used by the FastAPI backend, ensuring consistent representations across HTTP and MCP interfaces.
6. Connect from popular AI chatbots
Below are quick-start notes for common MCP-compatible clients. Substitute the path to your virtual environment's Python interpreter if different (e.g., .venv/bin/python).
Anthropic Claude Desktop
- Open Claude Desktop and navigate to Settings → Configure MCP Servers.
- Add a new server with:
- Command:
python - Arguments:
-m mcp_server - Working directory: the root of this repository.
- Command:
- Ensure the
DATABASE_URLenvironment variable is available to Claude (e.g., by launching Claude from a shell session where it is exported). - Claude can now call tools such as
get_store_summaryduring conversations.
Cursor IDE
- Open Cursor and run the command Cursor: Configure MCP Servers.
- Create an entry with the command
pythonand arguments-m mcp_server. - Optionally specify environment variables via the configuration panel so the MCP server can reach the PostgreSQL instance.
- Use the “Connect MCP Server” command to make tools available in the chat sidebar.
VS Code + Continue
-
Install the Continue extension (version 0.9.0+).
-
Open the Continue settings (
continue.json) and add:{ "servers": [ { "name": "mock-store", "command": "python", "args": ["-m", "mcp_server"], "cwd": "${workspaceFolder}", "env": { "DATABASE_URL": "postgresql+psycopg2://mcp_user:mcp_password@localhost:5432/mcp_store" } } ] } -
Restart Continue; the mock store tools will appear in the MCP tool palette.
OpenAI Desktop / ChatGPT Desktop (beta MCP support)
- Launch the client from a terminal with the virtual environment activated so the MCP server dependencies are available.
- In the MCP configuration UI, add a custom server pointing to
python -m mcp_server. - Use the UI to map environment variables or rely on your shell environment.
Tip: If a client requires an absolute path to the interpreter, run
which python(Linux/macOS) orwhere python(Windows) inside the virtual environment and paste that path into the MCP configuration.
Database management
-
Reset data: stop the containers (
docker compose down), delete the volume (docker volume rm mcp_postgres-data), and start again. -
Manual migrations: you can rerun the SQL scripts with
psql:psql postgresql://mcp_user:mcp_password@localhost:5432/mcp_store -f sql/create_tables.sql psql postgresql://mcp_user:mcp_password@localhost:5432/mcp_store -f sql/seed_data.sql
Testing the MCP tools manually
Once the server is running, you can issue direct requests with the fastmcp client utilities:
python -m fastmcp.client --command "get_store_summary"
Refer to the fastmcp documentation for more advanced usage such as streaming outputs or structured arguments.
License
This example is provided under the MIT license. Use it as a starting point for your own MCP-integrated services.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。