00 - Introduction to MCP Database Integration

Module
PostgreSQL
Progress
7%

Introduction to MCP Database Integration

๐ŸŽฏ What This Lab Covers

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.

Overview

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.

Learning Objectives

By the end of this lab, you will be able to:

  • Define Model Context Protocol and its core benefits for database integration
  • Identify key components of an MCP server architecture with databases
  • Understand the Zava Retail use case and its business requirements
  • Recognize enterprise patterns for secure, scalable database access
  • List the tools and technologies used throughout this learning path
  • ๐Ÿงญ The Challenge: AI Meets Real-World Data

    Traditional AI Limitations

    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 |

    The MCP Solution

    Model Context Protocol addresses these challenges by providing:

  • Real-time Data Access: AI assistants query live databases and APIs
  • Secure Integration: Controlled access with authentication and permissions
  • Natural Language Interface: Business users ask questions in plain English
  • Standardized Protocol: Works across different AI platforms and tools
  • ๐Ÿช Meet Zava Retail: Our Learning Case Study https://github.com/microsoft/MCP-Server-and-PostgreSQL-Sample-Retail

    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.

    Business Context

    Zava Retail operates:

  • 8 physical stores across Washington state (Seattle, Bellevue, Tacoma, Spokane, Everett, Redmond, Kirkland)
  • 1 online store for e-commerce sales
  • Diverse product catalog including tools, hardware, garden supplies, and building materials
  • Multi-level management with store managers, regional managers, and executives
  • Business Requirements

    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

    Technical Requirements

    The MCP server must provide:

  • Multi-tenant data access where store managers see only their store's data
  • Flexible querying supporting complex SQL operations
  • Semantic search for product discovery and recommendations
  • Real-time data reflecting current business state
  • Secure authentication with row-level security
  • Scalable architecture supporting multiple concurrent users
  • ๐Ÿ—๏ธ MCP Server Architecture Overview

    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)                            โ”‚
    
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    
    

    Key Components

    1. MCP Server Layer
  • FastMCP Framework: Modern Python MCP server implementation
  • Tool Registration: Declarative tool definitions with type safety
  • Request Context: User identity and session management
  • Error Handling: Robust error management and logging
  • 2. Database Integration Layer
  • Connection Pooling: Efficient asyncpg connection management
  • Schema Provider: Dynamic table schema discovery
  • Query Executor: Secure SQL execution with RLS context
  • Transaction Management: ACID compliance and rollback handling
  • 3. Security Layer
  • Row Level Security: PostgreSQL RLS for multi-tenant data isolation
  • User Identity: Store manager authentication and authorization
  • Access Control: Fine-grained permissions and audit trails
  • Input Validation: SQL injection prevention and query validation
  • 4. AI Enhancement Layer
  • Semantic Search: Vector embeddings for product discovery
  • Azure OpenAI Integration: Text embedding generation
  • Similarity Algorithms: pgvector cosine similarity search
  • Search Optimization: Indexing and performance tuning
  • ๐Ÿ”ง Technology Stack

    Core Technologies

    | 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 |

    Development Tools

    | Tool | Purpose |

    |----------|-------------|

    | asyncpg | High-performance PostgreSQL driver |

    | Pydantic | Data validation and serialization |

    | Azure SDK | Cloud service integration |

    | pytest | Testing framework |

    | Docker | Containerization and deployment |

    Production Stack

    | 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 |

    ๐ŸŽฌ Real-World Usage Scenarios

    Let's explore how different users interact with our MCP server:

    Scenario 1: Store Manager Performance Review

    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

    Scenario 2: Product Discovery with Semantic Search

    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

    Scenario 3: Cross-Store Analytics

    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

    ๐Ÿ”’ Security and Multi-Tenancy Deep Dive

    Our implementation prioritizes enterprise-grade security:

    Row Level Security (RLS)

    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()));
    
    

    User Identity Management

    Each MCP connection includes:

  • Store Manager ID: Unique identifier for RLS context
  • Role Assignment: Permissions and access levels
  • Session Management: Secure authentication tokens
  • Audit Logging: Complete access history
  • Data Protection

    Multiple layers of security:

  • Connection Encryption: TLS for all database connections
  • SQL Injection Prevention: Parameterized queries only
  • Input Validation: Comprehensive request validation
  • Error Handling: No sensitive data in error messages
  • ๐ŸŽฏ Key Takeaways

    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

    ๐Ÿš€ What's Next

    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.

    ๐Ÿ“š Additional Resources

    MCP Documentation

  • MCP Specification - Official protocol documentation
  • MCP for Beginners - Comprehensive MCP learning guide
  • FastMCP Documentation - Python SDK documentation
  • Database Integration

  • PostgreSQL Documentation - Complete PostgreSQL reference
  • pgvector Guide - Vector extension documentation
  • Row Level Security - PostgreSQL RLS guide
  • Azure Services

  • Azure OpenAI Documentation - AI service integration
  • Azure Database for PostgreSQL - Managed database service
  • Azure Container Apps - Serverless containers
  • ---

    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.

    MCP ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํ†ตํ•ฉ ์†Œ๊ฐœ

    ๐ŸŽฏ ์ด ์‹ค์Šต์—์„œ ๋‹ค๋ฃจ๋Š” ๋‚ด์šฉ

    ์ด ์ž…๋ฌธ ์‹ค์Šต์€ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํ†ตํ•ฉ์„ ํ†ตํ•ด 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 ์„œ๋ฒ„๋ฅผ ๊ตฌ์ถ•ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๊ฐ€๋ฅด์นฉ๋‹ˆ๋‹ค.

    ํ•™์Šต ๋ชฉํ‘œ

    ์ด ์‹ค์Šต์„ ์™„๋ฃŒํ•˜๋ฉด ๋‹ค์Œ์„ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

  • ์ •์˜: Model Context Protocol๊ณผ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํ†ตํ•ฉ์˜ ํ•ต์‹ฌ ์ด์ 
  • ์‹๋ณ„: ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ํฌํ•จํ•œ MCP ์„œ๋ฒ„ ์•„ํ‚คํ…์ฒ˜์˜ ์ฃผ์š” ๊ตฌ์„ฑ ์š”์†Œ
  • ์ดํ•ด: Zava Retail ์‚ฌ๋ก€์™€ ๋น„์ฆˆ๋‹ˆ์Šค ์š”๊ตฌ ์‚ฌํ•ญ
  • ์ธ์‹: ์•ˆ์ „ํ•˜๊ณ  ํ™•์žฅ ๊ฐ€๋Šฅํ•œ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์•ก์„ธ์Šค๋ฅผ ์œ„ํ•œ ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ ํŒจํ„ด
  • ๋ชฉ๋ก ์ž‘์„ฑ: ์ด ํ•™์Šต ๊ฒฝ๋กœ์—์„œ ์‚ฌ์šฉ๋œ ๋„๊ตฌ์™€ ๊ธฐ์ˆ 
  • ๐Ÿงญ ๋„์ „ ๊ณผ์ œ: AI์™€ ์‹ค์ œ ๋ฐ์ดํ„ฐ์˜ ๋งŒ๋‚จ

    ๊ธฐ์กด AI์˜ ํ•œ๊ณ„

    ํ˜„๋Œ€์˜ AI ์–ด์‹œ์Šคํ„ดํŠธ๋Š” ๋งค์šฐ ๊ฐ•๋ ฅํ•˜์ง€๋งŒ ์‹ค์ œ ๋น„์ฆˆ๋‹ˆ์Šค ๋ฐ์ดํ„ฐ์™€ ์ž‘์—…ํ•  ๋•Œ ์ค‘์š”ํ•œ ํ•œ๊ณ„๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค:

    | ๋„์ „ ๊ณผ์ œ | ์„ค๋ช… | ๋น„์ฆˆ๋‹ˆ์Šค ์˜ํ–ฅ |

    |---------------|-----------------|-------------------|

    | ์ •์  ์ง€์‹ | ๊ณ ์ •๋œ ๋ฐ์ดํ„ฐ์…‹์œผ๋กœ ํ›ˆ๋ จ๋œ AI ๋ชจ๋ธ์€ ํ˜„์žฌ ๋น„์ฆˆ๋‹ˆ์Šค ๋ฐ์ดํ„ฐ๋ฅผ ์•ก์„ธ์Šคํ•  ์ˆ˜ ์—†์Œ | ์˜ค๋ž˜๋œ ํ†ต์ฐฐ๋ ฅ, ๊ธฐํšŒ ์ƒ์‹ค |

    | ๋ฐ์ดํ„ฐ ์‚ฌ์ผ๋กœ | ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค, API, ์‹œ์Šคํ…œ์— ์ž ๊ธด ์ •๋ณด๋กœ ์ธํ•ด AI๊ฐ€ ์ ‘๊ทผ ๋ถˆ๊ฐ€ | ๋ถˆ์™„์ „ํ•œ ๋ถ„์„, ๋‹จํŽธํ™”๋œ ์›Œํฌํ”Œ๋กœ |

    | ๋ณด์•ˆ ์ œ์•ฝ | ์ง์ ‘์ ์ธ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์•ก์„ธ์Šค๋Š” ๋ณด์•ˆ ๋ฐ ๊ทœ์ • ์ค€์ˆ˜ ๋ฌธ์ œ๋ฅผ ์•ผ๊ธฐ | ์ œํ•œ๋œ ๋ฐฐํฌ, ์ˆ˜๋™ ๋ฐ์ดํ„ฐ ์ค€๋น„ |

    | ๋ณต์žกํ•œ ์ฟผ๋ฆฌ | ๋น„์ฆˆ๋‹ˆ์Šค ์‚ฌ์šฉ์ž๊ฐ€ ๋ฐ์ดํ„ฐ ํ†ต์ฐฐ๋ ฅ์„ ์ถ”์ถœํ•˜๋ ค๋ฉด ๊ธฐ์ˆ ์  ์ง€์‹์ด ํ•„์š” | ๋‚ฎ์€ ์ฑ„ํƒ๋ฅ , ๋น„ํšจ์œจ์ ์ธ ํ”„๋กœ์„ธ์Šค |

    MCP ์†”๋ฃจ์…˜

    Model Context Protocol์€ ๋‹ค์Œ์„ ํ†ตํ•ด ์ด๋Ÿฌํ•œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•ฉ๋‹ˆ๋‹ค:

  • ์‹ค์‹œ๊ฐ„ ๋ฐ์ดํ„ฐ ์•ก์„ธ์Šค: AI ์–ด์‹œ์Šคํ„ดํŠธ๊ฐ€ ๋ผ์ด๋ธŒ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์™€ API๋ฅผ ์ฟผ๋ฆฌ
  • ์•ˆ์ „ํ•œ ํ†ตํ•ฉ: ์ธ์ฆ ๋ฐ ๊ถŒํ•œ์„ ํ†ตํ•œ ์ œ์–ด๋œ ์•ก์„ธ์Šค
  • ์ž์—ฐ์–ด ์ธํ„ฐํŽ˜์ด์Šค: ๋น„์ฆˆ๋‹ˆ์Šค ์‚ฌ์šฉ์ž๊ฐ€ ํ‰๋ฒ”ํ•œ ์˜์–ด๋กœ ์งˆ๋ฌธ
  • ํ‘œ์ค€ํ™”๋œ ํ”„๋กœํ† ์ฝœ: ๋‹ค์–‘ํ•œ AI ํ”Œ๋žซํผ ๋ฐ ๋„๊ตฌ์—์„œ ์ž‘๋™
  • ๐Ÿช Zava Retail ์†Œ๊ฐœ: ํ•™์Šต ์‚ฌ๋ก€ ์—ฐ๊ตฌ https://github.com/microsoft/MCP-Server-and-PostgreSQL-Sample-Retail

    ์ด ํ•™์Šต ๊ฒฝ๋กœ์—์„œ๋Š” Zava Retail์ด๋ผ๋Š” ๊ฐ€์ƒ์˜ DIY ์†Œ๋งค ์ฒด์ธ์„ ์œ„ํ•œ MCP ์„œ๋ฒ„๋ฅผ ๊ตฌ์ถ•ํ•ฉ๋‹ˆ๋‹ค. ์ด ํ˜„์‹ค์ ์ธ ์‹œ๋‚˜๋ฆฌ์˜ค๋Š” ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ๊ธ‰ MCP ๊ตฌํ˜„์„ ๋ณด์—ฌ์ค๋‹ˆ๋‹ค.

    ๋น„์ฆˆ๋‹ˆ์Šค ๋ฐฐ๊ฒฝ

    Zava Retail์€ ๋‹ค์Œ์„ ์šด์˜ํ•ฉ๋‹ˆ๋‹ค:

  • ์›Œ์‹ฑํ„ด ์ฃผ ์ „์—ญ์— ๊ฑธ์นœ 8๊ฐœ์˜ ์˜คํ”„๋ผ์ธ ๋งค์žฅ (์‹œ์• ํ‹€, ๋ฒจ๋ทฐ, ํƒ€์ฝ”๋งˆ, ์Šคํฌ์บ”, ์—๋ฒ„๋ ›, ๋ ˆ๋“œ๋จผ๋“œ, ์ปคํด๋žœ๋“œ)
  • 1๊ฐœ์˜ ์˜จ๋ผ์ธ ๋งค์žฅ์„ ํ†ตํ•œ ์ „์ž์ƒ๊ฑฐ๋ž˜ ํŒ๋งค
  • ๋„๊ตฌ, ํ•˜๋“œ์›จ์–ด, ์ •์› ์šฉํ’ˆ, ๊ฑด์ถ• ์ž์žฌ๋ฅผ ํฌํ•จํ•œ ๋‹ค์–‘ํ•œ ์ œํ’ˆ ์นดํƒˆ๋กœ๊ทธ
  • ๋งค์žฅ ๊ด€๋ฆฌ์ž, ์ง€์—ญ ๊ด€๋ฆฌ์ž, ์ž„์›์„ ํฌํ•จํ•œ ๋‹ค๋‹จ๊ณ„ ๊ด€๋ฆฌ
  • ๋น„์ฆˆ๋‹ˆ์Šค ์š”๊ตฌ ์‚ฌํ•ญ

    ๋งค์žฅ ๊ด€๋ฆฌ์ž์™€ ์ž„์›์€ AI ๊ธฐ๋ฐ˜ ๋ถ„์„์„ ํ†ตํ•ด ๋‹ค์Œ์„ ์ˆ˜ํ–‰ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค:

    1. ๋งค์žฅ ๋ฐ ๊ธฐ๊ฐ„๋ณ„ ํŒ๋งค ์„ฑ๊ณผ ๋ถ„์„

    2. ์žฌ๊ณ  ์ˆ˜์ค€ ์ถ”์  ๋ฐ ์žฌ์ž…๊ณ  ํ•„์š”์„ฑ ์‹๋ณ„

    3. ๊ณ ๊ฐ ํ–‰๋™ ๋ฐ ๊ตฌ๋งค ํŒจํ„ด ์ดํ•ด

    4. ์˜๋ฏธ ๊ฒ€์ƒ‰์„ ํ†ตํ•œ ์ œํ’ˆ ํ†ต์ฐฐ๋ ฅ ๋ฐœ๊ฒฌ

    5. ์ž์—ฐ์–ด ์ฟผ๋ฆฌ๋ฅผ ์‚ฌ์šฉํ•œ ๋ณด๊ณ ์„œ ์ƒ์„ฑ

    6. ์—ญํ•  ๊ธฐ๋ฐ˜ ์•ก์„ธ์Šค ์ œ์–ด๋ฅผ ํ†ตํ•œ ๋ฐ์ดํ„ฐ ๋ณด์•ˆ ์œ ์ง€

    ๊ธฐ์ˆ  ์š”๊ตฌ ์‚ฌํ•ญ

    MCP ์„œ๋ฒ„๋Š” ๋‹ค์Œ์„ ์ œ๊ณตํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค:

  • ๋ฉ€ํ‹ฐ ํ…Œ๋„ŒํŠธ ๋ฐ์ดํ„ฐ ์•ก์„ธ์Šค: ๋งค์žฅ ๊ด€๋ฆฌ์ž๊ฐ€ ์ž์‹ ์˜ ๋งค์žฅ ๋ฐ์ดํ„ฐ๋งŒ ๋ณผ ์ˆ˜ ์žˆ๋„๋ก
  • ์œ ์—ฐํ•œ ์ฟผ๋ฆฌ: ๋ณต์žกํ•œ SQL ์ž‘์—… ์ง€์›
  • ์˜๋ฏธ ๊ฒ€์ƒ‰: ์ œํ’ˆ ๊ฒ€์ƒ‰ ๋ฐ ์ถ”์ฒœ
  • ์‹ค์‹œ๊ฐ„ ๋ฐ์ดํ„ฐ: ํ˜„์žฌ ๋น„์ฆˆ๋‹ˆ์Šค ์ƒํƒœ ๋ฐ˜์˜
  • ์•ˆ์ „ํ•œ ์ธ์ฆ: Row Level Security ํฌํ•จ
  • ํ™•์žฅ ๊ฐ€๋Šฅํ•œ ์•„ํ‚คํ…์ฒ˜: ์—ฌ๋Ÿฌ ๋™์‹œ ์‚ฌ์šฉ์ž๋ฅผ ์ง€์›
  • ๐Ÿ—๏ธ 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)                            โ”‚
    
    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
    
    

    ์ฃผ์š” ๊ตฌ์„ฑ ์š”์†Œ

    1. MCP ์„œ๋ฒ„ ๊ณ„์ธต
  • FastMCP Framework: ํ˜„๋Œ€์ ์ธ Python MCP ์„œ๋ฒ„ ๊ตฌํ˜„
  • ๋„๊ตฌ ๋“ฑ๋ก: ํƒ€์ž… ์•ˆ์ „์„ฑ์„ ๊ฐ–์ถ˜ ์„ ์–ธ์  ๋„๊ตฌ ์ •์˜
  • ์š”์ฒญ ์ปจํ…์ŠคํŠธ: ์‚ฌ์šฉ์ž ์‹ ์› ๋ฐ ์„ธ์…˜ ๊ด€๋ฆฌ
  • ์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ: ๊ฐ•๋ ฅํ•œ ์˜ค๋ฅ˜ ๊ด€๋ฆฌ ๋ฐ ๋กœ๊น…
  • 2. ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํ†ตํ•ฉ ๊ณ„์ธต
  • ์—ฐ๊ฒฐ ํ’€๋ง: ํšจ์œจ์ ์ธ asyncpg ์—ฐ๊ฒฐ ๊ด€๋ฆฌ
  • ์Šคํ‚ค๋งˆ ์ œ๊ณต์ž: ๋™์  ํ…Œ์ด๋ธ” ์Šคํ‚ค๋งˆ ๊ฒ€์ƒ‰
  • ์ฟผ๋ฆฌ ์‹คํ–‰๊ธฐ: RLS ์ปจํ…์ŠคํŠธ๋ฅผ ์‚ฌ์šฉํ•œ ์•ˆ์ „ํ•œ SQL ์‹คํ–‰
  • ํŠธ๋žœ์žญ์…˜ ๊ด€๋ฆฌ: ACID ์ค€์ˆ˜ ๋ฐ ๋กค๋ฐฑ ์ฒ˜๋ฆฌ
  • 3. ๋ณด์•ˆ ๊ณ„์ธต
  • Row Level Security: ๋ฉ€ํ‹ฐ ํ…Œ๋„ŒํŠธ ๋ฐ์ดํ„ฐ ๊ฒฉ๋ฆฌ๋ฅผ ์œ„ํ•œ PostgreSQL RLS
  • ์‚ฌ์šฉ์ž ์‹ ์›: ๋งค์žฅ ๊ด€๋ฆฌ์ž ์ธ์ฆ ๋ฐ ๊ถŒํ•œ ๋ถ€์—ฌ
  • ์•ก์„ธ์Šค ์ œ์–ด: ์„ธ๋ถ„ํ™”๋œ ๊ถŒํ•œ ๋ฐ ๊ฐ์‚ฌ ๊ธฐ๋ก
  • ์ž…๋ ฅ ๊ฒ€์ฆ: SQL ์ธ์ ์…˜ ๋ฐฉ์ง€ ๋ฐ ์ฟผ๋ฆฌ ๊ฒ€์ฆ
  • 4. AI ๊ฐ•ํ™” ๊ณ„์ธต
  • ์˜๋ฏธ ๊ฒ€์ƒ‰: ์ œํ’ˆ ๊ฒ€์ƒ‰์„ ์œ„ํ•œ ๋ฒกํ„ฐ ์ž„๋ฒ ๋”ฉ
  • Azure OpenAI ํ†ตํ•ฉ: ํ…์ŠคํŠธ ์ž„๋ฒ ๋”ฉ ์ƒ์„ฑ
  • ์œ ์‚ฌ์„ฑ ์•Œ๊ณ ๋ฆฌ์ฆ˜: pgvector ์ฝ”์‚ฌ์ธ ์œ ์‚ฌ์„ฑ ๊ฒ€์ƒ‰
  • ๊ฒ€์ƒ‰ ์ตœ์ ํ™”: ์ธ๋ฑ์‹ฑ ๋ฐ ์„ฑ๋Šฅ ํŠœ๋‹
  • ๐Ÿ”ง ๊ธฐ์ˆ  ์Šคํƒ

    ํ•ต์‹ฌ ๊ธฐ์ˆ 

    | ๊ตฌ์„ฑ ์š”์†Œ | ๊ธฐ์ˆ  | ๋ชฉ์  |

    |---------------|----------------|-------------|

    | 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 ์„œ๋ฒ„์™€ ์ƒํ˜ธ์ž‘์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค:

    ์‹œ๋‚˜๋ฆฌ์˜ค 1: ๋งค์žฅ ๊ด€๋ฆฌ์ž ์„ฑ๊ณผ ๊ฒ€ํ† 

    ์‚ฌ์šฉ์ž: Sarah, ์‹œ์• ํ‹€ ๋งค์žฅ ๊ด€๋ฆฌ์ž

    ๋ชฉํ‘œ: ์ง€๋‚œ ๋ถ„๊ธฐ์˜ ํŒ๋งค ์„ฑ๊ณผ ๋ถ„์„

    ์ž์—ฐ์–ด ์ฟผ๋ฆฌ:

    > "2024๋…„ 4๋ถ„๊ธฐ ๋™์•ˆ ๋‚ด ๋งค์žฅ์—์„œ ๋งค์ถœ ๊ธฐ์ค€ ์ƒ์œ„ 10๊ฐœ ์ œํ’ˆ์„ ๋ณด์—ฌ์ค˜"

    ์ง„ํ–‰ ๊ณผ์ •:

    1. VS Code AI ์ฑ„ํŒ…์ด ์ฟผ๋ฆฌ๋ฅผ MCP ์„œ๋ฒ„๋กœ ์ „์†ก

    2. MCP ์„œ๋ฒ„๊ฐ€ Sarah์˜ ๋งค์žฅ ์ปจํ…์ŠคํŠธ(์‹œ์• ํ‹€)๋ฅผ ์‹๋ณ„

    3. RLS ์ •์ฑ…์ด ๋ฐ์ดํ„ฐ๋ฅผ ์‹œ์• ํ‹€ ๋งค์žฅ์œผ๋กœ ํ•„ํ„ฐ๋ง

    4. SQL ์ฟผ๋ฆฌ๊ฐ€ ์ƒ์„ฑ๋˜๊ณ  ์‹คํ–‰๋จ

    5. ๊ฒฐ๊ณผ๊ฐ€ ํฌ๋งท๋˜์–ด AI ์ฑ„ํŒ…์œผ๋กœ ๋ฐ˜ํ™˜

    6. AI๊ฐ€ ๋ถ„์„ ๋ฐ ํ†ต์ฐฐ๋ ฅ์„ ์ œ๊ณต

    ์‹œ๋‚˜๋ฆฌ์˜ค 2: ์˜๋ฏธ ๊ฒ€์ƒ‰์„ ํ†ตํ•œ ์ œํ’ˆ ๋ฐœ๊ฒฌ

    ์‚ฌ์šฉ์ž: Mike, ์žฌ๊ณ  ๊ด€๋ฆฌ์ž

    ๋ชฉํ‘œ: ๊ณ ๊ฐ ์š”์ฒญ๊ณผ ์œ ์‚ฌํ•œ ์ œํ’ˆ ์ฐพ๊ธฐ

    ์ž์—ฐ์–ด ์ฟผ๋ฆฌ:

    > "์•ผ์™ธ์šฉ ๋ฐฉ์ˆ˜ ์ „๊ธฐ ์ปค๋„ฅํ„ฐ์™€ ์œ ์‚ฌํ•œ ์ œํ’ˆ์„ ์šฐ๋ฆฌ๊ฐ€ ํŒ๋งคํ•˜๋‚˜์š”?"

    ์ง„ํ–‰ ๊ณผ์ •:

    1. ์ฟผ๋ฆฌ๊ฐ€ ์˜๋ฏธ ๊ฒ€์ƒ‰ ๋„๊ตฌ์— ์˜ํ•ด ์ฒ˜๋ฆฌ๋จ

    2. Azure OpenAI๊ฐ€ ์ž„๋ฒ ๋”ฉ ๋ฒกํ„ฐ๋ฅผ ์ƒ์„ฑ

    3. pgvector๊ฐ€ ์œ ์‚ฌ์„ฑ ๊ฒ€์ƒ‰ ์ˆ˜ํ–‰

    4. ๊ด€๋ จ ์ œํ’ˆ์ด ๊ด€๋ จ์„ฑ ์ˆœ์œผ๋กœ ์ •๋ ฌ๋จ

    5. ๊ฒฐ๊ณผ์— ์ œํ’ˆ ์„ธ๋ถ€ ์ •๋ณด์™€ ๊ฐ€์šฉ์„ฑ์ด ํฌํ•จ๋จ

    6. AI๊ฐ€ ๋Œ€์•ˆ ๋ฐ ๋ฒˆ๋“ค๋ง ๊ธฐํšŒ๋ฅผ ์ œ์•ˆ

    ์‹œ๋‚˜๋ฆฌ์˜ค 3: ๋งค์žฅ ๊ฐ„ ๋ถ„์„

    ์‚ฌ์šฉ์ž: Jennifer, ์ง€์—ญ ๊ด€๋ฆฌ์ž

    ๋ชฉํ‘œ: ๋ชจ๋“  ๋งค์žฅ์˜ ์นดํ…Œ๊ณ ๋ฆฌ๋ณ„ ํŒ๋งค ๋น„๊ต

    ์ž์—ฐ์–ด ์ฟผ๋ฆฌ:

    > "์ง€๋‚œ 6๊ฐœ์›” ๋™์•ˆ ๋ชจ๋“  ๋งค์žฅ์˜ ์นดํ…Œ๊ณ ๋ฆฌ๋ณ„ ํŒ๋งค๋ฅผ ๋น„๊ตํ•ด์ค˜"

    ์ง„ํ–‰ ๊ณผ์ •:

    1. RLS ์ปจํ…์ŠคํŠธ๊ฐ€ ์ง€์—ญ ๊ด€๋ฆฌ์ž ์•ก์„ธ์Šค๋กœ ์„ค์ •๋จ

    2. ๋ณต์žกํ•œ ๋‹ค์ค‘ ๋งค์žฅ ์ฟผ๋ฆฌ๊ฐ€ ์ƒ์„ฑ๋จ

    3. ๋ฐ์ดํ„ฐ๊ฐ€ ๋งค์žฅ ์œ„์น˜๋ณ„๋กœ ์ง‘๊ณ„๋จ

    4. ๊ฒฐ๊ณผ์— ํŠธ๋ Œ๋“œ์™€ ๋น„๊ต๊ฐ€ ํฌํ•จ๋จ

    5. AI๊ฐ€ ํ†ต์ฐฐ๋ ฅ๊ณผ ์ถ”์ฒœ์„ ์‹๋ณ„

    ๐Ÿ”’ ๋ณด์•ˆ ๋ฐ ๋ฉ€ํ‹ฐ ํ…Œ๋„Œ์‹œ ์‹ฌ์ธต ๋ถ„์„

    ์šฐ๋ฆฌ์˜ ๊ตฌํ˜„์€ ์—”ํ„ฐํ”„๋ผ์ด์ฆˆ๊ธ‰ ๋ณด์•ˆ์„ ์šฐ์„ ์‹œํ•ฉ๋‹ˆ๋‹ค:

    Row Level Security (RLS)

    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 ์—ฐ๊ฒฐ์—๋Š” ๋‹ค์Œ์ด ํฌํ•จ๋ฉ๋‹ˆ๋‹ค:

  • ๋งค์žฅ ๊ด€๋ฆฌ์ž ID: RLS ์ปจํ…์ŠคํŠธ๋ฅผ ์œ„ํ•œ ๊ณ ์œ  ์‹๋ณ„์ž
  • ์—ญํ•  ํ• ๋‹น: ๊ถŒํ•œ ๋ฐ ์•ก์„ธ์Šค ์ˆ˜์ค€
  • ์„ธ์…˜ ๊ด€๋ฆฌ: ์•ˆ์ „ํ•œ ์ธ์ฆ ํ† ํฐ
  • ๊ฐ์‚ฌ ๋กœ๊น…: ์™„์ „ํ•œ ์•ก์„ธ์Šค ๊ธฐ๋ก
  • ๋ฐ์ดํ„ฐ ๋ณดํ˜ธ

    ๋‹ค์ค‘ ๋ณด์•ˆ ๊ณ„์ธต:

  • ์—ฐ๊ฒฐ ์•”ํ˜ธํ™”: ๋ชจ๋“  ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์—ฐ๊ฒฐ์— TLS ์‚ฌ์šฉ
  • SQL ์ธ์ ์…˜ ๋ฐฉ์ง€: ๋งค๊ฐœ๋ณ€์ˆ˜ํ™”๋œ ์ฟผ๋ฆฌ๋งŒ ํ—ˆ์šฉ
  • ์ž…๋ ฅ ๊ฒ€์ฆ: ํฌ๊ด„์ ์ธ ์š”์ฒญ ๊ฒ€์ฆ
  • ์˜ค๋ฅ˜ ์ฒ˜๋ฆฌ: ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€์— ๋ฏผ๊ฐํ•œ ๋ฐ์ดํ„ฐ ํฌํ•จ ๊ธˆ์ง€
  • ๐ŸŽฏ ์ฃผ์š” ์š”์ 

    ์ด ์†Œ๊ฐœ๋ฅผ ์™„๋ฃŒํ•œ ํ›„ ๋‹ค์Œ์„ ์ดํ•ดํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค:

    โœ… MCP ๊ฐ€์น˜ ์ œ์•ˆ: MCP๊ฐ€ AI ์–ด์‹œ์Šคํ„ดํŠธ์™€ ์‹ค์ œ ๋ฐ์ดํ„ฐ๋ฅผ ์—ฐ๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•

    โœ… ๋น„์ฆˆ๋‹ˆ์Šค ๋ฐฐ๊ฒฝ: Zava Retail์˜ ์š”๊ตฌ ์‚ฌํ•ญ๊ณผ ๊ณผ์ œ

    โœ… ์•„ํ‚คํ…์ฒ˜ ๊ฐœ์š”: ์ฃผ์š” ๊ตฌ์„ฑ ์š”์†Œ์™€ ์ƒํ˜ธ์ž‘์šฉ

    โœ… ๊ธฐ์ˆ  ์Šคํƒ: ์‚ฌ์šฉ๋œ ๋„๊ตฌ์™€ ํ”„๋ ˆ์ž„์›Œํฌ

    โœ… ๋ณด์•ˆ ๋ชจ๋ธ: ๋ฉ€ํ‹ฐ ํ…Œ๋„ŒํŠธ ๋ฐ์ดํ„ฐ ์•ก์„ธ์Šค ๋ฐ ๋ณดํ˜ธ

    โœ… ์‚ฌ์šฉ ํŒจํ„ด: ์‹ค์ œ ์ฟผ๋ฆฌ ์‹œ๋‚˜๋ฆฌ์˜ค์™€ ์›Œํฌํ”Œ๋กœ

    ๐Ÿš€ ๋‹ค์Œ ๋‹จ๊ณ„

    ๋” ๊นŠ์ด ํƒ๊ตฌํ•  ์ค€๋น„๊ฐ€ ๋˜์…จ๋‚˜์š”? ๋‹ค์Œ์„ ์ง„ํ–‰ํ•˜์„ธ์š”:

    Lab 01: ํ•ต์‹ฌ ์•„ํ‚คํ…์ฒ˜ ๊ฐœ๋…

    MCP ์„œ๋ฒ„ ์•„ํ‚คํ…์ฒ˜ ํŒจํ„ด, ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์„ค๊ณ„ ์›์น™, ์†Œ๋งค ๋ถ„์„ ์†”๋ฃจ์…˜์„ ์ง€์›ํ•˜๋Š” ์ƒ์„ธ ๊ธฐ์ˆ  ๊ตฌํ˜„์— ๋Œ€ํ•ด ์•Œ์•„๋ณด์„ธ์š”.

    ๐Ÿ“š ์ถ”๊ฐ€ ์ž๋ฃŒ

    MCP ๋ฌธ์„œ

  • MCP ์‚ฌ์–‘ - ๊ณต์‹ ํ”„๋กœํ† ์ฝœ ๋ฌธ์„œ
  • MCP ์ดˆ๋ณด์ž์šฉ - ํฌ๊ด„์ ์ธ MCP ํ•™์Šต ๊ฐ€์ด๋“œ
  • FastMCP ๋ฌธ์„œ - Python SDK ๋ฌธ์„œ
  • ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ํ†ตํ•ฉ

  • PostgreSQL ๋ฌธ์„œ - PostgreSQL ์ฐธ์กฐ ์ž๋ฃŒ
  • pgvector ๊ฐ€์ด๋“œ - ๋ฒกํ„ฐ ํ™•์žฅ ๋ฌธ์„œ
  • Row Level Security - PostgreSQL RLS ๊ฐ€์ด๋“œ
  • Azure ์„œ๋น„์Šค

  • Azure OpenAI ๋ฌธ์„œ - AI ์„œ๋น„์Šค ํ†ตํ•ฉ
  • Azure Database for PostgreSQL - ๊ด€๋ฆฌํ˜• ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์„œ๋น„์Šค
  • Azure Container Apps - ์„œ๋ฒ„๋ฆฌ์Šค ์ปจํ…Œ์ด๋„ˆ
  • ---

    ๋ฉด์ฑ… ์กฐํ•ญ: ์ด๋Š” ๊ฐ€์ƒ์˜ ์†Œ๋งค ๋ฐ์ดํ„ฐ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ํ•™์Šต ์—ฐ์Šต์ž…๋‹ˆ๋‹ค. ํ”„๋กœ๋•์…˜ ํ™˜๊ฒฝ์—์„œ ์œ ์‚ฌํ•œ ์†”๋ฃจ์…˜์„ ๊ตฌํ˜„ํ•  ๋•Œ๋Š” ํ•ญ์ƒ ์กฐ์ง์˜ ๋ฐ์ดํ„ฐ ๊ฑฐ๋ฒ„๋„Œ์Šค ๋ฐ ๋ณด์•ˆ ์ •์ฑ…์„ ๋”ฐ๋ฅด์‹ญ์‹œ์˜ค.

    ---

    ๋ฉด์ฑ… ์กฐํ•ญ:

    ์ด ๋ฌธ์„œ๋Š” AI ๋ฒˆ์—ญ ์„œ๋น„์Šค Co-op Translator๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฒˆ์—ญ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

    ์ •ํ™•์„ฑ์„ ์œ„ํ•ด ์ตœ์„ ์„ ๋‹คํ•˜๊ณ  ์žˆ์œผ๋‚˜, ์ž๋™ ๋ฒˆ์—ญ์—๋Š” ์˜ค๋ฅ˜๋‚˜ ๋ถ€์ •ํ™•์„ฑ์ด ํฌํ•จ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    ์›๋ณธ ๋ฌธ์„œ์˜ ์›์–ด ๋ฒ„์ „์ด ๊ถŒ์œ„ ์žˆ๋Š” ์ถœ์ฒ˜๋กœ ๊ฐ„์ฃผ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

    ์ค‘์š”ํ•œ ์ •๋ณด์˜ ๊ฒฝ์šฐ, ์ „๋ฌธ์ ์ธ ์ธ๊ฐ„ ๋ฒˆ์—ญ์„ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.

    ์ด ๋ฒˆ์—ญ ์‚ฌ์šฉ์œผ๋กœ ์ธํ•ด ๋ฐœ์ƒํ•˜๋Š” ์˜คํ•ด๋‚˜ ์ž˜๋ชป๋œ ํ•ด์„์— ๋Œ€ํ•ด ๋‹น์‚ฌ๋Š” ์ฑ…์ž„์„ ์ง€์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

    MCP Academy — microsoft/mcp-for-beginners