# 启动脚本 - MCP Calculator # 激活虚拟环境并启动服务 # 设置编码为UTF-8,解决中文乱码问题 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8 chcp 65001 | Out-Null # 检查虚拟环境是否存在 $venvPath = ".venv" if (-not (Test-Path $venvPath)) { $venvPath = "venv" if (-not (Test-Path $venvPath)) { Write-Host "错误: 未找到虚拟环境,请先创建虚拟环境" -ForegroundColor Red exit 1 } } # 激活虚拟环境 $activateScript = Join-Path $venvPath "Scripts\Activate.ps1" if (Test-Path $activateScript) { Write-Host "正在激活虚拟环境..." -ForegroundColor Green & $activateScript } else { Write-Host "警告: 未找到虚拟环境激活脚本,继续执行..." -ForegroundColor Yellow } # 设置环境变量 Write-Host "正在设置环境变量..." -ForegroundColor Green $env:FLASK_API_BASE = "http://192.168.254.242:5050" $env:MCP_ENDPOINT = "wss://api.xiaozhi.me/mcp/?token=eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjgxMSwiYWdlbnRJZCI6ODk0MzQxLCJlbmRwb2ludElkIjoiYWdlbnRfODk0MzQxIiwicHVycG9zZSI6Im1jcC1lbmRwb2ludCIsImlhdCI6MTc2MTcxOTA4MywiZXhwIjoxNzkzMjc2NjgzfQ.wu-N4mKWH3mINiEaS8UgbErwoehFyLREekAOg5pT5s-FzngzeFGlsid7fuvEW20E7O_wCvkgZd0N1vdhrCUJPQ" Write-Host "环境变量已设置:" -ForegroundColor Cyan Write-Host " FLASK_API_BASE = $env:FLASK_API_BASE" -ForegroundColor Cyan Write-Host " MCP_ENDPOINT = $env:MCP_ENDPOINT" -ForegroundColor Cyan # 启动服务 Write-Host "`n正在启动服务..." -ForegroundColor Green Write-Host "执行命令: uv run mcp_pipe.py calculator.py`n" -ForegroundColor Yellow uv run mcp_pipe.py calculator.py