get_network_competitors
Retrieve a list of competitors from your Metricool brand account for specified social networks and dates. Analyze insights to enhance brand strategies effectively.
Instructions
Get the list of your competitors from your Metricool brand account. Add interesting conclusions for my brand about my competitors.
Args: init date: Init date of the period to get the data. The format is YYYY-MM-DD end date: End date of the period to get the data. The format is YYYY-MM-DD network: Network to retrieve the competitors. The format is "twitter", "facebook", "instagram", "youtube", "twitch" and "bluesky". Only these are accepted. blog id: Blog id of the Metricool brand account. limit: Limit of competitors. By default = 10 timezone: Timezone of the post. The format is "Europe%2FMadrid". Use the timezone of the user extracted from the get_brands tool.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blog_id | Yes | ||
| end_date | Yes | ||
| init_date | Yes | ||
| limit | Yes | ||
| network | Yes | ||
| timezone | Yes |
Implementation Reference
- src/mcp_metricool/tools/tools.py:406-428 (handler)The handler function for the get_network_competitors tool. It uses the @mcp.tool() decorator, defines input parameters with type hints and detailed docstring, constructs the API URL using config constants, calls make_get_request helper, and returns the response or error message.@mcp.tool() async def get_network_competitors(network: str, init_date: str, end_date: str, blog_id: int, limit: int, timezone: str) -> str | dict[str, Any]: """ Get the list of your competitors from your Metricool brand account. Add interesting conclusions for my brand about my competitors. Args: init date: Init date of the period to get the data. The format is YYYY-MM-DD end date: End date of the period to get the data. The format is YYYY-MM-DD network: Network to retrieve the competitors. The format is "twitter", "facebook", "instagram", "youtube", "twitch" and "bluesky". Only these are accepted. blog id: Blog id of the Metricool brand account. limit: Limit of competitors. By default = 10 timezone: Timezone of the post. The format is "Europe%2FMadrid". Use the timezone of the user extracted from the get_brands tool. """ url = f"{METRICOOL_BASE_URL}/v2/analytics/competitors/{network}?from={init_date}T00%3A00%3A00&to={end_date}T23%3A59%3A59&blogId={blog_id}&userId={METRICOOL_USER_ID}&limit={limit}&timezone={timezone}&integrationSource=MCP" response = await make_get_request(url) if not response: return ("Failed to get competitors") return response
- src/mcp_metricool/tools/tools.py:16-18 (registration)Creation of the FastMCP server instance named 'metricool' to which all tools, including get_network_competitors, are registered via the @mcp.tool() decorator.# Initialize FastMCP server mcp = FastMCP("metricool")
- Helper function make_get_request used by the tool to perform authenticated HTTP GET requests to the Metricool API.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/config.py:4-6 (helper)Configuration constants used in the tool's API URL construction: base URL, user token for auth, and user ID.METRICOOL_BASE_URL = "https://app.metricool.com/api" METRICOOL_USER_TOKEN = os.getenv("METRICOOL_USER_TOKEN") METRICOOL_USER_ID = os.getenv("METRICOOL_USER_ID")