### Install Git on Windows Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/en/walkthrough/03-Setup/README.md Installs Git on Windows using Windows Package Manager or by downloading the installer from the official Git website. ```cmd # Using Windows Package Manager winget install Git.Git # Or download from: https://git-scm.com/download/win ``` -------------------------------- ### Install Docker Desktop (Windows) Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/walkthrough/03-Setup/README.md Installs Docker Desktop on Windows using Windows Package Manager or direct download. Requires Administrator privileges and WSL 2 integration. Verifies installation by checking the 'docker' and 'docker-compose' versions. ```cmd # Visit https://desktop.docker.com/win/stable/Docker%20Desktop%20Installer.exe # Or use Windows Package Manager winget install Docker.DockerDesktop ``` -------------------------------- ### Install Docker Desktop on Windows Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/en/walkthrough/03-Setup/README.md Installs Docker Desktop on Windows using Windows Package Manager or by downloading the installer. It includes steps for enabling WSL 2 integration and verifying the installation. ```cmd # Visit https://desktop.docker.com/win/stable/Docker%20Desktop%20Installer.exe # Or use Windows Package Manager winget install Docker.DockerDesktop ``` ```cmd docker --version docker-compose --version ``` -------------------------------- ### Community Contribution Guide Generation in Python Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/bn/walkthrough/12-Best-Practices/README.md Provides tools to manage community engagement, including generating a personalized contribution guide and validating contributions against predefined standards. The guide outlines areas for contribution, setup instructions, and community resources. ```python from typing import Dict class CommunityContributor: """Tools for community engagement and contribution.""" @staticmethod def generate_contribution_guide() -> Dict: """Generate personalized contribution guide.""" return { "getting_started": { "setup": "Follow setup guide in Module 03", "first_contribution": "Start with documentation improvements", "testing": "Run full test suite before submitting PR" }, "contribution_areas": { "documentation": "Improve learning modules and examples", "testing": "Add test cases and improve coverage", "features": "Implement new MCP tools and capabilities", "performance": "Optimize queries and caching", "security": "Enhance security measures and validation" }, "community_resources": { "discord": "https://discord.com/invite/ByRwuEEgH4", "discussions": "GitHub Discussions for Q&A", "issues": "GitHub Issues for bug reports", "examples": "Share your implementation examples" } } @staticmethod def validate_contribution(pr_data: Dict) -> Dict[str, bool]: """Validate contribution meets standards.""" return { "has_tests": "test" in pr_data.get("files_changed", []), "has_documentation": "README" in str(pr_data.get("files_changed", [])), "follows_conventions": True, # Would implement actual checks "security_reviewed": pr_data.get("security_review", False), "performance_tested": pr_data.get("benchmark_results", False) } # Example usage: # contributor = CommunityContributor() # guide = contributor.generate_contribution_guide() # print(guide) # pr_info = { # "files_changed": ["main.py", "test_main.py", "README.md"], # "security_review": True, # "benchmark_results": False # } # validation_result = contributor.validate_contribution(pr_info) # print(validation_result) ``` -------------------------------- ### Manage Python Package Installation and Environment Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/walkthrough/03-Setup/README.md This bash snippet provides commands for managing Python package installations and virtual environments. It includes steps to upgrade pip, clear the cache, and install packages individually to identify resolution issues. It also shows how to activate a virtual environment and configure VS Code to use the correct interpreter. ```bash # Upgrade pip and setuptools python -m pip install --upgrade pip setuptools wheel # Clear pip cache pip cache purge # Install packages one by one to identify issues pip install fastmcp pip install asyncpg pip install azure-ai-projects # Show Python interpreter paths which python # macOS/Linux where python # Windows # Activate virtual environment first source mcp-env/bin/activate # macOS/Linux mcp-env\Scripts\activate # Windows # Then open VS Code code . ``` -------------------------------- ### Python Dependencies and Test Setup Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/zh/walkthrough/10-Deployment/README.md This snippet details the Python environment setup, including installing project dependencies from 'requirements.lock.txt' and installing testing tools like pytest. It also covers configuring and setting up a test PostgreSQL database, and generating sample data for testing purposes. This ensures a consistent and isolated testing environment. ```bash python -m pip install --upgrade pip pip install -r requirements.lock.txt pip install pytest pytest-cov pytest-asyncio PGPASSWORD=postgres psql -h localhost -U postgres -d retail_test -f scripts/create_schema.sql python scripts/generate_sample_data.py --test ``` -------------------------------- ### Install Docker Engine and Compose (Linux) Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/walkthrough/03-Setup/README.md Installs Docker Engine on Ubuntu/Debian using a script and Docker Compose from GitHub. Requires superuser privileges for installation and group modifications. Users need to log out and back in for group changes to take effect. ```bash # Ubuntu/Debian curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh sudo usermod -aG docker $USER # Log out and back in for group changes to take effect # Install Docker Compose sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose ``` -------------------------------- ### Set up Python and Install Dependencies Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/no/walkthrough/10-Deployment/README.md This step sets up the Python environment, caches pip dependencies, and installs necessary packages including pytest for testing. ```bash steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.11' cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.lock.txt pip install pytest pytest-cov pytest-asyncio ``` -------------------------------- ### Install Python Packages Individually Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/en/walkthrough/03-Setup/README.md Installs Python packages one by one to help pinpoint which specific package might be causing installation failures. ```bash # Install packages one by one to identify issues pip install fastmcp pip install asyncpg pip install azure-ai-projects ``` -------------------------------- ### Install Azure CLI on macOS Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/en/walkthrough/03-Setup/README.md Installs the Azure CLI on macOS using Homebrew or by downloading and running the installation script from the official Microsoft link. ```bash # Using Homebrew brew install azure-cli # Or using installer curl -L https://aka.ms/InstallAzureCli | bash ``` -------------------------------- ### Dockerfile Instructions for MCP Server Setup Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/ar/walkthrough/12-Best-Practices/README.md These Dockerfile instructions outline the steps to build a Docker image for the MCP server. It includes creating a non-root user, copying the application code and virtual environment, setting up the working directory, configuring security permissions, and defining health checks and start commands. ```dockerfile RUN groupadd -r mcpserver && useradd -r -g mcpserver mcpserver COPY --from=builder /opt/venv /opt/venv ENV PATH="/opt/venv/bin:$PATH" WORKDIR /app COPY mcp_server/ ./mcp_server/ COPY --chown=mcpserver:mcpserver . . RUN chmod -R 755 /app && \ chown -R mcpserver:mcpserver /app USER mcpserver HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8000/health || exit 1 EXPOSE 8000 CMD ["python", "-m", "mcp_server.sales_analysis"] ``` -------------------------------- ### Set Up Test MCP Server Instance (Python) Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/uk/walkthrough/08-Testing/README.md Initializes and configures the MCP server for testing. It uses provided database and mock embedding manager fixtures, sets up configuration, and ensures proper server initialization and cleanup. ```python import pytest import asyncio import asyncpg # Assuming MCPServer, DatabaseProvider, and Config are importable # from mcp_server.server import MCPServer # from mcp_server.database import DatabaseProvider # from mcp_server.config import Config # Mock imports for demonstration if actual classes are not available in this context class MCPServer: def __init__(self, config, db_provider): self.config = config self.db_provider = db_provider self.embedding_manager = None async def initialize(self): pass async def cleanup(self): pass class DatabaseProvider: def __init__(self, connection_string): self.connection_string = connection_string async def initialize(self): pass class Config: def __init__(self): self.database = type('obj', (object,), {'connection_string': None}) self.server = type('obj', (object,), {'enable_debug': False}) TEST_DATABASE_URL = "postgresql://test_user:test_pass@localhost:5432/test_retail_db" # Assume test_database and mock_embedding_manager fixtures are defined elsewhere @pytest.fixture async def test_mcp_server(db_connection, mock_embedding_manager): """Set up test MCP server instance.""" from mcp_server.server import MCPServer from mcp_server.database import DatabaseProvider from mcp_server.config import Config # Create test configuration config = Config() config.database.connection_string = TEST_DATABASE_URL config.server.enable_debug = True # Create database provider db_provider = DatabaseProvider(config.database.connection_string) await db_provider.initialize() # Create MCP server server = MCPServer(config, db_provider) server.embedding_manager = mock_embedding_manager await server.initialize() yield server await server.cleanup() ``` -------------------------------- ### Python Test Setup and Execution Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/uk/walkthrough/10-Deployment/README.md This snippet details the steps for setting up the Python environment, installing dependencies, configuring the test database, and running unit tests using pytest. It includes environment variable configurations for database connection and secrets for cloud services. ```bash python -m pip install --upgrade pip pip install -r requirements.lock.txt pip install pytest pytest-cov pytest-asyncio PGPASSWORD=postgres psql -h localhost -U postgres -d retail_test -f scripts/create_schema.sql python scripts/generate_sample_data.py --test pytest tests/ -v --cov=mcp_server --cov-report=xml --cov-report=html # Environment variables for test database: # POSTGRES_HOST: localhost # POSTGRES_PORT: 5432 # POSTGRES_DB: retail_test # POSTGRES_USER: postgres # POSTGRES_PASSWORD: postgres # Environment variables for cloud services (secrets): # PROJECT_ENDPOINT # AZURE_CLIENT_ID # AZURE_CLIENT_SECRET # AZURE_TENANT_ID ``` -------------------------------- ### Install Git on Linux Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/en/walkthrough/03-Setup/README.md Installs Git on Linux (Ubuntu/Debian or RHEL/CentOS) using the respective package managers. ```bash # Ubuntu/Debian sudo apt update && sudo apt install git # RHEL/CentOS sudo dnf install git ``` -------------------------------- ### Set Up MCP Server Test Instance Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/pl/walkthrough/08-Testing/README.md Initializes and configures the MCP Server for testing. It sets up the configuration, creates a database provider, and injects a mocked embedding manager. This fixture depends on `db_connection` and `mock_embedding_manager`. ```python import pytest # Assuming these imports are available in the project context # from mcp_server.server import MCPServer # from mcp_server.database import DatabaseProvider # from mcp_server.config import Config TEST_DATABASE_URL = "postgresql://test_user:test_pass@localhost:5432/test_retail_db" @pytest.fixture async def test_mcp_server(db_connection, mock_embedding_manager): """Set up test MCP server instance.""" # Mock imports for demonstration if not globally available class MockMCPServer: def __init__(self, config, db_provider): self.config = config self.db_provider = db_provider self.embedding_manager = None async def initialize(self): pass async def cleanup(self): pass class MockDatabaseProvider: def __init__(self, connection_string): self.connection_string = connection_string async def initialize(self): pass class MockConfig: def __init__(self): self.database = self.MockDatabaseConfig() self.server = self.MockServerConfig() class MockDatabaseConfig: connection_string = None class MockServerConfig: enable_debug = False # Create test configuration config = MockConfig() config.database.connection_string = TEST_DATABASE_URL config.server.enable_debug = True # Create database provider db_provider = MockDatabaseProvider(config.database.connection_string) await db_provider.initialize() # Create MCP server server = MockMCPServer(config, db_provider) server.embedding_manager = mock_embedding_manager await server.initialize() yield server await server.cleanup() ``` -------------------------------- ### Install Azure CLI on Windows Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/en/walkthrough/03-Setup/README.md Installs the Azure Command-Line Interface on Windows using Windows Package Manager or by downloading the MSI installer from the official Microsoft link. ```cmd # Using Windows Package Manager winget install Microsoft.AzureCLI # Or download MSI from: https://aka.ms/installazurecliwindows ``` -------------------------------- ### Set Up Test Database and Generate Sample Data Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/ro/walkthrough/10-Deployment/README.md This step initializes the test database by running a SQL script to create the schema and then generates sample data using a Python script. It utilizes environment variables for database connection details, ensuring the test environment is properly configured. ```yaml - name: Set up test database run: | PGPASSWORD=postgres psql -h localhost -U postgres -d retail_test -f scripts/create_schema.sql python scripts/generate_sample_data.py --test env: POSTGRES_HOST: localhost POSTGRES_PORT: 5432 POSTGRES_DB: retail_test POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres ``` -------------------------------- ### Install Docker Desktop on macOS Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/en/walkthrough/03-Setup/README.md Installs Docker Desktop on macOS using Homebrew or by downloading the DMG file. It includes steps for launching Docker Desktop and verifying the installation. ```bash # Download from https://desktop.docker.com/mac/stable/Docker.dmg # Or use Homebrew brew install --cask docker ``` ```bash docker --version docker-compose --version ``` -------------------------------- ### Install Azure Developer CLI (azd) Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/azd/README.md Installs the Azure Developer CLI (azd) on different operating systems. Requires administrative privileges for some installations. ```bash # Windows (winget) winget install microsoft.azurecli winget install Microsoft.AzureDeveloperCLI # macOS (brew) brew install azure-cli brew install azd # Linux curl -fsSL https://aka.ms/install-azd.sh | bash ``` -------------------------------- ### Set up Python Test Environment and Install Dependencies Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/sl/walkthrough/10-Deployment/README.md This job runs on an Ubuntu environment and sets up Python 3.11 with pip caching. It then installs project dependencies from 'requirements.lock.txt' and testing libraries like pytest, pytest-cov, and pytest-asyncio. ```yaml jobs: test: runs-on: ubuntu-latest services: postgres: image: pgvector/pgvector:pg16 env: POSTGRES_PASSWORD: postgres POSTGRES_DB: retail_test options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports: - 5432:5432 steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.11' cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip pip install -r requirements.lock.txt pip install pytest pytest-cov pytest-asyncio ``` -------------------------------- ### Upgrade Pip and Setuptools Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/en/walkthrough/03-Setup/README.md Upgrades the pip package installer and setuptools library to their latest versions. Often resolves package installation errors. ```bash # Upgrade pip and setuptools python -m pip install --upgrade pip setuptools wheel ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/en/walkthrough/03-Setup/README.md Installs all necessary Python development dependencies listed in 'requirements.lock.txt' using pip. It also includes commands to verify the installation of key packages like fastmcp, asyncpg, and Azure libraries. ```bash # Install development dependencies pip install -r requirements.lock.txt # Verify key packages pip list | grep fastmcp pip list | grep asyncpg pip list | grep azure ``` -------------------------------- ### Setup Test Database and Schema with PostgreSQL Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/pt/walkthrough/08-Testing/README.md This fixture sets up the test database, drops it if it exists, creates a new one, and then loads schema and sample data SQL files. It utilizes `asyncpg` for asynchronous PostgreSQL operations and `load_sql_file` to read SQL scripts. ```python import pytest import asyncio import asyncpg TEST_DATABASE_URL = "postgresql://test_user:test_pass@localhost:5432/test_retail_db" async def load_sql_file(file_path: str) -> str: """Load SQL file content.""" with open(file_path, 'r') as file: return file.read() @pytest.uuid(scope="session") async def test_database(): """Set up test database with schema and sample data.""" # Create test database connection sys_conn = await asyncpg.connect( "postgresql://postgres:password@localhost:5432/postgres" ) try: # Create test database await sys_conn.execute("DROP DATABASE IF EXISTS test_retail_db") await sys_conn.execute("CREATE DATABASE test_retail_db") finally: await sys_conn.close() # Connect to test database and set up schema test_conn = await asyncpg.connect(TEST_DATABASE_URL) try: # Load schema schema_sql = await load_sql_file("../scripts/create_schema.sql") await test_conn.execute(schema_sql) # Load sample data sample_data_sql = await load_sql_file("../scripts/sample_data.sql") await test_conn.execute(sample_data_sql) yield test_conn finally: await test_conn.close() # Cleanup test database sys_conn = await asyncpg.connect( "postgresql://postgres:password@localhost:5432/postgres" ) try: await sys_conn.execute("DROP DATABASE IF EXISTS test_retail_db") finally: await sys_conn.close() ``` -------------------------------- ### Dockerfile: Build and Run Retail Server Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/sl/walkthrough/12-Best-Practices/README.md Dockerfile commands to create a non-root user, copy application code, set up the virtual environment, and configure security for the retail server. It includes health checks and defines the entry point for starting the application. ```dockerfile # Create non-root user RUN groupadd -r mcpserver && useradd -r -g mcpserver mcpserver # Copy virtual environment from builder COPY --from=builder /opt/venv /opt/venv ENV PATH="/opt/venv/bin:$PATH" # Set working directory WORKDIR /app # Copy application code COPY mcp_server/ ./mcp_server/ COPY --chown=mcpserver:mcpserver . . # Set security configurations RUN chmod -R 755 /app && \ chown -R mcpserver:mcpserver /app # Switch to non-root user USER mcpserver # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8000/health || exit 1 # Expose port EXPOSE 8000 # Start application CMD ["python", "-m", "mcp_server.sales_analysis"] ``` -------------------------------- ### Verify Python and Pip Installation Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/en/walkthrough/03-Setup/README.md Verifies that Python and pip have been installed correctly by checking their versions. This ensures that the development environment is set up with the correct tools. ```bash python --version # Should show Python 3.11.x pip --version # Should show pip version ``` -------------------------------- ### Install Git on macOS Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/en/walkthrough/03-Setup/README.md Installs or updates Git on macOS using Homebrew. Git is often pre-installed on macOS, but Homebrew ensures the latest version. ```bash # Git is usually pre-installed, but you can update via Homebrew brew install git ``` -------------------------------- ### Deploy to Staging Environment using Azure CLI (Bash) Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/sv/walkthrough/10-Deployment/README.md This step deploys the application to the staging environment. It first logs into Azure using provided credentials and then utilizes the Azure CLI to execute deployment scripts. This stage is triggered only on pushes to the main branch. ```bash # Deploy infrastructure ``` -------------------------------- ### Install Azure CLI on Linux Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/en/walkthrough/03-Setup/README.md Installs the Azure CLI on Linux (Ubuntu/Debian or RHEL/CentOS) using distribution-specific package managers and Microsoft's repository. ```bash # Ubuntu/Debian curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash # RHEL/CentOS sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc sudo dnf install azure-cli ``` -------------------------------- ### GitHub Actions CI/CD Pipeline Setup Placeholder Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/uk/walkthrough/10-Deployment/README.md This section is a placeholder for setting up a GitHub Actions CI/CD pipeline. The provided YAML content is minimal and indicates the start of a workflow definition, but lacks specific job details or actions for building, testing, or deploying the application. ```yaml ```yaml ``` -------------------------------- ### Install Python 3.11 on Windows Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/walkthrough/03-Setup/README.md Installs Python 3.11 on Windows using the Windows Package Manager (winget) or by downloading the installer from the official Python website. Python 3.8+ is a requirement for MCP server development. ```cmd # Using Windows Package Manager winget install Python.Python.3.11 # Or download from: https://www.python.org/downloads/ ``` -------------------------------- ### Generate Contribution Guide in Python Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/en/walkthrough/12-Best-Practices/README.md Provides tools for community engagement by generating a personalized contribution guide. This guide outlines setup, contribution areas, and community resources. It also includes a method to validate contributions against predefined standards. ```python from typing import Dict class CommunityContributor: """Tools for community engagement and contribution.""" @staticmethod def generate_contribution_guide(): """Generate personalized contribution guide.""" return { "getting_started": { "setup": "Follow setup guide in Module 03", "first_contribution": "Start with documentation improvements", "testing": "Run full test suite before submitting PR" }, "contribution_areas": { "documentation": "Improve learning modules and examples", "testing": "Add test cases and improve coverage", "features": "Implement new MCP tools and capabilities", "performance": "Optimize queries and caching", "security": "Enhance security measures and validation" }, "community_resources": { "discord": "https://discord.com/invite/ByRwuEEgH4", "discussions": "GitHub Discussions for Q&A", "issues": "GitHub Issues for bug reports", "examples": "Share your implementation examples" } } @staticmethod def validate_contribution(pr_data: Dict) -> Dict[str, bool]: """Validate contribution meets standards.""" return { "has_tests": "test" in pr_data.get("files_changed", []), "has_documentation": "README" in str(pr_data.get("files_changed", [])), "follows_conventions": True, # Would implement actual checks "security_reviewed": pr_data.get("security_review", False), "performance_tested": pr_data.get("benchmark_results", False) } ``` -------------------------------- ### Initialize and Start Performance Monitor - Python Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/mr/walkthrough/10-Deployment/README.md Initializes the `PerformanceMonitor` class, setting up logging and data structures for metrics. The `start_monitoring` method initiates the continuous collection and cleanup of performance metrics by creating asyncio tasks. ```python import asyncio import logging class PerformanceMonitor: """Monitor and collect performance metrics.""" def __init__(self, config): self.config = config self.logger = logging.getLogger(__name__) self.metrics_history = [] self.request_times = [] self.error_count = 0 self.request_count = 0 self.db_pool = None async def start_monitoring(self): """Start continuous performance monitoring.""" self.logger.info("Starting performance monitoring") asyncio.create_task(self._collect_metrics_loop()) asyncio.create_task(self._cleanup_old_metrics()) ``` -------------------------------- ### Generate Contribution Guide (Python) Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/ar/walkthrough/12-Best-Practices/README.md Provides tools for community engagement, including generating a personalized contribution guide and validating contributions against defined standards. Returns dictionaries outlining contribution areas, resources, and validation results. ```python from typing import Dict class CommunityContributor: """Tools for community engagement and contribution.""" @staticmethod def generate_contribution_guide() -> Dict: """Generate personalized contribution guide.""" return { "getting_started": { "setup": "Follow setup guide in Module 03", "first_contribution": "Start with documentation improvements", "testing": "Run full test suite before submitting PR" }, "contribution_areas": { "documentation": "Improve learning modules and examples", "testing": "Add test cases and improve coverage", "features": "Implement new MCP tools and capabilities", "performance": "Optimize queries and caching", "security": "Enhance security measures and validation" }, "community_resources": { "discord": "https://discord.com/invite/ByRwuEEgH4", "discussions": "GitHub Discussions for Q&A", "issues": "GitHub Issues for bug reports", "examples": "Share your implementation examples" } } @staticmethod def validate_contribution(pr_data: Dict) -> Dict[str, bool]: """Validate contribution meets standards.""" return { "has_tests": "test" in pr_data.get("files_changed", []), "has_documentation": "README" in str(pr_data.get("files_changed", [])), "follows_conventions": True, # Would implement actual checks "security_reviewed": pr_data.get("security_review", False), "performance_tested": pr_data.get("benchmark_results", False) } ``` -------------------------------- ### Install Python 3.11 on macOS Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/walkthrough/03-Setup/README.md Installs Python 3.11 on macOS using Homebrew. This ensures the project has the required Python version for MCP server development. ```bash # Using Homebrew brew install python@3.11 ``` -------------------------------- ### Set up Test MCP Server Instance Source: https://github.com/microsoft/mcp-server-and-postgresql-sample-retail/blob/main/translations/mo/walkthrough/08-Testing/README.md This fixture initializes and configures the MCP server for testing. It depends on the `db_connection` and `mock_embedding_manager` fixtures to provide necessary dependencies. The fixture creates a `Config` object, sets the database connection string, enables debug mode, and initializes the `DatabaseProvider` and `MCPServer`. It yields the server instance and ensures cleanup by calling `server.cleanup()` after the test. ```python @pytest.fixture async def test_mcp_server(db_connection, mock_embedding_manager): """Set up test MCP server instance.""" from mcp_server.server import MCPServer from mcp_server.database import DatabaseProvider from mcp_server.config import Config # Create test configuration config = Config() config.database.connection_string = TEST_DATABASE_URL config.server.enable_debug = True # Create database provider db_provider = DatabaseProvider(config.database.connection_string) await db_provider.initialize() # Create MCP server server = MCPServer(config, db_provider) server.embedding_manager = mock_embedding_manager await server.initialize() yield server await server.cleanup() ```