install.ps1•8 kB
# Google Forms MCP Server - Windows Installation Script
# This script handles complete setup for non-technical users
$ErrorActionPreference = "Stop"
# Get the directory where this script is located
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location $ScriptDir
function Write-ColorOutput($ForegroundColor) {
$fc = $host.UI.RawUI.ForegroundColor
$host.UI.RawUI.ForegroundColor = $ForegroundColor
if ($args) {
Write-Output $args
}
$host.UI.RawUI.ForegroundColor = $fc
}
Write-ColorOutput Blue "╔════════════════════════════════════════════════════════════╗"
Write-ColorOutput Blue "║ Google Forms MCP Server - Cursor Installation ║"
Write-ColorOutput Blue "╔════════════════════════════════════════════════════════════╗"
Write-Output ""
# Step 1: Check and install uv
Write-ColorOutput Yellow "Step 1/5: Checking for uv package manager..."
$uvInstalled = Get-Command uv -ErrorAction SilentlyContinue
if (-not $uvInstalled) {
Write-ColorOutput Yellow "uv not found. Installing uv..."
# Install uv using PowerShell installer
irm https://astral.sh/uv/install.ps1 | iex
# Refresh PATH
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
$uvInstalled = Get-Command uv -ErrorAction SilentlyContinue
if (-not $uvInstalled) {
Write-ColorOutput Red "Failed to install uv. Please install manually from: https://github.com/astral-sh/uv"
exit 1
}
Write-ColorOutput Green "✓ uv installed successfully"
} else {
Write-ColorOutput Green "✓ uv is already installed"
}
Write-Output ""
# Step 2: Install dependencies
Write-ColorOutput Yellow "Step 2/5: Installing Python dependencies..."
uv sync
Write-ColorOutput Green "✓ Dependencies installed"
Write-Output ""
# Step 3: Google Cloud OAuth Setup
Write-ColorOutput Yellow "Step 3/5: Setting up Google Cloud OAuth credentials"
Write-Output ""
Write-Output "You need to create OAuth credentials in Google Cloud Console."
Write-Output "This will allow the MCP server to access your Google Forms."
Write-Output ""
Write-ColorOutput Blue "Please follow these steps:"
Write-Output ""
Write-Output "1. Open: https://console.cloud.google.com"
Write-Output "2. Create a new project (or select existing one)"
Write-Output "3. Enable these APIs:"
Write-Output " - Google Forms API"
Write-Output " - Google Drive API"
Write-Output "4. Go to 'Credentials' → 'Create Credentials' → 'OAuth client ID'"
Write-Output "5. Application type: 'Desktop app'"
Write-Output "6. Name it: 'Google Forms MCP'"
Write-Output "7. Click 'Create'"
Write-Output ""
Write-ColorOutput Green "When ready, press Enter to continue..."
$null = Read-Host
# Ask for client ID and secret
Write-Output ""
Write-ColorOutput Yellow "Enter your OAuth Client ID:"
$ClientId = Read-Host
Write-ColorOutput Yellow "Enter your OAuth Client Secret:"
$ClientSecret = Read-Host
# Create client_secrets.json for token generation
$clientSecretsContent = @"
{
"installed": {
"client_id": "$ClientId",
"client_secret": "$ClientSecret",
"redirect_uris": ["http://localhost:8080"],
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token"
}
}
"@
Set-Content -Path "client_secrets.json" -Value $clientSecretsContent
Write-ColorOutput Green "✓ OAuth credentials saved"
Write-Output ""
# Step 4: Generate refresh token
Write-ColorOutput Yellow "Step 4/5: Generating OAuth refresh token..."
Write-Output ""
Write-Output "This will open your browser to authorize the application."
Write-Output "Please sign in with your Google account and grant access."
Write-Output ""
Write-ColorOutput Green "Press Enter to open browser..."
$null = Read-Host
# Run the token generation script and capture output
try {
$TokenOutput = uv run python get_token.py 2>&1 | Out-String
} catch {
Write-ColorOutput Red "Failed to generate token. Please check the error above."
exit 1
}
# Extract refresh token from output
$RefreshToken = ($TokenOutput -split "`n" | Where-Object { $_ -match "GOOGLE_REFRESH_TOKEN=" }) -replace "GOOGLE_REFRESH_TOKEN=", ""
if (-not $RefreshToken) {
Write-ColorOutput Red "Failed to extract refresh token. Please run 'uv run python get_token.py' manually."
exit 1
}
Write-ColorOutput Green "✓ Token generated successfully"
Write-Output ""
# Create .env file
$envContent = @"
# Google OAuth Credentials
# Generated by install.ps1 on $(Get-Date)
GOOGLE_CLIENT_ID=$ClientId
GOOGLE_CLIENT_SECRET=$ClientSecret
GOOGLE_REFRESH_TOKEN=$RefreshToken
"@
Set-Content -Path ".env" -Value $envContent
Write-ColorOutput Green "✓ .env file created"
Write-Output ""
# Clean up client_secrets.json (optional, for security)
Remove-Item -Path "client_secrets.json" -ErrorAction SilentlyContinue
# Step 5: Configure Cursor
Write-ColorOutput Yellow "Step 5/5: Configuring Cursor IDE..."
Write-Output ""
# Cursor config location on Windows
$CursorConfigDir = "$env:APPDATA\Cursor\User\globalStorage"
$McpConfigFile = "$CursorConfigDir\mcp.json"
# Create directory if it doesn't exist
New-Item -ItemType Directory -Force -Path $CursorConfigDir | Out-Null
# Prepare the configuration
$mcpConfig = @"
{
"mcpServers": {
"google-forms": {
"command": "uv",
"args": [
"--directory",
"$ScriptDir",
"run",
"python",
"main.py"
]
}
}
}
"@
# Check if mcp.json exists
if (Test-Path $McpConfigFile) {
Write-ColorOutput Yellow "Cursor MCP configuration already exists."
Write-Output "Your current config: $McpConfigFile"
Write-Output ""
Write-Output "Add this to your mcpServers section:"
Write-Output ""
Write-Output $mcpConfig
Write-Output ""
Write-ColorOutput Yellow "Would you like to open the config file for editing? (y/n)"
$openConfig = Read-Host
if ($openConfig -eq "y" -or $openConfig -eq "Y") {
notepad $McpConfigFile
}
} else {
# Create new mcp.json
Set-Content -Path $McpConfigFile -Value $mcpConfig
Write-ColorOutput Green "✓ Cursor MCP configuration created at: $McpConfigFile"
}
Write-Output ""
Write-ColorOutput Green "╔════════════════════════════════════════════════════════════╗"
Write-ColorOutput Green "║ Installation Complete! 🎉 ║"
Write-ColorOutput Green "╔════════════════════════════════════════════════════════════╗"
Write-Output ""
Write-ColorOutput Blue "Next steps:"
Write-Output "1. Restart Cursor IDE"
Write-Output "2. Open a project in Cursor"
Write-Output "3. Start using Google Forms MCP tools in AI chat"
Write-Output ""
Write-ColorOutput Blue "Test it by asking Cursor:"
Write-Output " 'List my Google Forms'"
Write-Output ""
Write-ColorOutput Blue "Available tools:"
Write-Output " - forms_create, forms_list, forms_get, forms_update, forms_delete"
Write-Output " - questions_add, questions_update, questions_delete, questions_move"
Write-Output " - responses_list, responses_get, responses_export_csv"
Write-Output " - sections_add, forms_duplicate, forms_get_link"
Write-Output ""
Write-ColorOutput Yellow "Troubleshooting:"
Write-Output " - Config file: $McpConfigFile"
Write-Output " - Credentials: $ScriptDir\.env"
Write-Output " - Test server: uv run python main.py"
Write-Output ""
Write-ColorOutput Green "Thank you for using Google Forms MCP Server!"
Write-Output ""