Skip to main content
Glama
SirMacke

adsense-mcp

by SirMacke

AdSense MCP

MCP-сервер, который извлекает данные ad-hoc из AdSense Management API v2. Он предоставляет неограниченный интерфейс отчетов: любые поддерживаемые измерения, метрики, фильтры, временной период, порядок сортировки, часовой пояс, язык, валюта и лимит AdSense могут быть переданы в accounts.reports.generate.

Сервер использует OAuth-область только для чтения https://www.googleapis.com/auth/adsense.readonly. Он не записывает данные в аккаунт AdSense.

Установка

После публикации запустите его из MCP-клиента с помощью npx -y @sirmacke/adsense-mcp. Настройте либо ADSENSE_ACCESS_TOKEN, либо все три: ADSENSE_CLIENT_ID, ADSENSE_CLIENT_SECRET и ADSENSE_REFRESH_TOKEN.

Related MCP server: google-ads-mcp

Безопасность

OAuth-токены доступа, refresh-токены и секреты клиента являются учетными данными. Не храните их в этом репозитории, в трекерах задач, в истории командной оболочки и в конфигурации MCP, которой вы делитесь с другими. Если один из них раскрыт, немедленно отзовите его в Google Cloud; см. SECURITY.md.

Настройка

  1. В Google Cloud включите AdSense Management API и создайте OAuth Desktop-клиент.

  2. Получите refresh-токен с областью https://www.googleapis.com/auth/adsense.readonly. Держите его в секрете.

  3. Скопируйте .env.example в вашу защищенную конфигурацию окружения и заполните либо ADSENSE_ACCESS_TOKEN, либо идентификатор клиента OAuth, секрет и refresh-токен.

  4. Установите и соберите:

npm install
npm run build

Одноразовая авторизация OAuth (без gcloud)

Скачайте JSON OAuth Desktop-клиента из Google Cloud, затем выполните:

$env:ADSENSE_OAUTH_CLIENT_FILE = "C:\secure\adsense-client.json"
$env:ADSENSE_TOKEN_FILE = "C:\secure\adsense-oauth.json"
npm run authorize

Команда открывает экран согласия Google на callback localhost и сохраняет идентификатор клиента, секрет клиента и refresh-токен только в приватном файле токенов. Скопируйте эти значения в поля ADSENSE_CLIENT_ID, ADSENSE_CLIENT_SECRET и ADSENSE_REFRESH_TOKEN конфигурации MCP. Не оставляйте внешний экран согласия в статусе «Тестирование»: его refresh-токены истекают через семь дней.

Claude Desktop

Текущие сборки Claude Desktop используют расширения. Выполните npm run package, затем установите build/adsense-mcp.mcpb через Настройки → Расширения → Дополнительные настройки → Установить расширение. Он безопасно запросит значения OAuth. В установках, поддерживающих классическую конфигурацию, добавьте вместо этого:

{
  "mcpServers": {
    "adsense": {
      "command": "node",
      "args": ["/absolute/path/to/adsense-mcp/dist/index.js"],
      "env": {
        "ADSENSE_CLIENT_ID": "...",
        "ADSENSE_CLIENT_SECRET": "...",
        "ADSENSE_REFRESH_TOKEN": "..."
      }
    }
  }
}

Codex

Добавьте эквивалентное определение сервера в вашу конфигурацию Codex MCP, используя ту же команду, аргументы и переменные окружения. Сервер использует стандартный транспорт MCP stdio и работает в обоих клиентах.

Инструменты

  • adsense_list_accounts

  • adsense_get_account

  • adsense_generate_report

Пример запроса отчета: metrics: ["ESTIMATED_EARNINGS", "PAGE_VIEWS", "CLICKS"], dimensions: ["DATE", "COUNTRY_NAME"], dateRange: "LAST_7_DAYS", orderBy: ["-ESTIMATED_EARNINGS"].

Проверка

npm test
npm run build

Для проверки на живых данных также требуются указанные выше значения OAuth и аккаунт AdSense. Конечная точка отчета API — GET /v2/{account}/reports:generate; для нее требуется область OAuth AdSense или AdSense только для чтения.

Лицензия

MIT

Available Tools

3 tools
adsense_generate_reportA

