Skip to main content

What you will build

These labs walk you through building the Zava Retail Analytics MCP Server — a production-grade implementation that connects AI assistants to a PostgreSQL retail database. The sample repository is at github.com/microsoft/MCP-Server-and-PostgreSQL-Sample-Retail. By the end of the path you will have built:
  • A multi-table retail database with customer orders, products, and inventory
  • Row Level Security for store-based data isolation
  • Semantic product search using Azure OpenAI embeddings and pgvector
  • VS Code AI Chat integration for natural language queries
  • Production-ready deployment with Docker and Azure Container Apps
  • Comprehensive monitoring with Application Insights

Prerequisites

Programming

Familiarity with Python (preferred) or a similar language. Basic understanding of async programming.

Databases

Basic SQL and relational database concepts. No PostgreSQL expertise required.

APIs

Understanding of REST APIs and HTTP concepts. Familiarity with JSON.

Tools

Command line, Git, and a code editor. Docker familiarity recommended but not required.

Required tools

ToolPurpose
Docker DesktopRun PostgreSQL and the MCP server locally
Azure CLIDeploy cloud resources
VS CodeDevelopment environment and MCP Chat integration
GitClone the sample repository
Python 3.8+MCP server development

Lab structure

The labs are organized into three phases.

Phase 1 — Foundations (Labs 00–03)

Understand the architecture, security model, and get your environment ready before writing any server code.

Phase 2 — Building the MCP Server (Labs 04–06)

Design the database schema, implement the FastMCP server, and create database query tools.

Phase 3 — Advanced Features and Production (Labs 07–12)

Add semantic search, testing, VS Code integration, deployment, monitoring, and best practices.

All labs

Lab 0: Introduction

Overview of MCP database integration and the Zava Retail use case.

Lab 1: Core Architecture

Layered architecture patterns, database design, and connection management.

Lab 2: Security & Multi-Tenancy

Row Level Security, Azure Entra ID authentication, and audit logging.

Lab 3: Environment Setup

Install tools, deploy Azure resources, and start Docker containers.

Lab 4: Database Design

PostgreSQL schema, pgvector setup, RLS policies, and sample data.

Lab 5: MCP Server

Build the FastMCP server with database integration and health endpoints.

Lab 6: Tool Development

Create advanced query tools, schema introspection, and analytics tools.

Lab 7: Semantic Search

Vector embeddings with Azure OpenAI and pgvector similarity search.

Lab 8: Testing & Debugging

Unit tests, integration tests, performance testing, and debugging tools.

Lab 9: VS Code Integration

Configure VS Code MCP settings and use AI Chat for natural language queries.

Lab 10: Deployment

Docker, Azure Container Apps, CI/CD pipelines, and auto-scaling.

Lab 11: Monitoring

Application Insights, structured logging, alerting, and dashboards.

Lab 12: Best Practices

Performance optimization, security hardening, and production guidelines.
  1. Complete MCP for Beginners modules 0–10 first.
  2. Work through Labs 00–03 to reinforce foundations.
  3. Follow Labs 04–06 for hands-on building.
  4. Try Labs 07–09 for practical usage.
  1. Review Labs 00–01 for database-specific concepts.
  2. Focus on Labs 02–06 for implementation.
  3. Dive into Labs 07–12 for advanced features.
  1. Skim Labs 00–03 for context.
  2. Focus on Labs 04–09 for database integration patterns.
  3. Concentrate on Labs 10–12 for production deployment.

Official MCP resources

Start with Lab 0: Introduction

Begin the learning path here.

Build docs developers (and LLMs) love