Skip to main content
Glama

get_sentiment_balance

Analyze cryptocurrency sentiment balance by calculating positive minus negative sentiment scores for specific assets over a defined period.

Instructions

Retrieve the sentiment balance (sentiment_balance_total) for a given asset.

Parameters:

  • asset (str): The cryptocurrency slug (e.g., "bitcoin", "ethereum"). Required.

  • days (int): Number of days to calculate the average sentiment balance, defaults to 7.

Usage:

  • Use this tool to get the average sentiment balance (positive minus negative sentiment) over a period.

Returns:

  • A string with the average sentiment balance (e.g., "Bitcoin's sentiment balance over the past 7 days is 12.5").

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
assetYes
daysNo

Implementation Reference

  • main.py:66-89 (handler)
    The handler function for the 'get_sentiment_balance' tool, registered via @mcp.tool() decorator. It fetches sentiment_balance_total data from Santiment API using the helper function, computes the average over the specified days, and returns a formatted string.
    @mcp.tool()
    def get_sentiment_balance(asset: str, days: int = 7) -> str:
        """
        Retrieve the sentiment balance (sentiment_balance_total) for a given asset.
        
        Parameters:
        - asset (str): The cryptocurrency slug (e.g., "bitcoin", "ethereum"). Required.
        - days (int): Number of days to calculate the average sentiment balance, defaults to 7.
        
        Usage:
        - Use this tool to get the average sentiment balance (positive minus negative sentiment) over a period.
        
        Returns:
        - A string with the average sentiment balance (e.g., "Bitcoin's sentiment balance over the past 7 days is 12.5").
        """
        try:
            data = fetch_santiment_data("sentiment_balance_total", asset, days)
            timeseries = data.get("data", {}).get("getMetric", {}).get("timeseriesData", [])
            if not timeseries:
                return f"Unable to fetch sentiment data for {asset}. Check subscription limits or asset availability."
            avg_balance = sum(float(d["value"]) for d in timeseries) / len(timeseries)
            return f"{asset.capitalize()}'s sentiment balance over the past {days} days is {avg_balance:.1f}."
        except Exception as e:
            return f"Error fetching sentiment balance for {asset}: {str(e)}"
  • main.py:16-42 (helper)
    Helper utility function to query Santiment GraphQL API for timeseries data of a specific metric (e.g., sentiment_balance_total) for an asset over a number of days. Used by get_sentiment_balance 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
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool retrieves data and describes the return format, but lacks details on permissions, rate limits, error handling, or whether it's a read-only operation. For a data retrieval tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured and appropriately sized, with clear sections for purpose, parameters, usage, and returns. Every sentence adds value without redundancy, and it's front-loaded with the core function. There's no wasted text, making it efficient for an agent to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 2 parameters with 0% schema coverage and no output schema, the description does a decent job by explaining parameters and the return format. However, it lacks details on behavioral aspects like authentication or limits, and doesn't fully address sibling tool differentiation. For a simple retrieval tool, it's adequate but has clear gaps in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaningful semantics: it explains that 'asset' is a 'cryptocurrency slug' with examples, and 'days' is for 'calculating the average sentiment balance' with a default. This clarifies beyond the bare schema, though it could provide more context on valid asset values or day ranges.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Retrieve the sentiment balance (sentiment_balance_total) for a given asset.' It specifies the verb ('retrieve') and resource ('sentiment balance'), making the function unambiguous. However, it doesn't explicitly differentiate from sibling tools like get_social_dominance or get_social_volume, which likely retrieve different social metrics for assets.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description includes a 'Usage' section that says 'Use this tool to get the average sentiment balance (positive minus negative sentiment) over a period,' which implies when to use it. However, it doesn't provide explicit guidance on when to choose this tool over alternatives (e.g., get_social_dominance for dominance metrics) or any exclusions, leaving usage context somewhat implied rather than fully articulated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kukapay/crypto-sentiment-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server