Skip to main content
Glama
marckwei

MCP Yahoo Finance

by marckwei

get_cashflow

Retrieve cash flow statements for any stock symbol from Yahoo Finance. Set frequency to yearly, quarterly, or trailing for detailed financial insights.

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

  • The primary handler function implementing the 'get_cashflow' tool logic. Fetches cashflow statements for a stock symbol using yfinance Ticker and returns formatted JSON.
    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 (via generate_tool(yf.get_cashflow)) in the MCP server's list of available tools.
    @server.list_tools() async def list_tools() -> list[Tool]: return [ generate_tool(yf.cmd_run), generate_tool(yf.get_recommendations), generate_tool(yf.get_news), generate_tool(yf.get_current_stock_price), generate_tool(yf.get_stock_price_by_date), generate_tool(yf.get_stock_price_date_range), generate_tool(yf.get_historical_stock_prices), generate_tool(yf.get_dividends), generate_tool(yf.get_income_statement), generate_tool(yf.get_cashflow), generate_tool(yf.get_earning_dates), ]
  • Dispatches calls to the 'get_cashflow' tool handler within the server's call_tool method.
    case "get_cashflow": price = yf.get_cashflow(**args) return [TextContent(type="text", text=price)]
  • Helper function that generates the input schema for tools like 'get_cashflow' based on function 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)

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/marckwei/no-use-tools'

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