Skip to main content
Glama
maxscheijen

MCP Yahoo Finance

by maxscheijen

get_cashflow

Retrieve cash flow statements for a specific stock symbol on Yahoo Finance. Choose between yearly, quarterly, or trailing frequencies to analyze financial data.

Instructions

Get cashflow for a given stock symbol.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
freqNoAt what frequency to get cashflow statements. Defaults to "yearly". Valid freqencies: "yearly", "quarterly", "trainling"
symbolYesStock symbol in Yahoo Finance format.

Implementation Reference

  • Core handler function for the get_cashflow tool. Fetches cashflow statements using yfinance Ticker.get_cashflow() and formats as pretty JSON string.
    def get_cashflow(
        self, symbol: str, freq: Literal["yearly", "quarterly", "trainling"] = "yearly"
    ):
        """Get cashflow for a given stock symbol.
    
        Args:
            symbol (str): Stock symbol in Yahoo Finance format.
            freq (str): At what frequency to get cashflow statements. Defaults to "yearly".
                    Valid freqencies: "yearly", "quarterly", "trainling"
        """
        stock = Ticker(ticker=symbol, session=self.session)
        cashflow = stock.get_cashflow(freq=freq, pretty=True)
    
        if isinstance(cashflow, pd.DataFrame):
            cashflow.columns = [str(col.date()) for col in cashflow.columns]
            return f"{cashflow.to_json(indent=2)}"
        return f"{cashflow}"
  • Registers the get_cashflow tool in the MCP server's tool list by generating a Tool object from the handler function.
    generate_tool(yf.get_cashflow),
  • Dispatch handler in the MCP server's call_tool method that invokes the get_cashflow function with arguments and returns the result as TextContent.
    case "get_cashflow":
        price = yf.get_cashflow(**args)
        return [TextContent(type="text", text=price)]
  • Helper utility that inspects the handler function to generate the MCP Tool object, including input schema from signature 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)
  • Type annotations and signature that define the input schema for the tool (symbol: str, freq: Literal[...]).
    def get_cashflow(
        self, symbol: str, freq: Literal["yearly", "quarterly", "trainling"] = "yearly"
    ):
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It only states the basic action without mentioning data freshness, rate limits, authentication needs, or error handling. For a financial data tool, this lack of context on reliability and constraints is a significant gap.

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 fluff or redundancy. It's appropriately sized and front-loaded, making it easy to parse 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 no annotations and no output schema, the description is incomplete. It doesn't explain what the cashflow data includes (e.g., operating, investing, financing activities), format of return values, or any prerequisites. For a financial data retrieval tool, this leaves critical gaps in understanding the tool's behavior and output.

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?

Schema description coverage is 100%, so the input schema fully documents both parameters ('symbol' and 'freq'). The description adds no additional meaning beyond implying cashflow is retrieved per stock symbol, which is already clear from the schema. Baseline 3 is appropriate as the schema handles parameter documentation.

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 ('cashflow for a given stock symbol'), making the purpose immediately understandable. However, it doesn't differentiate this tool from its siblings like 'get_income_statement' or 'get_dividends', which are also financial data retrieval tools for stocks, 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?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'get_income_statement' and 'get_dividends' available, it doesn't specify scenarios where cashflow data is preferred over other financial metrics, leaving the agent without context for tool selection.

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