This introduction lab provides a comprehensive overview of building Model Context Protocol (MCP) servers with database integration.
You'll understand the business case, technical architecture, and real-world applications through the Zava Retail analytics use case at https://github.com/microsoft/MCP-Server-and-PostgreSQL-Sample-Retail.
Model Context Protocol (MCP) enables AI assistants to securely access and interact with external data sources in real-time. When combined with database integration, MCP unlocks powerful capabilities for data-driven AI applications.
This learning path teaches you to build production-ready MCP servers that connect AI assistants to retail sales data through PostgreSQL, implementing enterprise patterns like Row Level Security, semantic search, and multi-tenant data access.
By the end of this lab, you will be able to:
Modern AI assistants are incredibly powerful but face significant limitations when working with real-world business data:
| Challenge | Description | Business Impact |
|---------------|-----------------|-------------------|
| Static Knowledge | AI models trained on fixed datasets can't access current business data | Outdated insights, missed opportunities |
| Data Silos | Information locked in databases, APIs, and systems AI can't reach | Incomplete analysis, fragmented workflows |
| Security Constraints | Direct database access raises security and compliance concerns | Limited deployment, manual data preparation |
| Complex Queries | Business users need technical knowledge to extract data insights | Reduced adoption, inefficient processes |
Model Context Protocol addresses these challenges by providing:
Throughout this learning path, we'll build an MCP server for Zava Retail, a fictional DIY retail chain with multiple store locations. This realistic scenario demonstrates enterprise-grade MCP implementation.
Zava Retail operates:
Store managers and executives need AI-powered analytics to:
1. Analyze sales performance across stores and time periods
2. Track inventory levels and identify restocking needs
3. Understand customer behavior and purchasing patterns
4. Discover product insights through semantic search
5. Generate reports with natural language queries
6. Maintain data security with role-based access control
The MCP server must provide:
Our MCP server implements a layered architecture optimized for database integration:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ VS Code AI Client โ
โ (Natural Language Queries) โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HTTP/SSE
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Server โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โ โ Tool Layer โ โ Security Layer โ โ Config Layer โ โ
โ โ โ โ โ โ โ โ
โ โ โข Query Tools โ โ โข RLS Context โ โ โข Environment โ โ
โ โ โข Schema Tools โ โ โข User Identity โ โ โข Connections โ โ
โ โ โข Search Tools โ โ โข Access Controlโ โ โข Validation โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ asyncpg
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PostgreSQL Database โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โ โ Retail Schema โ โ RLS Policies โ โ pgvector โ โ
โ โ โ โ โ โ โ โ
โ โ โข Stores โ โ โข Store-based โ โ โข Embeddings โ โ
โ โ โข Customers โ โ Isolation โ โ โข Similarity โ โ
โ โ โข Products โ โ โข Role Control โ โ Search โ โ
โ โ โข Orders โ โ โข Audit Logs โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ REST API
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Azure OpenAI โ
โ (Text Embeddings) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| Component | Technology | Purpose |
|---------------|----------------|-------------|
| MCP Framework | FastMCP (Python) | Modern MCP server implementation |
| Database | PostgreSQL 17 + pgvector | Relational data with vector search |
| AI Services | Azure OpenAI | Text embeddings and language models |
| Containerization | Docker + Docker Compose | Development environment |
| Cloud Platform | Microsoft Azure | Production deployment |
| IDE Integration | VS Code | AI Chat and development workflow |
| Tool | Purpose |
|----------|-------------|
| asyncpg | High-performance PostgreSQL driver |
| Pydantic | Data validation and serialization |
| Azure SDK | Cloud service integration |
| pytest | Testing framework |
| Docker | Containerization and deployment |
| Service | Azure Resource | Purpose |
|-------------|-------------------|-------------|
| Database | Azure Database for PostgreSQL | Managed database service |
| Container | Azure Container Apps | Serverless container hosting |
| AI Services | Azure AI Foundry | OpenAI models and endpoints |
| Monitoring | Application Insights | Observability and diagnostics |
| Security | Azure Key Vault | Secrets and configuration management |
Let's explore how different users interact with our MCP server:
User: Sarah, Seattle Store Manager
Goal: Analyze last quarter's sales performance
Natural Language Query:
> "Show me the top 10 products by revenue for my store in Q4 2024"
What Happens:
1. VS Code AI Chat sends query to MCP server
2. MCP server identifies Sarah's store context (Seattle)
3. RLS policies filter data to Seattle store only
4. SQL query generated and executed
5. Results formatted and returned to AI Chat
6. AI provides analysis and insights
User: Mike, Inventory Manager
Goal: Find products similar to a customer request
Natural Language Query:
> "What products do we sell that are similar to 'waterproof electrical connectors for outdoor use'?"
What Happens:
1. Query processed by semantic search tool
2. Azure OpenAI generates embedding vector
3. pgvector performs similarity search
4. Related products ranked by relevance
5. Results include product details and availability
6. AI suggests alternatives and bundling opportunities
User: Jennifer, Regional Manager
Goal: Compare performance across all stores
Natural Language Query:
> "Compare sales by category for all stores in the last 6 months"
What Happens:
1. RLS context set for regional manager access
2. Complex multi-store query generated
3. Data aggregated across store locations
4. Results include trends and comparisons
5. AI identifies insights and recommendations
Our implementation prioritizes enterprise-grade security:
PostgreSQL RLS ensures data isolation:
-- Store managers see only their store's data
CREATE POLICY store_manager_policy ON retail.orders
FOR ALL TO store_managers
USING (store_id = get_current_user_store());
-- Regional managers see multiple stores
CREATE POLICY regional_manager_policy ON retail.orders
FOR ALL TO regional_managers
USING (store_id = ANY(get_user_store_list()));
Each MCP connection includes:
Multiple layers of security:
After completing this introduction, you should understand:
โ MCP Value Proposition: How MCP bridges AI assistants and real-world data
โ Business Context: Zava Retail's requirements and challenges
โ Architecture Overview: Key components and their interactions
โ Technology Stack: Tools and frameworks used throughout
โ Security Model: Multi-tenant data access and protection
โ Usage Patterns: Real-world query scenarios and workflows
Ready to dive deeper? Continue with:
Lab 01: Core Architecture Concepts
Learn about MCP server architecture patterns, database design principles, and the detailed technical implementation that powers our retail analytics solution.
---
Disclaimer: This is a learning exercise using fictional retail data. Always follow your organization's data governance and security policies when implementing similar solutions in production environments.
์ด ์ ๋ฌธ ์ค์ต์ ๋ฐ์ดํฐ๋ฒ ์ด์ค ํตํฉ์ ํตํด Model Context Protocol (MCP) ์๋ฒ๋ฅผ ๊ตฌ์ถํ๋ ๋ฐฉ๋ฒ์ ๋ํ ํฌ๊ด์ ์ธ ๊ฐ์๋ฅผ ์ ๊ณตํฉ๋๋ค. https://github.com/microsoft/MCP-Server-and-PostgreSQL-Sample-Retail์ Zava Retail ๋ถ์ ์ฌ๋ก๋ฅผ ํตํด ๋น์ฆ๋์ค ์ฌ๋ก, ๊ธฐ์ ์ํคํ ์ฒ, ์ค์ ์์ฉ ์ฌ๋ก๋ฅผ ์ดํดํ ์ ์์ต๋๋ค.
Model Context Protocol (MCP)์ AI ์ด์์คํดํธ๊ฐ ์ธ๋ถ ๋ฐ์ดํฐ ์์ค์ ์ค์๊ฐ์ผ๋ก ์์ ํ๊ฒ ์ก์ธ์คํ๊ณ ์ํธ์์ฉํ ์ ์๋๋ก ํฉ๋๋ค. ๋ฐ์ดํฐ๋ฒ ์ด์ค ํตํฉ๊ณผ ๊ฒฐํฉํ๋ฉด MCP๋ ๋ฐ์ดํฐ ๊ธฐ๋ฐ AI ์ ํ๋ฆฌ์ผ์ด์ ์ ์ํ ๊ฐ๋ ฅํ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค.
์ด ํ์ต ๊ฒฝ๋ก๋ PostgreSQL์ ํตํด AI ์ด์์คํดํธ๋ฅผ ์๋งค ํ๋งค ๋ฐ์ดํฐ์ ์ฐ๊ฒฐํ๊ณ , Row Level Security, ์๋ฏธ ๊ฒ์, ๋ฉํฐ ํ ๋ํธ ๋ฐ์ดํฐ ์ก์ธ์ค์ ๊ฐ์ ์ํฐํ๋ผ์ด์ฆ ํจํด์ ๊ตฌํํ๋ ํ๋ก๋์ ์ค๋น MCP ์๋ฒ๋ฅผ ๊ตฌ์ถํ๋ ๋ฐฉ๋ฒ์ ๊ฐ๋ฅด์นฉ๋๋ค.
์ด ์ค์ต์ ์๋ฃํ๋ฉด ๋ค์์ ์ํํ ์ ์์ต๋๋ค:
ํ๋์ AI ์ด์์คํดํธ๋ ๋งค์ฐ ๊ฐ๋ ฅํ์ง๋ง ์ค์ ๋น์ฆ๋์ค ๋ฐ์ดํฐ์ ์์ ํ ๋ ์ค์ํ ํ๊ณ๋ฅผ ๊ฐ์ง๊ณ ์์ต๋๋ค:
| ๋์ ๊ณผ์ | ์ค๋ช | ๋น์ฆ๋์ค ์ํฅ |
|---------------|-----------------|-------------------|
| ์ ์ ์ง์ | ๊ณ ์ ๋ ๋ฐ์ดํฐ์ ์ผ๋ก ํ๋ จ๋ AI ๋ชจ๋ธ์ ํ์ฌ ๋น์ฆ๋์ค ๋ฐ์ดํฐ๋ฅผ ์ก์ธ์คํ ์ ์์ | ์ค๋๋ ํต์ฐฐ๋ ฅ, ๊ธฐํ ์์ค |
| ๋ฐ์ดํฐ ์ฌ์ผ๋ก | ๋ฐ์ดํฐ๋ฒ ์ด์ค, API, ์์คํ ์ ์ ๊ธด ์ ๋ณด๋ก ์ธํด AI๊ฐ ์ ๊ทผ ๋ถ๊ฐ | ๋ถ์์ ํ ๋ถ์, ๋จํธํ๋ ์ํฌํ๋ก |
| ๋ณด์ ์ ์ฝ | ์ง์ ์ ์ธ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ก์ธ์ค๋ ๋ณด์ ๋ฐ ๊ท์ ์ค์ ๋ฌธ์ ๋ฅผ ์ผ๊ธฐ | ์ ํ๋ ๋ฐฐํฌ, ์๋ ๋ฐ์ดํฐ ์ค๋น |
| ๋ณต์กํ ์ฟผ๋ฆฌ | ๋น์ฆ๋์ค ์ฌ์ฉ์๊ฐ ๋ฐ์ดํฐ ํต์ฐฐ๋ ฅ์ ์ถ์ถํ๋ ค๋ฉด ๊ธฐ์ ์ ์ง์์ด ํ์ | ๋ฎ์ ์ฑํ๋ฅ , ๋นํจ์จ์ ์ธ ํ๋ก์ธ์ค |
Model Context Protocol์ ๋ค์์ ํตํด ์ด๋ฌํ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํฉ๋๋ค:
์ด ํ์ต ๊ฒฝ๋ก์์๋ Zava Retail์ด๋ผ๋ ๊ฐ์์ DIY ์๋งค ์ฒด์ธ์ ์ํ MCP ์๋ฒ๋ฅผ ๊ตฌ์ถํฉ๋๋ค. ์ด ํ์ค์ ์ธ ์๋๋ฆฌ์ค๋ ์ํฐํ๋ผ์ด์ฆ๊ธ MCP ๊ตฌํ์ ๋ณด์ฌ์ค๋๋ค.
Zava Retail์ ๋ค์์ ์ด์ํฉ๋๋ค:
๋งค์ฅ ๊ด๋ฆฌ์์ ์์์ AI ๊ธฐ๋ฐ ๋ถ์์ ํตํด ๋ค์์ ์ํํด์ผ ํฉ๋๋ค:
1. ๋งค์ฅ ๋ฐ ๊ธฐ๊ฐ๋ณ ํ๋งค ์ฑ๊ณผ ๋ถ์
2. ์ฌ๊ณ ์์ค ์ถ์ ๋ฐ ์ฌ์ ๊ณ ํ์์ฑ ์๋ณ
3. ๊ณ ๊ฐ ํ๋ ๋ฐ ๊ตฌ๋งค ํจํด ์ดํด
4. ์๋ฏธ ๊ฒ์์ ํตํ ์ ํ ํต์ฐฐ๋ ฅ ๋ฐ๊ฒฌ
5. ์์ฐ์ด ์ฟผ๋ฆฌ๋ฅผ ์ฌ์ฉํ ๋ณด๊ณ ์ ์์ฑ
6. ์ญํ ๊ธฐ๋ฐ ์ก์ธ์ค ์ ์ด๋ฅผ ํตํ ๋ฐ์ดํฐ ๋ณด์ ์ ์ง
MCP ์๋ฒ๋ ๋ค์์ ์ ๊ณตํด์ผ ํฉ๋๋ค:
์ฐ๋ฆฌ์ MCP ์๋ฒ๋ ๋ฐ์ดํฐ๋ฒ ์ด์ค ํตํฉ์ ์ต์ ํ๋ ๊ณ์ธตํ ์ํคํ ์ฒ๋ฅผ ๊ตฌํํฉ๋๋ค:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ VS Code AI Client โ
โ (Natural Language Queries) โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HTTP/SSE
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Server โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โ โ Tool Layer โ โ Security Layer โ โ Config Layer โ โ
โ โ โ โ โ โ โ โ
โ โ โข Query Tools โ โ โข RLS Context โ โ โข Environment โ โ
โ โ โข Schema Tools โ โ โข User Identity โ โ โข Connections โ โ
โ โ โข Search Tools โ โ โข Access Controlโ โ โข Validation โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ asyncpg
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PostgreSQL Database โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โ โ Retail Schema โ โ RLS Policies โ โ pgvector โ โ
โ โ โ โ โ โ โ โ
โ โ โข Stores โ โ โข Store-based โ โ โข Embeddings โ โ
โ โ โข Customers โ โ Isolation โ โ โข Similarity โ โ
โ โ โข Products โ โ โข Role Control โ โ Search โ โ
โ โ โข Orders โ โ โข Audit Logs โ โ โ โ
โ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ REST API
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Azure OpenAI โ
โ (Text Embeddings) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| ๊ตฌ์ฑ ์์ | ๊ธฐ์ | ๋ชฉ์ |
|---------------|----------------|-------------|
| MCP Framework | FastMCP (Python) | ํ๋์ ์ธ MCP ์๋ฒ ๊ตฌํ |
| ๋ฐ์ดํฐ๋ฒ ์ด์ค | PostgreSQL 17 + pgvector | ๊ด๊ณํ ๋ฐ์ดํฐ์ ๋ฒกํฐ ๊ฒ์ |
| AI ์๋น์ค | Azure OpenAI | ํ ์คํธ ์๋ฒ ๋ฉ ๋ฐ ์ธ์ด ๋ชจ๋ธ |
| ์ปจํ ์ด๋ํ | Docker + Docker Compose | ๊ฐ๋ฐ ํ๊ฒฝ |
| ํด๋ผ์ฐ๋ ํ๋ซํผ | Microsoft Azure | ํ๋ก๋์ ๋ฐฐํฌ |
| IDE ํตํฉ | VS Code | AI ์ฑํ ๋ฐ ๊ฐ๋ฐ ์ํฌํ๋ก |
| ๋๊ตฌ | ๋ชฉ์ |
|----------|-------------|
| asyncpg | ๊ณ ์ฑ๋ฅ PostgreSQL ๋๋ผ์ด๋ฒ |
| Pydantic | ๋ฐ์ดํฐ ๊ฒ์ฆ ๋ฐ ์ง๋ ฌํ |
| Azure SDK | ํด๋ผ์ฐ๋ ์๋น์ค ํตํฉ |
| pytest | ํ ์คํธ ํ๋ ์์ํฌ |
| Docker | ์ปจํ ์ด๋ํ ๋ฐ ๋ฐฐํฌ |
| ์๋น์ค | Azure ๋ฆฌ์์ค | ๋ชฉ์ |
|-------------|-------------------|-------------|
| ๋ฐ์ดํฐ๋ฒ ์ด์ค | Azure Database for PostgreSQL | ๊ด๋ฆฌํ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์๋น์ค |
| ์ปจํ ์ด๋ | Azure Container Apps | ์๋ฒ๋ฆฌ์ค ์ปจํ ์ด๋ ํธ์คํ |
| AI ์๋น์ค | Azure AI Foundry | OpenAI ๋ชจ๋ธ ๋ฐ ์๋ํฌ์ธํธ |
| ๋ชจ๋ํฐ๋ง | Application Insights | ๊ด์ฐฐ ๊ฐ๋ฅ์ฑ ๋ฐ ์ง๋จ |
| ๋ณด์ | Azure Key Vault | ๋น๋ฐ ๋ฐ ๊ตฌ์ฑ ๊ด๋ฆฌ |
๋ค์ํ ์ฌ์ฉ์๊ฐ MCP ์๋ฒ์ ์ํธ์์ฉํ๋ ๋ฐฉ๋ฒ์ ์ดํด๋ณด๊ฒ ์ต๋๋ค:
์ฌ์ฉ์: Sarah, ์์ ํ ๋งค์ฅ ๊ด๋ฆฌ์
๋ชฉํ: ์ง๋ ๋ถ๊ธฐ์ ํ๋งค ์ฑ๊ณผ ๋ถ์
์์ฐ์ด ์ฟผ๋ฆฌ:
> "2024๋ 4๋ถ๊ธฐ ๋์ ๋ด ๋งค์ฅ์์ ๋งค์ถ ๊ธฐ์ค ์์ 10๊ฐ ์ ํ์ ๋ณด์ฌ์ค"
์งํ ๊ณผ์ :
1. VS Code AI ์ฑํ ์ด ์ฟผ๋ฆฌ๋ฅผ MCP ์๋ฒ๋ก ์ ์ก
2. MCP ์๋ฒ๊ฐ Sarah์ ๋งค์ฅ ์ปจํ ์คํธ(์์ ํ)๋ฅผ ์๋ณ
3. RLS ์ ์ฑ ์ด ๋ฐ์ดํฐ๋ฅผ ์์ ํ ๋งค์ฅ์ผ๋ก ํํฐ๋ง
4. SQL ์ฟผ๋ฆฌ๊ฐ ์์ฑ๋๊ณ ์คํ๋จ
5. ๊ฒฐ๊ณผ๊ฐ ํฌ๋งท๋์ด AI ์ฑํ ์ผ๋ก ๋ฐํ
6. AI๊ฐ ๋ถ์ ๋ฐ ํต์ฐฐ๋ ฅ์ ์ ๊ณต
์ฌ์ฉ์: Mike, ์ฌ๊ณ ๊ด๋ฆฌ์
๋ชฉํ: ๊ณ ๊ฐ ์์ฒญ๊ณผ ์ ์ฌํ ์ ํ ์ฐพ๊ธฐ
์์ฐ์ด ์ฟผ๋ฆฌ:
> "์ผ์ธ์ฉ ๋ฐฉ์ ์ ๊ธฐ ์ปค๋ฅํฐ์ ์ ์ฌํ ์ ํ์ ์ฐ๋ฆฌ๊ฐ ํ๋งคํ๋์?"
์งํ ๊ณผ์ :
1. ์ฟผ๋ฆฌ๊ฐ ์๋ฏธ ๊ฒ์ ๋๊ตฌ์ ์ํด ์ฒ๋ฆฌ๋จ
2. Azure OpenAI๊ฐ ์๋ฒ ๋ฉ ๋ฒกํฐ๋ฅผ ์์ฑ
3. pgvector๊ฐ ์ ์ฌ์ฑ ๊ฒ์ ์ํ
4. ๊ด๋ จ ์ ํ์ด ๊ด๋ จ์ฑ ์์ผ๋ก ์ ๋ ฌ๋จ
5. ๊ฒฐ๊ณผ์ ์ ํ ์ธ๋ถ ์ ๋ณด์ ๊ฐ์ฉ์ฑ์ด ํฌํจ๋จ
6. AI๊ฐ ๋์ ๋ฐ ๋ฒ๋ค๋ง ๊ธฐํ๋ฅผ ์ ์
์ฌ์ฉ์: Jennifer, ์ง์ญ ๊ด๋ฆฌ์
๋ชฉํ: ๋ชจ๋ ๋งค์ฅ์ ์นดํ ๊ณ ๋ฆฌ๋ณ ํ๋งค ๋น๊ต
์์ฐ์ด ์ฟผ๋ฆฌ:
> "์ง๋ 6๊ฐ์ ๋์ ๋ชจ๋ ๋งค์ฅ์ ์นดํ ๊ณ ๋ฆฌ๋ณ ํ๋งค๋ฅผ ๋น๊ตํด์ค"
์งํ ๊ณผ์ :
1. RLS ์ปจํ ์คํธ๊ฐ ์ง์ญ ๊ด๋ฆฌ์ ์ก์ธ์ค๋ก ์ค์ ๋จ
2. ๋ณต์กํ ๋ค์ค ๋งค์ฅ ์ฟผ๋ฆฌ๊ฐ ์์ฑ๋จ
3. ๋ฐ์ดํฐ๊ฐ ๋งค์ฅ ์์น๋ณ๋ก ์ง๊ณ๋จ
4. ๊ฒฐ๊ณผ์ ํธ๋ ๋์ ๋น๊ต๊ฐ ํฌํจ๋จ
5. AI๊ฐ ํต์ฐฐ๋ ฅ๊ณผ ์ถ์ฒ์ ์๋ณ
์ฐ๋ฆฌ์ ๊ตฌํ์ ์ํฐํ๋ผ์ด์ฆ๊ธ ๋ณด์์ ์ฐ์ ์ํฉ๋๋ค:
PostgreSQL RLS๋ ๋ฐ์ดํฐ ๊ฒฉ๋ฆฌ๋ฅผ ๋ณด์ฅํฉ๋๋ค:
-- Store managers see only their store's data
CREATE POLICY store_manager_policy ON retail.orders
FOR ALL TO store_managers
USING (store_id = get_current_user_store());
-- Regional managers see multiple stores
CREATE POLICY regional_manager_policy ON retail.orders
FOR ALL TO regional_managers
USING (store_id = ANY(get_user_store_list()));
๊ฐ MCP ์ฐ๊ฒฐ์๋ ๋ค์์ด ํฌํจ๋ฉ๋๋ค:
๋ค์ค ๋ณด์ ๊ณ์ธต:
์ด ์๊ฐ๋ฅผ ์๋ฃํ ํ ๋ค์์ ์ดํดํด์ผ ํฉ๋๋ค:
โ MCP ๊ฐ์น ์ ์: MCP๊ฐ AI ์ด์์คํดํธ์ ์ค์ ๋ฐ์ดํฐ๋ฅผ ์ฐ๊ฒฐํ๋ ๋ฐฉ๋ฒ
โ ๋น์ฆ๋์ค ๋ฐฐ๊ฒฝ: Zava Retail์ ์๊ตฌ ์ฌํญ๊ณผ ๊ณผ์
โ ์ํคํ ์ฒ ๊ฐ์: ์ฃผ์ ๊ตฌ์ฑ ์์์ ์ํธ์์ฉ
โ ๊ธฐ์ ์คํ: ์ฌ์ฉ๋ ๋๊ตฌ์ ํ๋ ์์ํฌ
โ ๋ณด์ ๋ชจ๋ธ: ๋ฉํฐ ํ ๋ํธ ๋ฐ์ดํฐ ์ก์ธ์ค ๋ฐ ๋ณดํธ
โ ์ฌ์ฉ ํจํด: ์ค์ ์ฟผ๋ฆฌ ์๋๋ฆฌ์ค์ ์ํฌํ๋ก
๋ ๊น์ด ํ๊ตฌํ ์ค๋น๊ฐ ๋์ จ๋์? ๋ค์์ ์งํํ์ธ์:
Lab 01: ํต์ฌ ์ํคํ ์ฒ ๊ฐ๋
MCP ์๋ฒ ์ํคํ ์ฒ ํจํด, ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ค๊ณ ์์น, ์๋งค ๋ถ์ ์๋ฃจ์ ์ ์ง์ํ๋ ์์ธ ๊ธฐ์ ๊ตฌํ์ ๋ํด ์์๋ณด์ธ์.
---
๋ฉด์ฑ ์กฐํญ: ์ด๋ ๊ฐ์์ ์๋งค ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฉํ๋ ํ์ต ์ฐ์ต์ ๋๋ค. ํ๋ก๋์ ํ๊ฒฝ์์ ์ ์ฌํ ์๋ฃจ์ ์ ๊ตฌํํ ๋๋ ํญ์ ์กฐ์ง์ ๋ฐ์ดํฐ ๊ฑฐ๋ฒ๋์ค ๋ฐ ๋ณด์ ์ ์ฑ ์ ๋ฐ๋ฅด์ญ์์ค.
---
๋ฉด์ฑ ์กฐํญ:
์ด ๋ฌธ์๋ AI ๋ฒ์ญ ์๋น์ค Co-op Translator๋ฅผ ์ฌ์ฉํ์ฌ ๋ฒ์ญ๋์์ต๋๋ค.
์ ํ์ฑ์ ์ํด ์ต์ ์ ๋คํ๊ณ ์์ผ๋, ์๋ ๋ฒ์ญ์๋ ์ค๋ฅ๋ ๋ถ์ ํ์ฑ์ด ํฌํจ๋ ์ ์์ต๋๋ค.
์๋ณธ ๋ฌธ์์ ์์ด ๋ฒ์ ์ด ๊ถ์ ์๋ ์ถ์ฒ๋ก ๊ฐ์ฃผ๋์ด์ผ ํฉ๋๋ค.
์ค์ํ ์ ๋ณด์ ๊ฒฝ์ฐ, ์ ๋ฌธ์ ์ธ ์ธ๊ฐ ๋ฒ์ญ์ ๊ถ์ฅํฉ๋๋ค.
์ด ๋ฒ์ญ ์ฌ์ฉ์ผ๋ก ์ธํด ๋ฐ์ํ๋ ์คํด๋ ์๋ชป๋ ํด์์ ๋ํด ๋น์ฌ๋ ์ฑ ์์ ์ง์ง ์์ต๋๋ค.