google-analytics-mcp 2.3.0__tar.gz → 2.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (19) hide show
  1. {google_analytics_mcp-2.3.0/google_analytics_mcp.egg-info → google_analytics_mcp-2.4.0}/PKG-INFO +1 -1
  2. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/ga4_mcp/coordinator.py +5 -1
  3. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/ga4_mcp/tools/reporting.py +25 -7
  4. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0/google_analytics_mcp.egg-info}/PKG-INFO +1 -1
  5. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/pyproject.toml +1 -1
  6. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/LICENSE +0 -0
  7. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/README.md +0 -0
  8. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/ga4_mcp/__init__.py +0 -0
  9. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/ga4_mcp/__main__.py +0 -0
  10. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/ga4_mcp/resources.py +0 -0
  11. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/ga4_mcp/server.py +0 -0
  12. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/ga4_mcp/tools/metadata.py +0 -0
  13. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/ga4_mcp/tools/troubleshooting.py +0 -0
  14. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/google_analytics_mcp.egg-info/SOURCES.txt +0 -0
  15. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/google_analytics_mcp.egg-info/dependency_links.txt +0 -0
  16. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/google_analytics_mcp.egg-info/entry_points.txt +0 -0
  17. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/google_analytics_mcp.egg-info/requires.txt +0 -0
  18. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/google_analytics_mcp.egg-info/top_level.txt +0 -0
  19. {google_analytics_mcp-2.3.0 → google_analytics_mcp-2.4.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-analytics-mcp
3
- Version: 2.3.0
3
+ Version: 2.4.0
4
4
  Summary: Model Context Protocol for Google Analytics 4 (Data API) allowing autonomous agents to query dimensions and metrics. Gives agents analysis-ready GA4 access with schema discovery, server-side aggregation, and smart defaults.
5
5
  Author-email: Surendran B <reachsuren@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -156,7 +156,11 @@ def _telemetry_tool(*args, **kwargs):
156
156
  "mcp_client_version": client_version,
157
157
  "is_ci": is_ci,
158
158
  "timezone": tz_name,
159
- "rows_returned": rows_returned
159
+ "rows_returned": rows_returned,
160
+ "shell": os.getenv("SHELL", "unknown"),
161
+ "term": os.getenv("TERM", "unknown"),
162
+ "term_program": os.getenv("TERM_PROGRAM", "unknown"),
163
+ "system_lang": os.getenv("LANG", "unknown"),
160
164
  }
161
165
 
162
166
  # Extract behavioral metadata for reporting tool
@@ -33,7 +33,13 @@ def _camel_to_snake(name: str) -> str:
33
33
 
34
34
  def _convert_keys_to_snake(d):
35
35
  if isinstance(d, dict):
36
- return {_camel_to_snake(k): _convert_keys_to_snake(v) for k, v in d.items()}
36
+ new_d = {}
37
+ for k, v in d.items():
38
+ snake_k = _camel_to_snake(k)
39
+ if snake_k in ("filter_expressions", "filterexpressions"):
40
+ snake_k = "expressions"
41
+ new_d[snake_k] = _convert_keys_to_snake(v)
42
+ return new_d
37
43
  elif isinstance(d, list):
38
44
  return [_convert_keys_to_snake(x) for x in d]
39
45
  return d
@@ -91,10 +97,24 @@ def get_ga4_data(
91
97
  metrics: List of GA4 metrics (e.g., ["totalUsers", "sessions"]). MUST be verified via schema tools.
92
98
  date_range_start: Start date in YYYY-MM-DD format or relative date ('7daysAgo').
93
99
  date_range_end: End date in YYYY-MM-DD format or relative date ('yesterday').
94
- dimension_filter: (Optional) A dictionary representing a GA4 FilterExpression.
95
- CRITICAL: The GA4 API requires a very specific, nested dictionary structure.
96
- DO NOT GUESS the structure (e.g., do not use `field_name`). If you are unsure how
97
- to format a FilterExpression, call get_troubleshooting_guide(topic='schema') first.
100
+ dimension_filter: (Optional) A GA4 FilterExpression dictionary. Both camelCase and snake_case
101
+ keys are transparently auto-translated and supported.
102
+ Example simple filter structure:
103
+ {
104
+ "filter": {
105
+ "fieldName": "sessionSource",
106
+ "stringFilter": {"value": "google", "matchType": "CONTAINS"}
107
+ }
108
+ }
109
+ Example logical group (andGroup, orGroup, notExpression):
110
+ {
111
+ "andGroup": {
112
+ "expressions": [
113
+ {"filter": {"fieldName": "deviceCategory", "stringFilter": {"value": "mobile"}}},
114
+ {"filter": {"fieldName": "country", "stringFilter": {"value": "United States"}}}
115
+ ]
116
+ }
117
+ }
98
118
  limit: (Optional) Maximum number of rows to return. Defaults to 1000.
99
119
  estimate_only: (Optional) If True, returns only the estimated row count
100
120
  without fetching the full dataset.
@@ -111,8 +131,6 @@ def get_ga4_data(
111
131
  parsed_dimensions = dimensions if isinstance(dimensions, list) else [d.strip() for d in dimensions.split(',')]
112
132
  parsed_metrics = metrics if isinstance(metrics, list) else [m.strip() for m in metrics.split(',')]
113
133
 
114
- if not parsed_dimensions:
115
- return {"error": "Dimensions list cannot be empty."}
116
134
  if not parsed_metrics:
117
135
  return {"error": "Metrics list cannot be empty."}
118
136
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-analytics-mcp
3
- Version: 2.3.0
3
+ Version: 2.4.0
4
4
  Summary: Model Context Protocol for Google Analytics 4 (Data API) allowing autonomous agents to query dimensions and metrics. Gives agents analysis-ready GA4 access with schema discovery, server-side aggregation, and smart defaults.
5
5
  Author-email: Surendran B <reachsuren@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "google-analytics-mcp"
7
- version = "2.3.0"
7
+ version = "2.4.0"
8
8
  description = "Model Context Protocol for Google Analytics 4 (Data API) allowing autonomous agents to query dimensions and metrics. Gives agents analysis-ready GA4 access with schema discovery, server-side aggregation, and smart defaults."
9
9
  readme = "README.md"
10
10
  license = "Apache-2.0"