Skip to main content
Glama

MCP Complete Implementation Guide

by saksham0712
setup.ps1โ€ข8.25 kB
#!/usr/bin/env pwsh <# .SYNOPSIS Setup script for MCP implementation .DESCRIPTION This script sets up the MCP server environment, installs dependencies, and configures the development environment for Windows. .PARAMETER Language Choose implementation language: 'node' or 'python' (default: 'node') .PARAMETER Force Force reinstall of dependencies .EXAMPLE .\scripts\setup.ps1 .\scripts\setup.ps1 -Language python .\scripts\setup.ps1 -Force #> param( [Parameter(Mandatory=$false)] [ValidateSet('node', 'python')] [string]$Language = 'node', [Parameter(Mandatory=$false)] [switch]$Force ) # Set error action preference $ErrorActionPreference = 'Stop' # Colors for output $colors = @{ Success = 'Green' Warning = 'Yellow' Error = 'Red' Info = 'Cyan' Header = 'Magenta' } function Write-ColorOutput { param( [string]$Message, [string]$Color = 'White' ) Write-Host $Message -ForegroundColor $colors[$Color] } function Test-CommandExists { param([string]$Command) try { Get-Command $Command -ErrorAction Stop | Out-Null return $true } catch { return $false } } function Install-NodeDependencies { Write-ColorOutput "๐Ÿ“ฆ Installing Node.js dependencies..." -Color Info if (-not (Test-CommandExists 'node')) { Write-ColorOutput "โŒ Node.js not found. Please install Node.js v18+ from https://nodejs.org/" -Color Error exit 1 } $nodeVersion = node --version Write-ColorOutput "โœ… Found Node.js $nodeVersion" -Color Success if (-not (Test-CommandExists 'npm')) { Write-ColorOutput "โŒ npm not found. Please ensure npm is installed with Node.js" -Color Error exit 1 } if ($Force) { Write-ColorOutput "๐Ÿ—‘๏ธ Cleaning node_modules..." -Color Warning if (Test-Path "node_modules") { Remove-Item "node_modules" -Recurse -Force } if (Test-Path "package-lock.json") { Remove-Item "package-lock.json" -Force } } npm install if ($LASTEXITCODE -ne 0) { Write-ColorOutput "โŒ Failed to install Node.js dependencies" -Color Error exit 1 } Write-ColorOutput "โœ… Node.js dependencies installed successfully" -Color Success } function Install-PythonDependencies { Write-ColorOutput "๐Ÿ Installing Python dependencies..." -Color Info if (-not (Test-CommandExists 'python')) { Write-ColorOutput "โŒ Python not found. Please install Python 3.8+ from https://python.org/" -Color Error exit 1 } $pythonVersion = python --version Write-ColorOutput "โœ… Found $pythonVersion" -Color Success if (-not (Test-CommandExists 'pip')) { Write-ColorOutput "โŒ pip not found. Please ensure pip is installed with Python" -Color Error exit 1 } # Create virtual environment if (-not (Test-Path "venv")) { Write-ColorOutput "๐Ÿ—๏ธ Creating Python virtual environment..." -Color Info python -m venv venv } # Activate virtual environment Write-ColorOutput "๐Ÿ”„ Activating virtual environment..." -Color Info & ".\venv\Scripts\Activate.ps1" # Upgrade pip python -m pip install --upgrade pip # Install dependencies if ($Force) { pip install -r requirements.txt --force-reinstall } else { pip install -r requirements.txt } if ($LASTEXITCODE -ne 0) { Write-ColorOutput "โŒ Failed to install Python dependencies" -Color Error exit 1 } Write-ColorOutput "โœ… Python dependencies installed successfully" -Color Success } function Setup-Environment { Write-ColorOutput "โš™๏ธ Setting up environment..." -Color Info # Copy .env.example to .env if it doesn't exist if (-not (Test-Path ".env")) { if (Test-Path ".env.example") { Copy-Item ".env.example" ".env" Write-ColorOutput "โœ… Created .env file from template" -Color Success Write-ColorOutput "๐Ÿ“ Please edit .env file with your configuration" -Color Warning } else { Write-ColorOutput "โš ๏ธ .env.example not found, skipping .env creation" -Color Warning } } else { Write-ColorOutput "โœ… .env file already exists" -Color Success } # Create necessary directories $dirs = @('temp', 'logs') foreach ($dir in $dirs) { if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Path $dir | Out-Null Write-ColorOutput "โœ… Created $dir directory" -Color Success } } } function Test-Setup { Write-ColorOutput "๐Ÿงช Testing setup..." -Color Info if ($Language -eq 'node') { # Test Node.js server Write-ColorOutput "Testing Node.js server..." -Color Info $job = Start-Job -ScriptBlock { Set-Location $using:PWD node server.js } Start-Sleep -Seconds 3 try { $response = Invoke-RestMethod -Uri "http://localhost:3000/health" -TimeoutSec 5 if ($response.status -eq 'healthy') { Write-ColorOutput "โœ… Node.js server test passed" -Color Success } else { Write-ColorOutput "โŒ Node.js server test failed" -Color Error } } catch { Write-ColorOutput "โŒ Node.js server test failed: $($_.Exception.Message)" -Color Error } finally { Stop-Job $job -Force Remove-Job $job -Force } } else { # Test Python server Write-ColorOutput "Testing Python server..." -Color Info & ".\venv\Scripts\Activate.ps1" $job = Start-Job -ScriptBlock { Set-Location $using:PWD & ".\venv\Scripts\Activate.ps1" python server.py --http } Start-Sleep -Seconds 5 try { $response = Invoke-RestMethod -Uri "http://localhost:3000/health" -TimeoutSec 5 if ($response.status -eq 'healthy') { Write-ColorOutput "โœ… Python server test passed" -Color Success } else { Write-ColorOutput "โŒ Python server test failed" -Color Error } } catch { Write-ColorOutput "โŒ Python server test failed: $($_.Exception.Message)" -Color Error } finally { Stop-Job $job -Force Remove-Job $job -Force } } } # Main execution try { Write-ColorOutput "๐Ÿš€ MCP Implementation Setup" -Color Header Write-ColorOutput "Language: $Language" -Color Info Write-ColorOutput "Force reinstall: $Force" -Color Info Write-Host "" # Check prerequisites Write-ColorOutput "๐Ÿ” Checking prerequisites..." -Color Info if (-not (Test-CommandExists 'git')) { Write-ColorOutput "โŒ Git not found. Please install Git from https://git-scm.com/" -Color Error exit 1 } Write-ColorOutput "โœ… Git is available" -Color Success # Install dependencies based on language choice if ($Language -eq 'node') { Install-NodeDependencies } else { Install-PythonDependencies } # Setup environment Setup-Environment # Test setup Test-Setup Write-Host "" Write-ColorOutput "๐ŸŽ‰ Setup completed successfully!" -Color Success Write-ColorOutput "" -Color Info Write-ColorOutput "Next steps:" -Color Header Write-ColorOutput "1. Edit .env file with your configuration" -Color Info Write-ColorOutput "2. Run the development server:" -Color Info if ($Language -eq 'node') { Write-ColorOutput " npm run dev" -Color Success } else { Write-ColorOutput " .\\scripts\\start-dev.ps1" -Color Success } Write-ColorOutput "3. Configure your AI client with the MCP server" -Color Info Write-ColorOutput "4. Visit http://localhost:3000/health to check server status" -Color Info } catch { Write-ColorOutput "โŒ Setup failed: $($_.Exception.Message)" -Color Error exit 1 }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/saksham0712/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server