Skip to main content
Glama

compute_indicators

Calculate technical indicators like RSI, MACD, and BBANDS for financial symbols to support trading strategy analysis and portfolio management.

Instructions

Calculates technical indicators for a symbol.

Args:
    symbol: Ticker symbol.
    indicators: List of indicators (e.g., ['RSI', 'MACD', 'BBANDS']).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes
indicatorsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler function implementing the compute_indicators tool. Downloads 1 year of historical data for the given symbol using yfinance, computes the specified technical indicators (RSI, MACD, Bollinger Bands) using pandas_ta, handles data structure issues, and returns the last 10 rows of results as JSON string.
    def compute_indicators(symbol: str, indicators: List[str] = ["RSI", "MACD"]) -> str:
        """
        Calculates technical indicators for a symbol.
        
        Args:
            symbol: Ticker symbol.
            indicators: List of indicators (e.g., ['RSI', 'MACD', 'BBANDS']).
        """
        df = yf.download(symbol, period="1y", progress=False)
        if df.empty:
            return f"No data for {symbol}"
        
        # Handle MultiIndex
        if isinstance(df.columns, pd.MultiIndex):
            df.columns = df.columns.get_level_values(0)
            
        result = df[['Close']].copy()
        
        for ind in indicators:
            try:
                if ind.upper() == "RSI":
                    result['RSI'] = ta.rsi(df['Close'])
                elif ind.upper() == "MACD":
                    macd = ta.macd(df['Close'])
                    result = pd.concat([result, macd], axis=1)
                elif ind.upper() == "BBANDS":
                    bb = ta.bbands(df['Close'])
                    result = pd.concat([result, bb], axis=1)
                # Add more as needed
            except Exception as e:
                return f"Error computing {ind}: {str(e)}"
                
        return result.tail(10).to_json(orient="index")
  • server.py:390-393 (registration)
    Registration of the compute_indicators tool (along with related functions) as part of the 'Feature Engineering' category in the MCP server using the register_tools helper function, which applies @mcp.tool() decorator to each.
    register_tools(
        [compute_indicators, rolling_stats, get_technical_summary],
        "Feature Engineering"
    )
  • The register_tools helper function that dynamically registers imported tools like compute_indicators by applying the MCP @mcp.tool() decorator in a loop with logging.
    def register_tools(tools: List[Callable], category: str):
        """Helper to register multiple tools with logging."""
        for tool in tools:
            try:
                mcp.tool()(tool)
                logger.info(f"Registered {category} tool: {tool.__name__}")
            except Exception as e:
                logger.error(f"Failed to register {tool.__name__}: {e}")
                raise
  • app.py:291-291 (registration)
    compute_indicators is included in the 'Technical Analysis' tool category for the Gradio UI toolbox (non-MCP usage).
    "Technical Analysis": [compute_indicators, rolling_stats, get_technical_summary],
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but offers minimal information. It mentions what the tool does but doesn't describe how it behaves—no details about data sources, timeframes, rate limits, error conditions, or what the calculation entails. For a tool with computational output, this leaves significant gaps in understanding its operational characteristics.

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 appropriately concise with a clear purpose statement followed by parameter explanations in a structured format. Every sentence serves a purpose, though the parameter section could be slightly more detailed given the schema's limitations.

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 (calculating technical indicators with 2 parameters), no annotations, and an output schema present, the description is minimally adequate but incomplete. It covers the basic purpose and parameters but lacks behavioral context and usage guidance. The output schema reduces the need to describe return values, but more operational details would improve completeness.

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 some semantic context by explaining that 'symbol' is a 'Ticker symbol' and 'indicators' is a 'List of indicators' with examples, which provides meaning beyond the bare schema (which has 0% description coverage). However, it doesn't fully compensate for the schema's lack of descriptions—for instance, it doesn't specify valid indicator names beyond examples or explain parameter interactions.

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 ('Calculates') and resource ('technical indicators for a symbol'), making it immediately understandable. However, it doesn't distinguish this tool from potential sibling tools that might also calculate indicators, such as 'get_technical_summary' which appears in the sibling list.

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 like 'get_technical_summary' or other analysis tools in the sibling list. There's no mention of prerequisites, context, or exclusions that would help an agent choose between similar tools.

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