Skip to main content
Glama
16Coffee

Yahoo Finance MCP Server

by 16Coffee

get_stock_info

Retrieve company profiles and key financial metrics by providing a stock ticker, such as "AAPL", using the Yahoo Finance MCP Server.

Instructions

获取公司概况及关键财务指标。

参数说明: ticker: str 股票代码,例如 "AAPL"

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tickerYes

Implementation Reference

  • The main handler function that fetches the stock profile data from the Financial Modeling Prep API using the ticker symbol and returns it as JSON.
    async def get_stock_info(ticker: str) -> str:
        """Get stock information for a given ticker symbol"""
        api_key = os.environ.get("FMP_API_KEY")
        if not api_key:
            return "Error: FMP_API_KEY environment variable not set."
    
        url = f"https://financialmodelingprep.com/api/v3/profile/{ticker}"
        try:
            resp = requests.get(url, params={"apikey": api_key}, timeout=10)
            resp.raise_for_status()
            data = resp.json()
        except Exception as e:
            return f"Error: getting stock information for {ticker}: {e}"
        return json.dumps(data[0] if isinstance(data, list) and data else data)
  • server.py:126-134 (registration)
    The decorator that registers the 'get_stock_info' tool with FastMCP, including the name and description with input schema details.
    @fmp_server.tool(
        name="get_stock_info",
        description="""获取公司概况及关键财务指标。
    
    参数说明:
        ticker: str
            股票代码,例如 "AAPL"
    """,
    )
  • The tool description providing input schema: ticker as str.
        name="get_stock_info",
        description="""获取公司概况及关键财务指标。
    
    参数说明:
        ticker: str
            股票代码,例如 "AAPL"
    """,
    )

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/16Coffee/finance-mcp'

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