Extract any ad-hoc AdSense report. Supply API v2 dimensions, metrics, filters, dates, sorting, and other report parameters. Account is discovered automatically when omitted.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNo
accountNoAccount resource name; optional when one account is accessible.
endDateNoCustom end date in YYYY-MM-DD.
filtersNoAdSense filters, e.g. AD_CLIENT_ID==ca-pub-...
metricsYesRequired metrics, e.g. ESTIMATED_EARNINGS, PAGE_VIEWS, CLICKS.
orderByNoColumns to sort, e.g. -ESTIMATED_EARNINGS.
dateRangeNoPreset date range such as TODAY, YESTERDAY, LAST_7_DAYS, MONTH_TO_DATE, CUSTOM.
startDateNoCustom start date in YYYY-MM-DD.
dimensionsNoReport dimensions, e.g. DATE, AD_UNIT_NAME, COUNTRY_NAME.
currencyCodeNo
languageCodeNo
reportingTimeZoneNoACCOUNT_TIME_ZONE or GOOGLE_TIME_ZONE.

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the behavioral burden. "Extract" implies a read-only data fetch, and "Account is discovered automatically when omitted" is a useful behavioral detail. However, it does not disclose response format, pagination behavior, permissions, or any side effects, leaving a meaningful transparency gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two front-loaded sentences say exactly what is needed without fluff. The first sentence gives the purpose, the second tells the caller what to supply and clarifies account optionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 12 parameters, no output schema, and no annotations, this description is too thin. It does not say what the report response looks like, whether results are paginated, or how ad-hoc complexity is handled. The auto-discovery note is helpful, but the tool still lacks guidance for an agent to fully anticipate the invocation outcome.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 75%, and the description adds a high-level parameter map: dimensions, metrics, filters, dates, sorting, and other report parameters. It also notes the API version, which helps normalize parameter syntax. It does not detail every uncovered parameter such as limit, currencyCode, or languageCode, but the schema still provides most semantics.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource: "Extract any ad-hoc AdSense report." It clearly distinguishes this reporting tool from the sibling account tools by framing it as report extraction with flexible parameters.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It gives clear context: use this tool for ad-hoc AdSense reporting where the caller supplies dimensions, metrics, filters, dates, and sorting. It also removes a common prerequisite by noting that the account is discovered automatically when omitted. It does not explicitly compare to sibling alternatives, but the usage context is clear.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

adsense_get_accountA

Get one AdSense account by resource name, e.g. accounts/pub-123.

ParametersJSON Schema
NameRequiredDescriptionDefault
accountYes

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of disclosing side effects. It only says 'get', implying a read-only operation, but does not explicitly confirm it is non-destructive, nor does it mention permission requirements, error behavior, or return value characteristics. The minimal disclosure is insufficient for safe invocation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence with an example, containing no filler. Every word adds value and it is front-loaded with the core action.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (one parameter, no output schema), the description covers the basics but omits details like return value structure, error handling (e.g., what happens if account doesn't exist), and any authentication or permission notes. Since there is no output schema, explaining what is returned would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It indirectly explains the 'account' parameter by saying 'by resource name' and gives an example format ('accounts/pub-123'), which clarifies the required pattern. However, it does not explicitly name the parameter or explain its full semantics (e.g., must start with 'accounts/'), leaving some ambiguity.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action: 'Get one AdSense account by resource name' with a specific example. It distinguishes from siblings (adsense_list_accounts for multiple, adsense_generate_report for reporting) by focusing on retrieving a single account by its resource identifier.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied through the phrase 'by resource name' and the example, but there is no explicit guidance on when to use this tool versus alternatives like list_accounts. It does not state when not to use it or mention prerequisites (e.g., need a known account resource name).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

adsense_list_accountsA

List AdSense accounts available to the authenticated user.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.6/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the burden. It states the tool lists accounts, which is a read operation, but does not disclose any behavioral traits such as authentication requirements, rate limits, or whether it returns all accounts or only those with certain statuses. The description is minimal but not misleading.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that fully conveys the tool's purpose. There is no wasted text, and it is front-loaded with the action and resource.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (no parameters, no output schema, no annotations), the description is mostly complete. However, it could benefit from mentioning what the response contains (e.g., account IDs, names) or any prerequisites like authentication, but the lack of complexity makes this a minor gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, and schema description coverage is 100% (vacuously). The description adds no parameter details because there are none, but it correctly implies no inputs are needed. Baseline for 0 params is 4, and the description is adequate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool lists AdSense accounts for the authenticated user, using a specific verb and resource. It distinguishes from siblings like adsense_get_account (which likely retrieves a single account) and adsense_generate_report (which generates reports), though it doesn't explicitly name them.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context (listing accounts for the authenticated user) but does not explicitly state when to use this tool versus alternatives. It doesn't mention exclusions or alternatives, but the purpose is clear enough that an agent can infer when to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 3 tool updatesv0.1.1
    • First observedadsense_generate_report
    • First observedadsense_get_account
    • First observedadsense_list_accounts

TDQS

A3.8/5.0

Scored across 3 tools

Disambiguation5/5

Each tool targets a distinct operation: listing accounts, retrieving a specific account, and generating reports. There is no overlap between these actions, and the report tool even auto-discovers the account, reducing ambiguity.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern with the 'adsense_' prefix (list_accounts, get_account, generate_report). This makes the naming predictable and easy to navigate.

Tool Count4/5

With 3 tools, the server is on the lower end of the ideal range, but it covers the core AdSense operations: account listing, account retrieval, and report generation. The count feels minimal yet sufficient for a focused server, though slightly thin.

Completeness3/5

The surface covers essential account and reporting operations, but lacks other common AdSense resources like ad units, sites, or alerts. This might be a notable gap for agents needing broader management capabilities, though it may be acceptable for a report-focused server.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    MCP server for Google AdSense management. Create ad units, generate framework-specific ad code, manage earnings reports, and automate ads.txt — all from your AI assistant.
    12
    13 npm
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP server for Google Ads campaign reporting and management via Claude, enabling GAQL queries, performance metrics, and campaign modifications.
    27 npm
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    MCP server for querying Google Analytics accounts, properties, reports, and realtime data using the Data API and Admin API.
    Apache 2.0
  • A
    license
    Not graded
    quality
    F
    maintenance
    MCP server that provides tools to interact with Google Analytics APIs, enabling account and property retrieval, report running, and custom dimension/metrics access.
    Apache 2.0