-
Notifications
You must be signed in to change notification settings - Fork 148
planning documentation for mcp #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
varunbhayana-tech
wants to merge
8
commits into
googleads:main
Choose a base branch
from
Maino-Growweasy:mcp-setup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ede14f8
planning documentation for mcp
varunbhayana-tech 3e059a8
Updated
varunbhayana-tech e131c34
in progress
varunbhayana-tech c26d451
in progress
varunbhayana-tech ee57139
added mcp servers for impression and key
varunbhayana-tech 9c8b619
added mcp servers for impression and key
varunbhayana-tech 845c0c9
updated the functions name specific to google
varunbhayana-tech 947d07e
delete .env.local and sh script to run
varunbhayana-tech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| GOOGLE_ADS_DEVELOPER_TOKEN= | ||
| GOOGLE_ADS_LOGIN_CUSTOMER_ID= | ||
| MCP_LOCAL_HTTP=true | ||
| PORT=8080 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| { | ||
| "mcpServers": { | ||
| "google-ads-mcp": { | ||
| "command": "/Users/varunbhayana/Desktop/projects/mcpforked/google-ads-mcp/.venv/bin/google-ads-mcp", | ||
| "env": { | ||
| "GOOGLE_APPLICATION_CREDENTIALS": "/Users/varunbhayana/Desktop/projects/google-ads-mcp/.gcloud/application_default_credentials.json", | ||
| "GOOGLE_ADS_DEVELOPER_TOKEN": "mM23ZIOAiOldJD-oEItRGw", | ||
| "GOOGLE_ADS_LOGIN_CUSTOMER_ID": "5061122756" | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,238 @@ | ||
| # Local Development Setup | ||
|
|
||
| This guide documents the exact local setup to run this repository from source on macOS with `zsh`. | ||
|
|
||
| ## What Lives in This Repo (Not Committed) | ||
|
|
||
| | File / Dir | Purpose | | ||
| |---|---| | ||
| | `.venv/` | Local Python virtual environment | | ||
| | `.env.local` | Local credentials and runtime env vars | | ||
| | `.env.local.example` | Template — copy this to `.env.local` | | ||
| | `run-local.sh` | Starts the MCP server using values from `.env.local` | | ||
| | `gcloud-local.sh` | Runs `gcloud` with a repo-local config directory | | ||
| | `.gcloud/` | Repo-local Google Cloud CLI config and ADC credentials | | ||
| | `.mcp.json` | Claude Code MCP client config (not committed — contains local paths) | | ||
|
|
||
| --- | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - macOS with Homebrew | ||
| - Python 3.11 (`brew install python@3.11`) | ||
| - Google Cloud CLI (`brew install --cask google-cloud-sdk`) | ||
| - A Google Ads developer token | ||
| - A Google Cloud project with the Google Ads API enabled | ||
| - OAuth client credentials JSON (for ADC login) | ||
|
|
||
| --- | ||
|
|
||
| ## Step 1 — Create the Virtual Environment | ||
|
|
||
| From the repo root: | ||
|
|
||
| ```bash | ||
| /opt/homebrew/bin/python3.11 -m venv .venv | ||
| ``` | ||
|
|
||
| Then install the project into that environment: | ||
|
|
||
| ```bash | ||
| ./.venv/bin/pip install -e . | ||
| ``` | ||
|
|
||
| This installs the local entrypoint used by the repo: | ||
|
|
||
| ```bash | ||
| ./.venv/bin/python -c "import ads_mcp.server; print('ok')" | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Step 2 — Authenticate with Application Default Credentials | ||
|
|
||
| Use the local `gcloud` wrapper so credentials stay inside `.gcloud/` instead of your global `~/.config/gcloud`: | ||
|
|
||
| ```bash | ||
| ./gcloud-local.sh auth application-default login \ | ||
| --scopes https://www.googleapis.com/auth/adwords,https://www.googleapis.com/auth/cloud-platform \ | ||
| --client-id-file /absolute/path/to/your-oauth-client.json | ||
| ``` | ||
|
|
||
| When complete, the credentials file is at: | ||
|
|
||
| ``` | ||
| .gcloud/application_default_credentials.json | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Step 3 — Configure `.env.local` | ||
|
|
||
| Copy the template: | ||
|
|
||
| ```bash | ||
| cp .env.local.example .env.local | ||
| ``` | ||
|
|
||
| Fill in `.env.local`: | ||
|
|
||
| ```env | ||
| GOOGLE_PROJECT_ID=your-gcp-project-id | ||
| GOOGLE_ADS_DEVELOPER_TOKEN=your-developer-token | ||
| GOOGLE_APPLICATION_CREDENTIALS=/absolute/path/to/repo/.gcloud/application_default_credentials.json | ||
|
|
||
| # Required if your accounts are under an MCC (manager account). | ||
| # Set this to the top-level MCC ID, digits only, no hyphens. | ||
| # All data queries must still target a leaf client account ID — see Account Structure below. | ||
| GOOGLE_ADS_LOGIN_CUSTOMER_ID=5061122756 | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Step 4 — Start the Server | ||
|
|
||
| ```bash | ||
| ./run-local.sh | ||
| ``` | ||
|
|
||
| This loads `.env.local` and starts `.venv/bin/google-ads-mcp`. The process listens for MCP messages over stdio. It will appear to hang — that is normal. The server is waiting for a client to connect. | ||
|
|
||
| --- | ||
|
|
||
| ## Step 5 — Configure Claude Code (`.mcp.json`) | ||
|
|
||
| Create `.mcp.json` at the repo root. This file is gitignored because it contains absolute local paths. | ||
|
|
||
| ```json | ||
| { | ||
| "mcpServers": { | ||
| "google-ads-mcp": { | ||
| "command": "/absolute/path/to/repo/.venv/bin/google-ads-mcp", | ||
| "env": { | ||
| "GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/repo/.gcloud/application_default_credentials.json", | ||
| "GOOGLE_ADS_DEVELOPER_TOKEN": "your-developer-token", | ||
| "GOOGLE_ADS_LOGIN_CUSTOMER_ID": "5061122756" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Replace `/absolute/path/to/repo` with the actual path on your machine. | ||
|
|
||
| After creating this file, restart Claude Code. The MCP server starts automatically when Claude Code loads the project. | ||
|
|
||
| --- | ||
|
|
||
| ## Account Structure | ||
|
|
||
| The credential authenticates as a top-level MCC. Queries must target a **leaf client account** (a non-manager account inside the MCC): | ||
|
|
||
| - `GOOGLE_ADS_LOGIN_CUSTOMER_ID` = the top-level MCC ID (e.g. `5061122756`) | ||
| - `customer_id` passed to each tool = a leaf account ID (e.g. `1673268103`) | ||
| - IDs must be digits only — remove any hyphens | ||
|
|
||
| To list all leaf accounts under the MCC, use the `search` tool with: | ||
|
|
||
| ``` | ||
| resource: customer_client | ||
| fields: [ | ||
| "customer_client.client_customer", | ||
| "customer_client.descriptive_name", | ||
| "customer_client.level", | ||
| "customer_client.manager", | ||
| "customer_client.status" | ||
| ] | ||
| customer_id: 5061122756 | ||
| conditions: ["customer_client.level <= 2"] | ||
| ``` | ||
|
|
||
| Filter for rows where `customer_client.manager = false` — those are the queryable leaf accounts. | ||
|
|
||
| --- | ||
|
|
||
| ## Available MCP Tools | ||
|
|
||
| ### Built-in (generic) | ||
|
|
||
| | Tool | Description | | ||
| |---|---| | ||
| | `list_accessible_customers` | Returns top-level MCC IDs accessible by the credential | | ||
| | `get_resource_metadata` | Returns selectable/filterable/sortable fields for any GAQL resource | | ||
| | `search` | Runs any GAQL query against a valid resource | | ||
|
|
||
| ### Custom (curated) | ||
|
|
||
| | Tool | Description | | ||
| |---|---| | ||
| | `get_search_term_report` | Search terms that triggered ads — for negative keyword discovery. Inputs: `customer_id`, `start_date`, `end_date`, optional `campaign_id`, `ad_group_id`, `min_impressions`, `limit`. | | ||
|
|
||
| --- | ||
|
|
||
| ## Example: Run `get_search_term_report` | ||
|
|
||
| ```python | ||
| get_search_term_report( | ||
| customer_id="1635583349", # Stage_Haryanavi_2025 — digits only, no hyphens | ||
| start_date="2026-01-01", | ||
| end_date="2026-05-06", | ||
| min_impressions=10, | ||
| limit=200, | ||
| ) | ||
| ``` | ||
|
|
||
| Returns rows with: `search_term`, `status` (ADDED / EXCLUDED / NONE), `triggering_keyword`, `match_type`, `impressions`, `clicks`, `ctr`, `cost_micros`, `conversions`, `top_impression_pct`, `abs_top_impression_pct`. | ||
|
|
||
| `status = NONE` means the term is not yet added as a keyword or negative — these are the candidates to review for negative keyword additions. | ||
|
|
||
| --- | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| **`Missing .env.local`** | ||
|
|
||
| ```bash | ||
| cp .env.local.example .env.local | ||
| ``` | ||
|
|
||
| **`GOOGLE_ADS_DEVELOPER_TOKEN environment variable not set`** | ||
|
|
||
| Fill in `GOOGLE_ADS_DEVELOPER_TOKEN` in `.env.local`. | ||
|
|
||
| **`google-ads-mcp: command not found`** | ||
|
|
||
| ```bash | ||
| ./.venv/bin/pip install -e . | ||
| ``` | ||
|
|
||
| **`Metrics cannot be requested for a manager account`** | ||
|
|
||
| You passed an MCC ID as `customer_id`. Use a leaf (non-manager) client account ID instead. See Account Structure above. | ||
|
|
||
| **`User doesn't have permission to access customer`** | ||
|
|
||
| The `GOOGLE_ADS_LOGIN_CUSTOMER_ID` is set but the account you are querying is not under that MCC, or the MCC header is missing. Verify the hierarchy using `customer_client`. | ||
|
|
||
| **`The developer token is only approved for use with test accounts`** | ||
|
|
||
| Your token does not have production access. See the Google Ads access levels documentation. | ||
|
|
||
| **ADC or auth errors** | ||
|
|
||
| Re-run the login flow: | ||
|
|
||
| ```bash | ||
| ./gcloud-local.sh auth application-default login \ | ||
| --scopes https://www.googleapis.com/auth/adwords,https://www.googleapis.com/auth/cloud-platform \ | ||
| --client-id-file /absolute/path/to/your-oauth-client.json | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| ## Security Notes | ||
|
|
||
| - Do not commit `.env.local` — it contains real credentials | ||
| - Do not commit `.gcloud/` — it contains ADC tokens | ||
| - Do not commit `.mcp.json` — it contains absolute local paths and tokens | ||
| - If credentials were accidentally exposed, rotate them immediately in Google Cloud IAM |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really think you wanted to commit this. I recommend you reset your developer token as soon as possible.