feat: add batch_run_reports tool - #172
Open
Avicennasis wants to merge 8 commits into
Open
Conversation
Avicennasis
force-pushed
the
feat/batch-run-reports
branch
from
June 11, 2026 16:11
f73dfe5 to
3afb237
Compare
Audience exports (Data API v1beta, analytics.readonly-compatible): create_audience_export starts the async export job and returns the operation metadata for polling; get/list/query retrieve state and user rows. Measurement Protocol (plain HTTP, write-capable): validate_event hits only the debug endpoint and never records data. send_event is guarded for AI callers — the API secret comes solely from the ANALYTICS_MCP_MP_API_SECRET env var, dry-run validation is the default, recording requires an explicit confirm=True, and even confirmed sends abort if validation fails.
Fixes from a stargazer review of the server: - coordinator: call_mcp_tool now returns CallToolResult(content=[...], isError=True) on both failure paths (tool raised, and tool-not-found) instead of a plain TextContent that MCP clients read as a *successful* response. This is the one genuinely client-observable fix — clients can now detect failures programmatically. [FR-179] - coordinator: drop the unused `from json import tool` import, which bound `tool` to the json.tool CLI module only for it to be shadowed by later `for tool in ...` loops. [FR-173] - client: `except:` -> `except Exception:` in the package-version fallback so Ctrl-C / SystemExit are no longer swallowed into "unknown". [FR-175] - reporting (core, realtime, audience_exports, conversions): replace truthy `if limit:` / `if offset:` / `if currency_code:` guards with `is not None`. NOTE: these RunReportRequest fields are proto3 scalars with no field presence, so offset=0 / limit=0 serialize identically to unset — this is a correctness/consistency cleanup and a guard against presence-aware fields, NOT a behavior change today (verified by comparing serialized requests). [FR-170, FR-171, FR-172, FR-181] Verified: black --check clean; existing suite (19 tests) green; ad-hoc harness confirms isError=True on both failure paths, the success path still returns list[Content], and offset/limit=0 requests are wire-identical to unset.
Avicennasis
force-pushed
the
feat/batch-run-reports
branch
from
August 19, 2026 17:20
3afb237 to
6d7ea57
Compare
Rebuilt on top of current main rather than rebased — the original branch's coordinator.py hunk conflicted through an unterminated import statement, so a union merge produced nested open imports. Reapplied the branch's actual additions (imports, three FunctionTool wrappers, three registry entries, three inputSchema clauses) at the correct anchors in main's current file. pivot.py, compatibility.py and their tests are unchanged from the original branch.
Reapplied onto main after #4 (pivot tools) merged — that touched the same coordinator.py registry, so this branch conflicted again. Same four additions at the same anchors; verified the pivot registrations from #4 are still intact (6 references) rather than clobbered. batch_test.py uses asyncio.run() to match the repo's other tests, and black --check -l 80 is clean across all 27 files.
Avicennasis
force-pushed
the
feat/batch-run-reports
branch
from
August 19, 2026 17:59
95447fe to
760f880
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a new
batch_run_reportstool that wraps the Data API v1betabatchRunReportsendpoint, allowing up to 5 reports to be run in a single API call.run_reporttool (dimensions, metrics, date_ranges, filters, order_bys, limit, offset, currency_code, return_property_quota)run_report's formatUse case
When an LLM needs data from multiple reports for the same property (e.g. building a dashboard, comparing metrics across dimensions), this reduces latency vs. calling
run_reportsequentially. The API processes all reports server-side in a single round trip.Files changed
analytics_mcp/tools/reporting/batch.py_build_report_requesthelperanalytics_mcp/coordinator.pytests/batch_test.pyTest plan
nox -s lintpasses (black, 80-char line width)nox -s testspasses — 17 tests total (6 existing + 11 new)