get_brands
Retrieve a comprehensive list of brands linked to your Metricool account for streamlined account management and analysis.
Instructions
Get the list of brands from your Metricool account.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_brands"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp_metricool/tools/tools.py:20-42 (handler)The core handler function for the 'get_brands' tool, decorated with @mcp.tool() for automatic registration in FastMCP. It retrieves the list of brands from the Metricool API, simplifies the data (label, id, userId, networks, timezone), and returns it as a list of dictionaries.
@mcp.tool() async def get_brands() -> list[dict[str, Any]]: """ Get the list of brands from your Metricool account. """ url = f"{METRICOOL_BASE_URL}/v2/settings/brands?userId={METRICOOL_USER_ID}&integrationSource=MCP" response = await make_get_request(url) if not response: return ("Failed to get brands") result = [] dicts = response["data"] for item in dicts: simplified = { "label": item.get("label"), "id": item.get("id"), "userId": item.get("userId"), "networks": item.get("networksData"), "timezone": item.get("timezone") } result.append(simplified) return result - Supporting utility function 'make_get_request' called by get_brands to perform authenticated HTTP GET requests to the Metricool API, handling errors and returning JSON or None.
async def make_get_request(url: str) -> dict[str, Any] | None: """Make a get request to the Metricool API with proper error handling.""" headers = { "X-Mc-Auth": METRICOOL_USER_TOKEN, } async with httpx.AsyncClient() as client: try: response = await client.get(url, headers=headers, timeout=30.0) response.raise_for_status() return response.json() except Exception: return None - src/mcp_metricool/server.py:1-7 (registration)Registers and runs the MCP server by importing the tools module (which defines and decorates the tools) and calling mcp.run(), making the get_brands tool available via stdio transport.
from .tools import tools mcp = tools.mcp if __name__ == "__main__": # Initialize and run the server mcp.run(transport='stdio') - Alternative helper tool 'get_brands_complete' that returns full API response with additional instructions, but documentation instructs to prefer 'get_brands'.
@mcp.tool() async def get_brands_complete() -> str | dict[str, Any]: """ Get the list of brands from your Metricool account. Only use this tool if the user asks specifically for his brands, in every other case use get_brands. Add to the result that the only networks with competitors are Instagram, Facebook, Twitch, YouTube, Twitter, and Bluesky. """ url = f"{METRICOOL_BASE_URL}/v2/settings/brands?userId={METRICOOL_USER_ID}&integrationSource=MCP" response = await make_get_request(url) if not response: return ("Failed to get brands") return { "brands": response, "instructions": ( "Explain that only Instagram, Facebook, Twitch, YouTube, Twitter, and Bluesky support competitors. " ) }