Elevate Analytics MCP
Production-ready MCP server integrating Google Search Console, GA4, and PageSpeed Insights for SEO and analytics intelligence, enabling natural-language queries to Google analytics data.
README
Elevate Analytics MCP
Production-ready analytics and MCP platform integrating Google Search Console, GA4, PageSpeed Insights, and SEO intelligence.
Installation
- Install Node.js 22+.
- Install dependencies:
npm ci
- Copy environment template and update values:
cp .env.example .env
- Validate environment:
npm run check:env
Development
Run local development server:
npm run dev
Run with Docker Compose:
docker compose up --build
Google OAuth Setup
- Create OAuth credentials in Google Cloud Console.
- Configure authorized callback URL:
- local: http://localhost:3000/oauth/google/callback
- production: https://YOUR_CLOUD_RUN_DOMAIN/oauth/google/callback
- Set these environment variables:
- GOOGLE_CLIENT_ID
- GOOGLE_CLIENT_SECRET
- GOOGLE_REDIRECT_URI
Search Console Setup
- Ensure OAuth scope includes https://www.googleapis.com/auth/webmasters.readonly.
- Add and verify your site property in Search Console.
- Ensure authenticated Google account has required site permissions.
GA4 Setup
- Ensure OAuth scope includes https://www.googleapis.com/auth/analytics.readonly.
- Retrieve your GA4 property ID.
- Confirm API access is enabled for the Google Cloud project.
PageSpeed Setup
- Enable PageSpeed Insights API in Google Cloud.
- Set GOOGLE_API_KEY (optional but recommended for quota tracking and reliability).
Cloud Run Deployment
Option A: Cloud Build
gcloud builds submit --config cloudbuild.yaml .
Option B: Scripted Deploy
export GCP_PROJECT_ID=your-project
export GCP_REGION=us-central1
export GCP_SERVICE_NAME=elevate-analytics-mcp
export IMAGE_TAG=$(git rev-parse --short HEAD)
bash scripts/deploy-cloud-run.sh
Secret Manager
Set secrets in Google Secret Manager and bind on deploy:
- jwt-secret
- session-secret
- encryption-key
- google-client-secret
- mcp-api-key
Claude Custom Connector Configuration
- Deploy the MCP server endpoint on Cloud Run.
- Use the Cloud Run HTTPS URL with
/mcppath in Claude Custom Connector. - Provide MCP API key using
x-api-key: <MCP_API_KEY>(orAuthorization: Bearer <MCP_API_KEY>). - Validate MCP discovery:
curl -H "x-api-key: YOUR_MCP_API_KEY" https://YOUR_CLOUD_RUN_URL/mcp
Security and Observability
Implemented production controls:
- Helmet security headers
- CORS controls
- Rate limiting
- Compression
- Trusted proxy support
- Secure cookies (in production)
- Structured JSON logging with Pino
- Health probes: /health, /ready, /live, /version
- Prometheus metrics endpoint: /metrics
- MCP endpoint protection with API key middleware (
MCP_API_KEY)
Collected metrics include:
- Request duration
- Memory usage
- CPU usage
- Process uptime
- Google API latency
- Database latency
- Cache hit ratio
- MCP tool execution time
- MCP tool execution count
- Quota usage events
Caching
- Set
REDIS_URLto enable Redis-backed caches. - If Redis is unavailable, the app falls back to the in-memory cache automatically.
Tracing
- Set
OTEL_ENABLED=trueto emit OpenTelemetry spans. - Optional: set
OTEL_SERVICE_NAMEto override the service name. - Traced operations include OAuth flows, Google APIs, database checks, MCP tools, and incoming HTTP/MCP requests.
Health Endpoints
- GET /health
- GET /ready
- GET /live
Authenticated endpoints:
- GET /version
- GET /metrics
- GET/POST /mcp
Environment Variables
Required in all environments:
- DATABASE_URL
Required in production:
- JWT_SECRET
- SESSION_SECRET
- ENCRYPTION_KEY
- MCP_API_KEY
- GOOGLE_CLIENT_ID
- GOOGLE_CLIENT_SECRET
- GOOGLE_REDIRECT_URI
- GCP_PROJECT_ID
- GCP_REGION
- GCP_SERVICE_NAME
Optional but recommended:
- GOOGLE_API_KEY
- METRICS_AUTH_TOKEN
- ALLOWED_ORIGINS
- LOG_LEVEL
CORS Configuration
ALLOWED_ORIGINSaccepts a comma-separated list of browser origins.- In development, localhost origins such as
http://localhost:3000andhttp://127.0.0.1:3000are allowed automatically. - In production, unknown origins are rejected.
CI/CD
GitHub Actions workflow at .github/workflows/ci-cd.yml executes:
- Install
- Lint
- Build
- Test
- Docker build
- Cloud Run deployment (main branch)
Cloud Build pipeline at cloudbuild.yaml performs equivalent build and deploy workflow.
Troubleshooting
- Startup fails due to missing env vars:
- Run
npm run check:env.
- Run
- OAuth callback errors:
- Verify redirect URI and client credentials.
- 429/quota errors:
- Check Google API quotas and logs for quota events.
- /ready returns non-200:
- Verify database connectivity and DATABASE_URL.
- Metrics endpoint unauthorized:
- Provide
Authorization: Bearer <METRICS_AUTH_TOKEN>when token is set.
- Provide
- MCP endpoint unauthorized:
- Provide
x-api-key: <MCP_API_KEY>orAuthorization: Bearer <MCP_API_KEY>.
- Provide
Testing
Run quality gates:
npm run lint
npm run build
npm test
Run production smoke checks:
bash scripts/production-check.sh http://localhost:3000
Checklists
- Deployment checklist:
docs/deployment-checklist.md - Production checklist:
docs/production-checklist.md
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。