get_account_summaries
Fetches a summary of all Google Analytics accounts and their associated properties.
Instructions
Retrieves information about the user's Google Analytics accounts and properties.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- analytics_mcp/tools/admin/info.py:31-38 (handler)Core handler for get_account_summaries. Calls the Google Analytics Admin API list_account_summaries() via create_admin_api_client(), converts each proto response to dict using proto_to_dict, and runs the synchronous API call in a thread via asyncio.to_thread.
async def get_account_summaries() -> List[Dict[str, Any]]: """Retrieves information about the user's Google Analytics accounts and properties.""" def _sync_call(): summary_pager = create_admin_api_client().list_account_summaries() return [proto_to_dict(summary_page) for summary_page in summary_pager] return await asyncio.to_thread(_sync_call) - analytics_mcp/coordinator.py:66-75 (registration)Registration of get_account_summaries as an ADK FunctionTool, added to the tools list which is then converted to MCP tools and exposed via the MCP server.
tools = [ FunctionTool(get_account_summaries), FunctionTool(list_google_ads_links), FunctionTool(get_property_details), FunctionTool(list_property_annotations), FunctionTool(get_custom_dimensions_and_metrics), run_report_with_description, run_realtime_report_with_description, run_funnel_report_with_description, ] - analytics_mcp/tools/client.py:65-70 (helper)Helper that creates the Admin API client used by get_account_summaries to call list_account_summaries.
def create_admin_api_client() -> admin_v1beta.AnalyticsAdminServiceClient: """Returns the Google Analytics Admin API client.""" with _client_lock: return admin_v1beta.AnalyticsAdminServiceClient( client_info=_CLIENT_INFO, credentials=_get_credentials() ) - analytics_mcp/tools/utils.py:47-51 (helper)Helper utility used to convert the proto response from list_account_summaries into a dictionary.
def proto_to_dict(obj: proto.Message) -> Dict[str, Any]: """Converts a proto message to a dictionary.""" return type(obj).to_dict( obj, use_integers_for_enums=False, preserving_proto_field_name=True ) - No input parameters (schema is an empty object). Returns a list of dicts containing account/property summaries.
async def get_account_summaries() -> List[Dict[str, Any]]: """Retrieves information about the user's Google Analytics accounts and properties.""" def _sync_call(): summary_pager = create_admin_api_client().list_account_summaries() return [proto_to_dict(summary_page) for summary_page in summary_pager] return await asyncio.to_thread(_sync_call)