Skip to content

Google Analytics 4, Google Ads and Search Console: optional default property / customer ID / site per connector #1963

Backlog

Description

@AXILTIADIGITAL

Problem

One Google login often reaches many GA4 properties, Google Ads accounts and Search Console sites, for example at an agency with many clients. The connectors always expose all of them. Every GA4 tool needs property_id, most Google Ads tools need customer_id, and the Search Console tools need site_url. So every prompt has to name the right ID, or the model first calls ga4_get_account_summaries / gads_list_accessible_customers / gsc_list_sites and picks one from a long list.

That causes two problems:

  • Wrong client: it is easy for the model to query the wrong property.
  • No scoping: I can't hand a connector (or an MCP server built from it) to a colleague or a client and have it see only that client's data. The only limit is what the Google account can see.

Other GA4 / Google Ads / Search Console integrations let you choose the properties when you connect.

Proposed Solution

Add one optional, non-secret variable per connector that holds a comma-separated list of the properties, accounts or sites the connector may use:

Connector Variable Example
google-analytics-4 GA4_PROPERTY_IDS 385356434 or 385356434,412345678
google-ads GOOGLE_ADS_CUSTOMER_IDS 1234567890,9876543210 (10 digits, no dashes)
google-search-console GSC_SITE_URLS https://www.example.com/,sc-domain:example.org

How the value would work:

  • Empty (default): same as today. All properties, accounts or sites the Google user can see.
  • One ID: it is the default. Tools that take the ID make it optional and fill it in when the caller leaves it out (like the existing endpointMapping.envDefaults). A call with any other ID is refused with a clear error.
  • Several IDs: only these are allowed. The caller has to pass one of them, and a call outside the list is refused. The list tools (ga4_get_account_summaries, gads_list_accessible_customers, gads_list_client_accounts, gsc_list_sites) return only the allowed entries, so the model only ever picks from the user's selection.

Important: the check should run in the engine, before the call to Google, not only as a sentence in the instructions. Then the limit holds regardless of what the model does. An instructionFacts sentence ("This connector is limited to GA4 properties {{GA4_PROPERTY_IDS}}") would also tell the model up front which IDs it can use.

For Search Console I would keep the write tools (gsc_submit_sitemap, gsc_delete_sitemap, gsc_add_site, gsc_remove_site) requiring an explicit site_url even when a single site is set, so a write never goes to a site just because it is the default. They should still respect the allowlist.

Nice to have: after "Authorize with Provider", a multi-select on the connector page filled from accountSummaries / listAccessibleCustomers / sites.list, so the IDs don't have to be typed. Since the setting is a plain variable, the same OAuth grant could then be installed several times, once per client, each limited to that client's IDs.

Alternatives Considered

  • Connector instructions: put "always use property X" at the top. This works most of the time, but it is only a request to the model and doesn't limit anything.
  • A Claude project per client with the IDs in its instructions. This depends on the client, and Copilot and ChatGPT don't share it.
  • One install and MCP server per client: this needs a separate OAuth authorization for each install, and the connector still reaches every property.

Area

Connectors (REST, SOAP, GraphQL, Database, MCP Bridge)

Additional Context

Self-hosted v0.55.18 (Docker / Coolify). GA4, Google Ads and Search Console use the same OAuth client in one Google Cloud project, with Explorer access for the Ads API. The Google Ads login customer (GOOGLE_ADS_LOGIN_CUSTOMER_ID, the manager account) is a separate setting and stays as it is

