MCP Marketing Analytics

MCP Marketing Analytics

A minimal MCP server for marketing analytics data discovery and querying, supporting Google Ads integration with mock fallback and real API access.

Category
访问服务器

README

MCP Marketing Analytics

A minimal MCP server for marketing analytics data discovery and querying, starting with a Google Ads integration layer.

Features

  • Data source discovery
  • Google Ads account discovery
  • Field discovery for metrics and dimensions
  • Data query execution with mock fallback and real Google Ads support when configured

Local setup

  1. Install dependencies:
    npm install
    
  2. Copy the environment template:
    cp .env.example .env
    
  3. Build the project:
    npm run build
    
  4. Start the server:
    npm start
    

Testing with MCP Inspector

Run the inspector against the local server:

npx @modelcontextprotocol/inspector node dist/server.js

Example tool calls

Health check:

{
  "name": "health_check",
  "arguments": {}
}

Discover sources:

{
  "name": "data_source_discovery",
  "arguments": {
    "search": "google"
  }
}

Discover accounts:

{
  "name": "accounts_discovery",
  "arguments": {
    "source": "AW"
  }
}

Discover fields:

{
  "name": "field_discovery",
  "arguments": {
    "source": "AW",
    "search": "cost"
  }
}

Run a query:

{
  "name": "data_query",
  "arguments": {
    "source": "AW",
    "accounts": ["1234567890"],
    "fields": ["date", "campaign_name", "clicks", "cost"],
    "dateRange": {
      "start": "2026-07-01",
      "end": "2026-07-07"
    },
    "filters": ["clicks > 100"]
  }
}

Retrieve query result:

{
  "name": "get_query_results",
  "arguments": {
    "scheduleId": "schedule-123"
  }
}

Google Ads configuration

Public multi-tenant connector

Production uses OAuth per user. The service keeps only its Google Ads developer token and Google OAuth application credentials in Vercel; each user's Google refresh token is encrypted and stored separately in Supabase. See docs/multi-tenant-oauth.md for database migration, redirect URI, environment configuration, and rollout instructions.

Local single-user mode

To enable the real Google Ads API flow, define these environment variables in your .env file:

GOOGLE_ADS_DEVELOPER_TOKEN=
GOOGLE_ADS_CLIENT_ID=
GOOGLE_ADS_CLIENT_SECRET=
GOOGLE_ADS_REFRESH_TOKEN=
GOOGLE_ADS_CUSTOMER_ID=
GOOGLE_ADS_LOGIN_CUSTOMER_ID=
GOOGLE_ADS_API_VERSION=v25
GOOGLE_ADS_MOCK_MODE=false

OAuth 2.0 setup for Google Ads

  1. Create or select a Google Cloud project.
  2. Enable the Google Ads API in the Google Cloud console.
  3. Create OAuth 2.0 Client ID credentials for a desktop application.
  4. Add the following OAuth scopes to the consent screen:
    • https://www.googleapis.com/auth/adwords
  5. Use a redirect URI such as:
    • http://localhost
  6. Complete the OAuth authorization flow and store the generated refresh token in GOOGLE_ADS_REFRESH_TOKEN.
  7. Insert your Google Ads developer token and customer IDs in the environment variables above.

Recommended values for the environment file

  • GOOGLE_ADS_DEVELOPER_TOKEN: your Google Ads manager/developer token.
  • GOOGLE_ADS_CLIENT_ID: OAuth client ID from Google Cloud.
  • GOOGLE_ADS_CLIENT_SECRET: OAuth client secret from Google Cloud.
  • GOOGLE_ADS_REFRESH_TOKEN: refresh token obtained after the OAuth flow.
  • GOOGLE_ADS_CUSTOMER_ID: the Google Ads customer ID you want to query.
  • GOOGLE_ADS_LOGIN_CUSTOMER_ID: the manager/customer ID used for login context, often the same as the customer ID.
  • GOOGLE_ADS_API_VERSION: Google Ads API version; defaults to v25.
  • GOOGLE_ADS_MOCK_MODE: opt-in demo data mode; keep false for the real integration.

Local OAuth helper

A local helper is now included so you can complete the flow directly from this project.

  1. Make sure your .env contains GOOGLE_ADS_CLIENT_ID and GOOGLE_ADS_CLIENT_SECRET.
  2. Build the project:
    npm run build
    
  3. Start the OAuth helper:
    npm run oauth:google-ads
    
  4. Open the printed URL in your browser, approve the consent screen, and return to the terminal.
  5. The helper will exchange the authorization code for tokens and print the response.

Example OAuth flow

If you want to test the flow manually, use the standard OAuth 2.0 desktop-app flow:

https://accounts.google.com/o/oauth2/v2/auth?client_id=YOUR_CLIENT_ID&redirect_uri=http://localhost:3000/callback&response_type=code&access_type=offline&scope=https://www.googleapis.com/auth/adwords&prompt=consent

Then exchange the returned authorization code for a refresh token using the local helper above.

Important notes

  • The Google Ads API requires a valid developer token and OAuth credentials.
  • The current implementation uses mock data whenever the required credentials are missing.
  • Once the credentials are present, the server will attempt to call the real Google Ads API endpoints.

Connection diagnostics

Use the google_ads_connection_status MCP tool to verify production configuration without returning credential values. Missing credentials now produce a clear error; mock responses are used only when GOOGLE_ADS_MOCK_MODE=true.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选