Skip to main content
Glama

get_symbol_sentiment

Analyze recent news sentiment for financial symbols to assess market perception and inform trading decisions.

Instructions

Fetches recent news for a symbol and calculates aggregate sentiment.

Args:
    symbol: Ticker symbol.

Returns:
    Aggregate sentiment analysis of recent news.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'get_symbol_sentiment' tool. It fetches the latest 10 news articles for the given symbol using yfinance, analyzes the sentiment of each title using the 'analyze_sentiment' helper, computes the average polarity score, classifies as BULLISH/BEARISH/NEUTRAL, and returns a formatted string summary.
    def get_symbol_sentiment(symbol: str) -> str:
        """
        Fetches recent news for a symbol and calculates aggregate sentiment.
        
        Args:
            symbol: Ticker symbol.
        
        Returns:
            Aggregate sentiment analysis of recent news.
        """
        try:
            ticker = yf.Ticker(symbol)
            news = ticker.news[:10]  # Last 10 articles
            
            if not news:
                return f"No news found for {symbol}"
            
            sentiments = []
            model_used = "Unknown"
            
            for item in news:
                title = item.get("title", "")
                if title:
                    result = analyze_sentiment(title)
                    if "polarity" in result:
                        sentiments.append(result["polarity"])
                        model_used = result.get("model", "Unknown")
            
            if not sentiments:
                return f"No valid news titles for {symbol}"
            
            avg_polarity = sum(sentiments) / len(sentiments)
            
            if avg_polarity > 0.1:
                classification = "BULLISH"
            elif avg_polarity < -0.1:
                classification = "BEARISH"
            else:
                classification = "NEUTRAL"
            
            return (f"Sentiment Analysis for {symbol} ({len(sentiments)} articles):\n"
                    f"Average Polarity: {avg_polarity:.3f}\n"
                    f"Market Sentiment: {classification}\n"
                    f"Model: {model_used}")
            
        except Exception as e:
            return f"Error analyzing sentiment for {symbol}: {str(e)}"
  • server.py:405-408 (registration)
    Registration of the 'get_symbol_sentiment' tool (along with related news tools) using the 'register_tools' helper function, which applies the @mcp.tool() decorator to make it available in the MCP server.
    register_tools(
        [get_news, analyze_sentiment, get_symbol_sentiment],
        "News & Sentiment"
    )
  • Import statement that brings the 'get_symbol_sentiment' function into the server.py scope for registration.
    from tools.news_intelligence import get_news, analyze_sentiment, get_symbol_sentiment
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. It mentions fetching news and calculating sentiment but lacks details on behavioral traits like rate limits, data sources, time frames for 'recent', error handling, or authentication needs. This leaves significant gaps for a tool that performs analysis.

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

Conciseness4/5

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

The description is concise and well-structured with three sentences: purpose, args, and returns. Each sentence serves a clear function, and there's no wasted text, though it could be slightly more detailed without losing efficiency.

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 the tool's complexity (fetching and analyzing news), no annotations, and an output schema that likely covers return values, the description is minimally complete. It states what the tool does but lacks depth on behavior, usage, or integration with siblings, making it adequate but with clear gaps.

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

Parameters3/5

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

The description adds minimal semantics beyond the input schema: it specifies that 'symbol' is a 'ticker symbol', which the schema only labels as 'Symbol'. However, with 0% schema description coverage and only one parameter, this is adequate but not comprehensive, aligning with the baseline for low coverage without full compensation.

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 with a specific verb ('fetches') and resource ('recent news for a symbol'), and it adds the action of calculating aggregate sentiment. However, it doesn't explicitly differentiate from sibling tools like 'get_news' or 'analyze_sentiment', which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives such as 'get_news' (which fetches news without sentiment) or 'analyze_sentiment' (which might analyze sentiment without fetching news). There's no mention of prerequisites, context, or exclusions.

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/N-lia/MonteWalk'

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