Activity

  1. added
    enhancement
    on Dec 1, 2026
  2. changed the title [-]Google Analytics 4 and Google Ads: optional default property / customer ID per connector[/-] [+]Google Analytics 4, Google Ads and Search Console: optional default property / customer ID / site per connector[/+] on Dec 1, 2026
  3. AYUshJaiswal454 commented on Dec 1, 2026

    @AYUshJaiswal454
    Contributor

    Hi, after reading the description I'd like to work on this. I suggest a generic envAllowlist next to the existing envDefaults, checked in the engine before the call to Google. I'd also suggest splitting it into three separate PRs: GA4 first, then Ads and Search Console, then list filtering.

    @helpcodeai is a PR welcome for this, or are you planning to do it yourself? And does envAllowlist sound like the right approach?

  4. helpcodeai commented on Dec 2, 2026

    @helpcodeai
    Contributor

    Thanks for the detailed proposal, the agency case makes sense and a check in the engine before the call is the right place for it.

    @AYUshJaiswal454 thanks for offering. This changes the REST engine, so I want to look at the design first (a generic envAllowlist next to envDefaults, how the list tools get filtered, and how it behaves on Cloud and self-hosted). Please wait with the PR until I confirm the approach here. I'll come back in this issue.

  5. helpcodeai commented on Dec 2, 2026

    @helpcodeai
    Contributor

    @AYUshJaiswal454 the approach is fine, go ahead. A few points so the PRs stay small and easy to review:

    • A generic envAllowlist in endpointMapping, next to envDefaults: maps a parameter to a connector variable holding a comma-separated list. Empty or unset means today's behaviour.
    • The check runs in the REST engine before the request is sent, and a refused value gets a clear error that names the allowed values. One allowed value also works as the default when the caller leaves the parameter out.
    • Normalise before comparing where the API does (for example Google Ads ids without dashes), and match whole values only.
    • Same behaviour on Cloud and self-hosted.
    • Search Console write tools keep requiring an explicit site_url, as proposed above, and still respect the list.
    • Tests next to the engine spec, plus static checks in the adapter specs.

    Please start with the engine part and GA4 in the first PR, then Ads and Search Console, then filtering of the list tools. Thanks for picking this up.

  6. AXILTIADIGITAL commented on Dec 2, 2026

    @AXILTIADIGITAL
    Author

    @AYUshJaiswal454, @helpcodeai:

    Thanks for your reply! Please also keep this in mind for Google Merchant Center and, in the future, the Google Business Profile API. ;-)

  7. AYUshJaiswal454 commented on Dec 2, 2026

    @AYUshJaiswal454
    Contributor

    Thanks @helpcodeai, that's clear. I'll start with the first PR: the generic envAllowlist in the REST engine plus GA4, with tests next to the engine spec and static checks in the adapter spec.

    @AXILTIADIGITAL since envAllowlist is generic (any parameter mapped to a connector variable), Google Merchant Center and later the Business Profile API can use it too in a follow-up.

  8. AYUshJaiswal454 commented on Dec 6, 2026

    @AYUshJaiswal454
    Contributor

    #1972 and #1977 are merged, thanks for the quick reviews! Before the last PR (filtering the list tools), here is the design, since it touches the engine again:

    Rule: endpointMapping.envAllowlistResponse, next to envAllowlist:

    Tool Rule
    gsc_list_sites { "variable": "GSC_SITE_URLS", "items": "siteEntry", "key": "siteUrl" }
    gads_list_accessible_customers { "variable": "GOOGLE_ADS_CUSTOMER_IDS", "items": "resourceNames", "normalize": "digits" } (no key: the item itself, customers/1234567890 → 1234567890)
    gads_list_client_accounts { "variable": "GOOGLE_ADS_CUSTOMER_IDS", "items": "results", "key": "customerClient.id", "normalize": "digits" }
    ga4_get_account_summaries { "variable": "GA4_PROPERTY_IDS", "items": "accountSummaries[*].propertySummaries", "key": "property", "normalize": "digits", "dropEmptyParents": true }

    Behaviour

    • Empty or unset variable: the response is untouched, as today.
    • Items whose key is not in the list are removed, with the same whole-value match and digits normalisation as envAllowlist.
    • dropEmptyParents: for GA4, an account left with no allowed property is removed too, so other clients' account names don't leak.
    • Applied before responseMapping, on fresh answers and cache hits (the cache holds the raw body, so a changed list applies at once), and in the "Run test" path.
    • Pagination tokens are kept, so a page can come back shorter or empty.
    • The validator checks that the variable is declared and not secret, that normalize is known and that items/key are non-empty paths.

    Questions

    1. Should the call log keep the full upstream body (like responseMapping does) or the filtered one?
    2. Is endpointMapping the right place, rather than responseMapping? I'd keep it in endpointMapping because responseMapping can be customised per workspace and preserved on resync, and this is a limit, not shaping.

    If this looks right I'll open the PR with tests, and it will close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions