A community-driven registry for Claude, Cursor, Windsurf, Cline & more. Not affiliated with Anthropic.
Are you the author? Sign in to claim
A Model Context Protocol (MCP) server that provides comprehensive customer sales database access for Zava Retail DIY Bus
Follow these steps to get started using these resources:
git clone https://github.com/YOUR-USERNAME/MCP-Server-and-PostgreSQL-Sample-Retail.gitFrench | Spanish | German | Russian | Arabic | Persian (Farsi) | Urdu | Chinese (Simplified) | Chinese (Traditional, Macau) | Chinese (Traditional, Hong Kong) | Chinese (Traditional, Taiwan) | Japanese | Korean | Hindi | Bengali | Marathi | Nepali | Punjabi (Gurmukhi) | Portuguese (Portugal) | Portuguese (Brazil) | Italian | Polish | Turkish | Greek | Thai | Swedish | Danish | Norwegian | Finnish | Dutch | Hebrew | Vietnamese | Indonesian | Malay | Tagalog (Filipino) | Swahili | Hungarian | Czech | Slovak | Romanian | Bulgarian | Serbian (Cyrillic) | Croatian | Slovenian | Ukrainian | Burmese (Myanmar)
If you wish to have additional translations languages supported are listed here
This sample demonstrates how to build and deploy a comprehensive Model Context Protocol (MCP) server that provides AI assistants with secure, intelligent access to retail sales data through PostgreSQL. The project showcases enterprise-grade features including Row Level Security (RLS), semantic search capabilities, and Azure AI integration for real-world retail analytics scenarios.
Key Use Cases:
Perfect for:
Share your experiences of MCP and meet the experts and product groups
A Model Context Protocol (MCP) server that provides comprehensive customer sales database access for Zava Retail DIY Business. This server enables AI assistants to query and analyze retail sales data through a secure, schema-aware interface.
For a detailed breakdown of how this solution is built and how to implement similar MCP servers, see our comprehensive Sample Walkthrough. This guide provides:
Perfect for developers who want to understand the implementation details and build similar solutions.
Model Context Protocol (MCP) is an open standard that enables AI assistants to securely access external data sources and tools in real-time. Think of it as a bridge that allows AI models to connect with databases, APIs, file systems, and other resources while maintaining security and control.
If you're new to Model Context Protocol, we recommend starting with Microsoft's comprehensive beginner resources:
This resource provides:
Once you understand the basics, return here to explore this advanced retail analytics implementation!
This repository includes a complete 12-module learning walkthrough that deconstructs this MCP retail server sample into digestible, step-by-step lessons. The walkthrough transforms this working example into a comprehensive educational resource perfect for developers who want to understand how to build production-ready MCP servers with database integration.
The walkthrough covers everything from basic MCP concepts to advanced production deployment, including:
The walkthrough follows a progressive learning structure designed for developers of all skill levels:
| Module | Focus Area | Description | Time Estimate |
|---|---|---|---|
| 00-Introduction | Foundation | MCP concepts, Zava Retail case study, architecture overview | 30 minutes |
| 01-Architecture | Design Patterns | Technical architecture, layered design, system components | 45 minutes |
| 02-Security | Enterprise Security | Azure authentication, Row Level Security, multi-tenant isolation | 60 minutes |
| 03-Setup | Environment | Docker setup, Azure CLI, project configuration, validation | 45 minutes |
| 04-Database | Data Layer | PostgreSQL schema, pgvector, RLS policies, sample data | 60 minutes |
| 05-MCP-Server | Core Implementation | FastMCP framework, database integration, connection management | 90 minutes |
| 06-Tools | Tool Development | MCP tool creation, query validation, business intelligence features | 75 minutes |
| 07-Semantic-Search | AI Integration | Azure OpenAI embeddings, vector search, hybrid search strategies | 60 minutes |
| 08-Testing | Quality Assurance | Unit testing, integration testing, performance testing, debugging | 75 minutes |
| 09-VS-Code | Development Experience | VS Code configuration, AI Chat integration, debugging workflows | 45 minutes |
| 10-Deployment | Production Ready | Containerization, Azure Container Apps, CI/CD pipelines, scaling | 90 minutes |
| 11-Monitoring | Observability | Application Insights, structured logging, performance metrics | 60 minutes |
| 12-Best-Practices | Production Excellence | Security hardening, performance optimization, enterprise patterns | 45 minutes |
Total Learning Time: ~12-15 hours of comprehensive hands-on learning
For Beginners:
For Experienced Developers:
For Production Implementation:
Option 1: Complete Learning Path (Recommended for newcomers)
# Clone and start with the introduction
git clone https://github.com/microsoft/MCP-Server-and-PostgreSQL-Sample-Retail.git
cd MCP-Server-and-PostgreSQL-Sample-Retail/walkthrough
# Follow along starting with 00-Introduction/README.md
Option 2: Hands-On Implementation (Jump right into building)
# Start with setup and build as you learn
cd walkthrough/03-Setup
# Follow the setup guide and continue through implementation modules
Option 3: Production Focus (Enterprise deployment)
# Focus on production-ready aspects
# Review modules: 02-Security, 10-Deployment, 11-Monitoring, 12-Best-Practices
Recommended Background:
Not Required (but helpful):
Ready to start learning? Begin with Module 00: Introduction or explore the complete walkthrough overview.
text-embedding-3-small model and optionally gpt-4o-mini model.Open a terminal window and running the following commands:
Authenticate with Azure CLI
az login
Clone the repository
git clone https://github.com/gloveboxes/Zava-MCP-Server-and-PostgreSQL-Sample
Navigate to the project directory
cd Zava-MCP-Server-and-PostgreSQL-Sample
Run the following scripts to automate the deployment of Azure resources needed for the MCP server.
The deployment scripts will automatically deploy the text-embedding-3-small model. During deployment, you'll have the option to also include the gpt-4o-mini model. Note that gpt-4o-mini is not required for this project and is only included for potential future enhancements.
Choose the script for your platform:
# Run from the project root directory
cd infra && ./deploy.ps1
# Run from the project root directory
cd infra && ./deploy.sh
The easiest way to run the complete stack (PostgreSQL + MCP Server) is using Docker Compose:
# Start PostgreSQL and MCP Server
docker compose up -d
# View logs
docker compose logs -f
# View MCP Server Logs
docker compose logs -f mcp_server
# View the PostgreSQL Logs
docker compose logs -f pg17
# Stop the stack
docker compose down -v
The following assumes you'll be using the built-in VS Code MCP server support.
Open the project in VS Code. From the terminal, run:
code .
Start one or more MCP servers using the configurations in .vscode/mcp.json. The file contains four different server configurations, each representing a different store manager role:
{
"servers": {
"zava-sales-analysis-headoffice": {
"url": "http://127.0.0.1:8000/mcp",
"type": "http",
"headers": {"x-rls-user-id": "00000000-0000-0000-0000-000000000000"}
},
"zava-sales-analysis-seattle": {
"url": "http://127.0.0.1:8000/mcp",
"type": "http",
"headers": {"x-rls-user-id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"}
},
"zava-sales-analysis-redmond": {
"url": "http://127.0.0.1:8000/mcp",
"type": "http",
"headers": {"x-rls-user-id": "e7f8a9b0-c1d2-3e4f-5678-90abcdef1234"}
},
"zava-sales-analysis-online": {
"url": "http://127.0.0.1:8000/mcp",
"type": "http",
"headers": {"x-rls-user-id": "2f4e6d8c-1a3b-5c7e-9f0a-b2d4f6e8c0a2"}
}
},
"inputs": []
}
The server provides access to the following retail database tables:
retail.customers - Customer information and profilesretail.stores - Store locations and detailsretail.categories - Product categories and hierarchiesretail.product_types - Product type classificationsretail.products - Product catalog and specificationsretail.orders - Customer orders and transactionsretail.order_items - Individual items within ordersretail.inventory - Current inventory levels and stock dataget_multiple_table_schemasRetrieve database schemas for multiple tables in a single request.
Parameters:
table_names (list[str]): List of valid table names from the supported tables aboveReturns: Concatenated schema strings for the requested tables
execute_sales_queryExecute PostgreSQL queries against the sales database with Row Level Security.
Parameters:
postgresql_query (str): A well-formed PostgreSQL queryReturns: Query results formatted as a string (limited to 20 rows for readability)
Best Practices:
get_current_utc_dateGet the current UTC date and time in ISO format.
Returns: Current UTC date/time in ISO format (YYYY-MM-DDTHH:MM:SS.fffffZ)
semantic_search_productsPerform a semantic search for products based on user queries.
Returns: A list of products matching the search criteria
Parameters:
query (str): The search query stringReturns: A list of products matching the search criteria
The server implements Row Level Security to ensure users only access data they're authorized to view:
HTTP Mode: Uses x-rls-user-id header to identify the requesting user
Default Fallback: Uses placeholder UUID when no user ID is provided
Each Zava Retail store location has a unique RLS user ID that determines which data the user can access:
| Store Location | RLS User ID | Description |
|---|---|---|
| Global Access | 00000000-0000-0000-0000-000000000000 | Default fallback - all store access |
| Seattle | f47ac10b-58cc-4372-a567-0e02b2c3d479 | Zava Retail Seattle store data |
| Bellevue | 6ba7b810-9dad-11d1-80b4-00c04fd430c8 | Zava Retail Bellevue store data |
| Tacoma | a1b2c3d4-e5f6-7890-abcd-ef1234567890 | Zava Retail Tacoma store data |
| Spokane | d8e9f0a1-b2c3-4567-8901-234567890abc | Zava Retail Spokane store data |
| Everett | 3b9ac9fa-cd5e-4b92-a7f2-b8c1d0e9f2a3 | Zava Retail Everett store data |
| Redmond | e7f8a9b0-c1d2-3e4f-5678-90abcdef1234 | Zava Retail Redmond store data |
| Kirkland | 9c8b7a65-4321-fed0-9876-543210fedcba | Zava Retail Kirkland store data |
| Online | 2f4e6d8c-1a3b-5c7e-9f0a-b2d4f6e8c0a2 | Zava Retail Online store data |
When a user connects with a specific store's RLS User ID, they will only see:
This ensures data isolation between different store locations while maintaining a unified database schema.
The server uses a managed application context with:
AppContext dataclassThe server integrates with a PostgreSQL database through the PostgreSQLSchemaProvider class:
The server implements robust error handling:
00000000-0000-0000-0000-000000000000) provides limited accessmcp_server/
├── sales_analysis.py # Main MCP server implementation
├── sales_analysis_postgres.py # PostgreSQL integration layer
├── sales_analysis_text_embedding.py # Text embedding for semantic search tool
When contributing to this server:
This MCP server enables secure, efficient access to Zava Retail sales data for AI-powered analysis and insights.
Run Claude Code as an MCP server so any agent can delegate coding tasks to it
Browser automation using accessibility snapshots instead of screenshots
MCP server integration for DaVinci Resolve Studio
A Jetbrains IDE IntelliJ plugin aimed to provide coding agents the ability to leverage intelliJ's indexing of the codeba