Skip to main content
Glama
maxscheijen

MCP Yahoo Finance

by maxscheijen

get_dividends

Retrieve dividend data for a specific stock symbol using the MCP Yahoo Finance server. Input the stock symbol to access accurate dividend payout information for analysis or decision-making.

Instructions

Get dividends for a given stock symbol.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesStock symbol in Yahoo Finance format.

Implementation Reference

  • The primary handler function that executes the get_dividends tool logic: fetches dividends data using yfinance.Ticker(symbol).dividends and returns formatted JSON.
    def get_dividends(self, symbol: str) -> str:
        """Get dividends for a given stock symbol.
    
        Args:
            symbol (str): Stock symbol in Yahoo Finance format.
        """
        stock = Ticker(ticker=symbol, session=self.session)
        dividends = stock.dividends
    
        if hasattr(dividends.index, "date"):
            dividends.index = dividends.index.date.astype(str)  # type: ignore
        return f"{dividends.to_json(orient='index')}"
  • Registers the get_dividends tool in the server's list_tools() method by wrapping the handler with generate_tool.
    generate_tool(yf.get_dividends),
  • Handles tool invocation dispatch for 'get_dividends' in the server's call_tool() method, calling the handler with arguments.
    case "get_dividends":
        price = yf.get_dividends(**args)
        return [TextContent(type="text", text=price)]
  • Generates the input schema for get_dividends (and other tools) from function signature, annotations, and docstring.
    def generate_tool(func: Any) -> Tool:
        """Generates a tool schema from a Python function."""
        signature = inspect.signature(func)
        docstring = inspect.getdoc(func) or ""
        param_descriptions = parse_docstring(docstring)
    
        schema = {
            "name": func.__name__,
            "description": docstring.split("Args:")[0].strip(),
            "inputSchema": {
                "type": "object",
                "properties": {},
            },
        }
    
        for param_name, param in signature.parameters.items():
            param_type = (
                "number"
                if param.annotation is float
                else "string"
                if param.annotation is str
                else "string"
            )
            schema["inputSchema"]["properties"][param_name] = {
                "type": param_type,
                "description": param_descriptions.get(param_name, ""),
            }
    
            if "required" not in schema["inputSchema"]:
                schema["inputSchema"]["required"] = [param_name]
            else:
                if "=" not in str(param):
                    schema["inputSchema"]["required"].append(param_name)
    
        return Tool(**schema)
  • Helper function used by generate_tool to parse docstring for parameter descriptions in the schema.
    def parse_docstring(docstring: str) -> dict[str, str]:
        """Parses a Google-style docstring to extract parameter descriptions."""
        descriptions = {}
        if not docstring:
            return descriptions
    
        lines = docstring.split("\n")
        current_param = None
    
        for line in lines:
            line = line.strip()
            if line.startswith("Args:"):
                continue
            elif line and "(" in line and ")" in line and ":" in line:
                param = line.split("(")[0].strip()
                desc = line.split("):")[1].strip()
                descriptions[param] = desc
                current_param = param
            elif current_param and line:
                descriptions[current_param] += " " + line.strip()
    
        return descriptions
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 does not mention if this is a read-only operation, potential rate limits, authentication needs, error handling, or the format of returned data. This leaves significant gaps in understanding how the tool behaves beyond its basic function.

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 a single, efficient sentence that directly states the tool's purpose without any wasted words. It is appropriately sized and front-loaded, making it easy to grasp quickly.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It does not explain what the tool returns (e.g., dividend amounts, dates, frequency), potential limitations, or how it integrates with sibling tools. For a financial data tool with no structured output, more context is needed to ensure proper usage.

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 no parameter semantics beyond what the input schema provides. The schema has 100% coverage with a clear description for the 'symbol' parameter, so the baseline is 3. The description does not compensate with additional details like examples or constraints, but it doesn't need to given the schema's completeness.

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 verb ('Get') and resource ('dividends for a given stock symbol'), making the purpose immediately understandable. It does not explicitly differentiate from siblings like 'get_earning_dates' or 'get_historical_stock_prices', which might also involve financial data retrieval, so it misses full sibling distinction.

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?

No guidance is provided on when to use this tool versus alternatives. For example, it does not specify if this is for current dividends, historical dividends, or how it differs from other financial data tools like 'get_cashflow' or 'get_income_statement'. The description lacks context on prerequisites 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

Related 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/maxscheijen/mcp-yahoo-finance'

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