1818
1919from analytics_mcp .coordinator import mcp
2020from analytics_mcp .tools .utils import (
21+ construct_property_rn ,
2122 create_admin_api_client ,
2223 proto_to_dict ,
2324)
@@ -38,15 +39,16 @@ async def get_account_summaries() -> List[Dict[str, Any]]:
3839
3940
4041@mcp .tool (title = "List links to Google Ads accounts" )
41- async def list_google_ads_links (property_id : str ) -> List [Dict [str , Any ]]:
42+ async def list_google_ads_links (property_id : int | str ) -> List [Dict [str , Any ]]:
4243 """Returns a list of links to Google Ads accounts for a property.
4344
4445 Args:
45- property_id: The ID of the property.
46+ property_id: The Google Analytics property ID. Accepted formats are:
47+ - A number
48+ - A string consisting of 'properties/' followed by a number
4649 """
47- property_resource_name = f"properties/{ property_id } "
4850 request = admin_v1beta .ListGoogleAdsLinksRequest (
49- parent = property_resource_name
51+ parent = construct_property_rn ( property_id )
5052 )
5153 # Uses an async list comprehension so the pager returned by
5254 # list_google_ads_links retrieves all pages.
@@ -58,13 +60,16 @@ async def list_google_ads_links(property_id: str) -> List[Dict[str, Any]]:
5860
5961
6062@mcp .tool (title = "Gets details about a property" )
61- def get_property_details (property_id : str ) -> Dict [str , Any ]:
63+ def get_property_details (property_id : int | str ) -> Dict [str , Any ]:
6264 """Returns details about a property.
6365 Args:
64- property_id: The ID of the property.
66+ property_id: The Google Analytics property ID. Accepted formats are:
67+ - A number
68+ - A string consisting of 'properties/' followed by a number
6569 """
6670 client = admin_v1beta .AnalyticsAdminServiceClient ()
67- property_resource_name = f"properties/{ property_id } "
68- request = admin_v1beta .GetPropertyRequest (name = property_resource_name )
71+ request = admin_v1beta .GetPropertyRequest (
72+ name = construct_property_rn (property_id )
73+ )
6974 response = client .get_property (request = request )
7075 return proto_to_dict (response )
0 commit comments