get_social_dominance
Retrieve the percentage of crypto media discussions dominated by a specific cryptocurrency over a set number of days. Use this tool to analyze an asset's social influence and market attention.
Instructions
Retrieve the social dominance (social_dominance_total) for a given asset. Social Dominance shows the share of the discussions in crypto media that is referring to a particular asset or phrase.
Parameters:
asset (str): The cryptocurrency slug (e.g., "bitcoin", "ethereum"). Required.
days (int): Number of days to calculate average social dominance, defaults to 7.
Usage:
Call this tool to get the percentage of social media discussion dominated by the asset.
Returns:
A string with the average social dominance (e.g., "Bitcoin's social dominance over the past 7 days is 25.3%").
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| asset | Yes | ||
| days | No |
Implementation Reference
- main.py:192-215 (handler)The handler function decorated with @mcp.tool(), implementing the get_social_dominance tool. It fetches social dominance data from Santiment API using fetch_santiment_data, computes the average over the specified days, and returns a formatted string.@mcp.tool() def get_social_dominance(asset: str, days: int = 7) -> str: """ Retrieve the social dominance (social_dominance_total) for a given asset. Social Dominance shows the share of the discussions in crypto media that is referring to a particular asset or phrase. Parameters: - asset (str): The cryptocurrency slug (e.g., "bitcoin", "ethereum"). Required. - days (int): Number of days to calculate average social dominance, defaults to 7. Usage: - Call this tool to get the percentage of social media discussion dominated by the asset. Returns: - A string with the average social dominance (e.g., "Bitcoin's social dominance over the past 7 days is 25.3%"). """ try: data = fetch_santiment_data("social_dominance_total", asset, days) timeseries = data.get("data", {}).get("getMetric", {}).get("timeseriesData", []) if not timeseries: return f"Unable to fetch social dominance for {asset}. Check subscription limits or asset availability." avg_dominance = sum(float(d["value"]) for d in timeseries) / len(timeseries) return f"{asset.capitalize()}'s social dominance over the past {days} days is {avg_dominance:.1f}%." except Exception as e: return f"Error fetching social dominance for {asset}: {str(e)}"
- main.py:16-42 (helper)Helper function to fetch timeseries data from Santiment GraphQL API for a given metric and asset over a number of days. Used by get_social_dominance and other tools.def fetch_santiment_data(metric: str, asset: str, days: int) -> dict: now = datetime.now(UTC) to_date = now from_date = to_date - timedelta(days=days) query = f""" {{ getMetric(metric: "{metric}") {{ timeseriesData( slug: "{asset}" from: "{from_date.isoformat()}" to: "{to_date.isoformat()}" interval: "1d" ) {{ datetime value }} }} }} """ response = requests.post(SANTIMENT_API_URL, json={"query": query}, headers=HEADERS) result = response.json() if result.get("errors"): raise Exception(f"API error: {result.get('errors')}") return result
- main.py:192-192 (registration)The @mcp.tool() decorator registers the get_social_dominance function as an MCP tool.@mcp.tool()