mcp-site-analyst

mcp-site-analyst

An MCP server that provides Google Analytics and Search Console data as tools for AI assistants, enabling natural language queries for web analytics, SEO performance, and site insights.

Category
访问服务器

README

MCP Site Analyst

An MCP (Model Context Protocol) server that provides Google Analytics (GA4) and Google Search Console data as tools for AI assistants.

Features

  • 13 tools across two Google services
    • Google Analytics (GA4): Custom reports, realtime data, metadata discovery, top pages, traffic sources, demographics
    • Google Search Console: Search analytics, sitemaps, URL inspection, site listing, top queries, top pages
  • Dual transport: stdio (local) and stateless HTTP (remote)
  • Flexible auth: Service account key file, inline JSON credentials, Application Default Credentials, or CLI argument
  • Configurable GA4 Property ID: Set once at server level or per-tool call
  • Optional Bearer token auth for HTTP mode

Prerequisites

  1. Google Cloud Project with these APIs enabled:

  2. Service Account with a downloaded JSON key file:

  3. Grant access to the service account:

    • GA4: Admin > Property Access Management > Add the service account email as Viewer
    • Search Console: Settings > Users and permissions > Add the service account email

Installation

npm install
npm run build

Usage

stdio mode (Claude Desktop, Gemini CLI, etc.)

# Using CLI argument
node build/index.js --key-file /path/to/key.json

# Using environment variable
GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json node build/index.js

# With a default GA4 Property ID
node build/index.js --key-file /path/to/key.json --property-id 123456789

HTTP mode

# Default port 3000
node build/index.js --http --key-file /path/to/key.json

# Custom port
node build/index.js --http --port 8080 --key-file /path/to/key.json

# With Bearer token authentication
MCP_AUTH_TOKEN=my-secret-token node build/index.js --http --key-file /path/to/key.json

The HTTP endpoint is available at POST http://localhost:3000/mcp (Streamable HTTP, stateless). A health check endpoint is available at GET http://localhost:3000/health.

Authentication

The server resolves Google credentials in this order:

Priority Method Description
1 --key-file <path> CLI argument pointing to a service account JSON key file
2 GOOGLE_CREDENTIALS_JSON Environment variable containing the full JSON key as a string (useful for containers/CI)
3 GOOGLE_APPLICATION_CREDENTIALS Environment variable pointing to a key file path
4 Application Default Credentials Automatic on Cloud Run, GCE, or when authenticated via gcloud auth application-default login

Claude Desktop Configuration

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "site-analyst": {
      "command": "node",
      "args": [
        "/absolute/path/to/mcp-site-analyst/build/index.js",
        "--key-file",
        "/absolute/path/to/key.json",
        "--property-id",
        "YOUR_GA4_PROPERTY_ID"
      ]
    }
  }
}

Gemini CLI Configuration

Add to your .gemini/settings.json:

{
  "mcpServers": {
    "site-analyst": {
      "command": "node",
      "args": [
        "/absolute/path/to/mcp-site-analyst/build/index.js",
        "--key-file",
        "/absolute/path/to/key.json"
      ]
    }
  }
}

Remote HTTP Configuration

If deployed to a remote server (e.g. Cloud Run), configure your client to use the HTTP endpoint:

{
  "mcpServers": {
    "site-analyst": {
      "httpUrl": "https://your-service-url/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_AUTH_TOKEN"
      }
    }
  }
}

Deploying to Cloud Run

A deployment script is included for Google Cloud Run.

Setup

# Copy the example env file and fill in your values
cp .env.example .env

# Edit .env with your GCP project ID, region, and GA4 property ID

See .env.example for all available configuration options.

Deploy

# Deploy with Cloud Build (no local Docker required)
./deploy.sh --cloud-build

# Deploy with local Docker build
./deploy.sh

# Deploy with Bearer token auth enabled
./deploy.sh --token "my-secret-token"

On Cloud Run the server uses Application Default Credentials automatically via the configured service account — no key file is needed.

Tools Reference

Google Analytics (GA4)

Tool Description
ga4_run_report Run a custom report with flexible dimensions, metrics, date ranges, filters, and sorting
ga4_realtime_report Get real-time active user data (last 30 minutes)
ga4_get_metadata Discover all available dimensions and metrics
ga4_top_pages Shortcut: Top pages by pageviews
ga4_top_traffic_sources Shortcut: Top traffic sources by sessions
ga4_user_demographics Shortcut: User breakdown by country/city/language

Google Search Console

Tool Description
gsc_search_analytics Query search performance (clicks, impressions, CTR, position) with filters
gsc_list_sitemaps List all submitted sitemaps
gsc_get_sitemap Get details for a specific sitemap
gsc_inspect_url Inspect a URL's index status and mobile usability
gsc_list_sites List all sites accessible by the service account
gsc_top_queries Shortcut: Top search queries by clicks
gsc_top_pages Shortcut: Top pages by clicks in search

Development

# Run in dev mode (no build step needed)
npx tsx src/index.ts --key-file /path/to/key.json

# Build
npm run build

# Test with MCP Inspector
npx @modelcontextprotocol/inspector node build/index.js --key-file /path/to/key.json

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选