Commerce Server
FreeNot checkedEnables natural-language querying of e-commerce data (products, users, orders) from a PostgreSQL database, using a Hugging Face model for safe intent extraction
About
Enables natural-language querying of e-commerce data (products, users, orders) from a PostgreSQL database, using a Hugging Face model for safe intent extraction and parameterized SQL execution.
README
This project provides a deployment-ready MCP server that can be invoked from a LangGraph orchestration flow.
It accepts natural-language input, uses an open-source Hugging Face model to derive query intent, and safely fetches data from PostgreSQL.
What is implemented
- MCP tools:
query_commerce(query, user_context?, limit?)get_product_price(product_name, limit?)get_user_orders(user_id?, email?, limit?)calculate_two_numbers(a, b, operation?)where operation supports add/subtract
- PostgreSQL schema for:
- Product prices (
products) - Users (
users) - Orders (
orders,order_items)
- Product prices (
- Hugging Face model integration (open-source text-to-text model default:
google/flan-t5-base) - SQL-injection-safe query layer (no model SQL execution; only parameterized, pre-approved SQL templates)
- OpenTelemetry tracing and structured logging for MCP tool flow, intent parsing, DB connection, and query execution
- Docker + docker-compose setup for deployment
Why this is SQL-injection safe
- LLM output is treated as intent only, not executable SQL.
- The server maps intent to a fixed set of SQL templates.
- All runtime values are passed as query parameters via psycopg (
%splaceholders). limitis bounded server-side to prevent abuse.
Project structure
.
├── db/init.sql
├── docker-compose.yml
├── Dockerfile
├── examples/langgraph_client.py
├── pyproject.toml
├── requirements.txt
└── src/mcp_commerce_server
├── config.py
├── db.py
├── hf_intent.py
├── main.py
├── query_service.py
└── server.py
1. Local development setup
- Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate - Install dependencies:
pip install -r requirements.txt - Create env file:
cp .env.example .env - Start PostgreSQL and seed schema:
- Option A: Use your own DB and run
db/init.sql. - Option B: Use docker-compose (recommended below).
- Option A: Use your own DB and run
2. Run with docker-compose (deployment-ready local)
- Ensure
.envexists and hasHF_API_KEY. - Start services:
docker compose up --build - MCP server is exposed at:
http://localhost:8000/mcp(streamable-http transport)
3. Run MCP server directly (stdio for local MCP clients)
python -m mcp_commerce_server.main
Set MCP_TRANSPORT=stdio in .env for this mode.
4. LangGraph orchestration usage
- See
examples/langgraph_client.pyfor end-to-end invocation. - The example now connects to two MCP servers:
commerceatMCP_COMMERCE_URL(defaulthttp://localhost:8000/mcp)knowledgeatMCP_KNOWLEDGE_URL(defaulthttp://localhost:8001/mcp)
- It sends different prompts so the model routes to different tools (commerce query tools,
calculate_two_numbers, and knowledge tools).
5. Environment variables
| Variable | Description | Required |
|---|---|---|
POSTGRES_HOST |
PostgreSQL host | Yes |
POSTGRES_PORT |
PostgreSQL port | Yes |
POSTGRES_DB |
Database name | Yes |
POSTGRES_USER |
Database user | Yes |
POSTGRES_PASSWORD |
Database password | Yes |
HF_API_KEY |
Hugging Face API key | Yes (for model inference) |
HF_MODEL_ID |
Open-source HF model id | No (google/flan-t5-base) |
MCP_TRANSPORT |
stdio or streamable-http |
No (stdio) |
MCP_HOST |
HTTP host for streamable MCP | No (0.0.0.0) |
MCP_PORT |
HTTP port for streamable MCP | No (8000) |
LOG_LEVEL |
Python logging level | No (INFO) |
OTEL_SERVICE_NAME |
OpenTelemetry service name | No (commerce-postgres-mcp) |
6. Deployment steps (production-oriented)
- Build image:
docker build -t commerce-mcp-server:latest . - Push image to your registry:
docker tag commerce-mcp-server:latest <registry>/<namespace>/commerce-mcp-server:latest docker push <registry>/<namespace>/commerce-mcp-server:latest - Provision managed PostgreSQL (AWS RDS / Azure Database / Cloud SQL).
- Apply
db/init.sqlonce (or convert to migration pipeline). - Deploy container to your platform (Kubernetes, ECS, App Service, Cloud Run, etc.) with:
MCP_TRANSPORT=streamable-http- DB connection variables
HF_API_KEYsecret
- Expose HTTP endpoint and allow only trusted callers (VPC/ingress ACL, auth gateway, or service mesh policy).
- Configure LangGraph to call deployed MCP URL.
7. Hardening recommendations before go-live
- Use DB least-privilege user (read-only if writes are unnecessary).
- Add request auth in front of MCP endpoint (API gateway/JWT/mTLS).
- Add query logging + tracing.
- Add circuit breakers/timeouts for HF and DB.
- Add schema migrations (Alembic/Flyway/liquibase) for controlled releases.
Installing Commerce Server
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/vikramjt/mcp_demoFAQ
Is Commerce Server MCP free?
Yes, Commerce Server MCP is free — one-click install via Unyly at no cost.
Does Commerce Server need an API key?
No, Commerce Server runs without API keys or environment variables.
Is Commerce Server hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install Commerce Server in Claude Desktop, Claude Code or Cursor?
Open Commerce Server on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
wenb1n-dev/SmartDB_MCP
A universal database MCP server supporting simultaneous connections to multiple databases. It provides tools for database operations, health analysis, SQL optim
by wenb1n-devPostgres Server
This server enables interaction with PostgreSQL databases through the Model Context Protocol, optimized for the AWS Bedrock AgentCore Runtime. It provides tools
by madhurprashPostgres
Query your database in natural language
by AnthropicPostgreSQL
Read-only database access with schema inspection.
by modelcontextprotocolRedis
Interact with Redis key-value stores.
by modelcontextprotocolSQLite
Database interaction and business intelligence capabilities.
by modelcontextprotocolmxcp
Open-source framework for building enterprise-grade MCP servers using just YAML, SQL, and Python, with built-in auth, monitoring, ETL and policy enforcement.
by raw-labstadas-github/a2asearch-mcp
MCP server to search 4,800+ MCP servers, AI agents, CLI tools and agent skills. Install: npx -y a2asearch-mcp. Ask Claude: "Find MCP servers for database access
by tadas-githubjulien040/anyquery
Query more than 40 apps with one binary using SQL. It can also connect to your PostgreSQL, MySQL, or SQLite compatible database. Local-first and private by desi
by julien040drakonkat/wizzy-mcp-tmdb
A MCP server for The Movie Database API that enables AI assistants to search and retrieve movie, TV show, and person information.
by drakonkatCompare Commerce Server with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All data MCPs
