Skip to main content
Glama
narumiruna

Yahoo Finance MCP Server

yfinance_search

Read-onlyIdempotent

Search Yahoo Finance for stocks, ETFs, and news articles. Retrieve ticker symbols, company details, or financial news with configurable result types.

Instructions

Search Yahoo Finance for stocks, ETFs, and news articles.

Returns JSON with search results based on search_type:

- 'quotes': Array of securities with:
    - symbol: Ticker symbol
    - shortname/longname: Company name
    - quoteType: Security type (EQUITY, ETF, MUTUALFUND, etc.)
    - exchange: Exchange code
    - sector: Business sector
    - industry: Industry classification
    - score: Search relevance score

- 'news': Array of articles with:
    - uuid: Article identifier
    - title: Headline
    - publisher: News source
    - link: Article URL
    - providerPublishTime: Unix timestamp
    - relatedTickers: Array of related symbols
    - thumbnail: Image URLs

- 'all': Object with both 'quotes' and 'news' arrays

Use this to find ticker symbols, discover related securities, or search financial news.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query - company name, ticker symbol, or keywords
search_typeYesFilter results: 'all' (quotes + news), 'quotes' (stocks/ETFs only), or 'news' (articles only)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The async function 'search' that implements the yfinance_search tool logic. It takes a query string and search_type ('all', 'quotes', 'news'), calls yf.Search, and returns JSON results based on the search_type filter.
    async def search(
        query: Annotated[str, Field(description="Search query - company name, ticker symbol, or keywords")],
        search_type: Annotated[
            SearchType,
            Field(
                description="Filter results: 'all' (quotes + news), 'quotes' (stocks/ETFs only), or 'news' (articles only)"
            ),
        ],
    ) -> str:
        """Search Yahoo Finance for stocks, ETFs, and news articles.
    
        Returns JSON with search results based on search_type:
    
        - 'quotes': Array of securities with:
            - symbol: Ticker symbol
            - shortname/longname: Company name
            - quoteType: Security type (EQUITY, ETF, MUTUALFUND, etc.)
            - exchange: Exchange code
            - sector: Business sector
            - industry: Industry classification
            - score: Search relevance score
    
        - 'news': Array of articles with:
            - uuid: Article identifier
            - title: Headline
            - publisher: News source
            - link: Article URL
            - providerPublishTime: Unix timestamp
            - relatedTickers: Array of related symbols
            - thumbnail: Image URLs
    
        - 'all': Object with both 'quotes' and 'news' arrays
    
        Use this to find ticker symbols, discover related securities, or search financial news.
        """
        try:
            s = await asyncio.to_thread(yf.Search, query)
        except _RETRYABLE_YFINANCE_EXCEPTIONS as exc:
            return _create_retryable_error_response(f"searching for '{query}'", exc, {"query": query})
        except Exception as exc:
            return create_error_response(
                f"Search failed for '{query}'. Try simplifying your query or using different keywords.",
                error_code="API_ERROR",
                details={"query": query, "exception": str(exc)},
            )
    
        match search_type.lower():
            case "all":
                return dump_json(s.all)
            case "quotes":
                return dump_json(s.quotes)
            case "news":
                return dump_json(s.news)
            case _:
                return create_error_response(
                    f"Invalid search_type '{search_type}'. Valid options: 'all', 'quotes', 'news'.",
                    error_code="INVALID_PARAMS",
                    details={"search_type": search_type, "valid_options": ["all", "quotes", "news"]},
                )
  • The @mcp.tool decorator that registers the function as the 'yfinance_search' MCP tool with readOnlyHint=True, destructiveHint=False, idempotentHint=True, openWorldHint=True.
    @mcp.tool(
        name="yfinance_search",
        annotations=ToolAnnotations(
            readOnlyHint=True,
            destructiveHint=False,
            idempotentHint=True,
            openWorldHint=True,
        ),
    )
  • The SearchType Literal type definition used for the search_type parameter validation in the yfinance_search tool.
    SearchType = Literal[
        "all",
        "quotes",
        "news",
    ]
  • The dump_json helper function used by the search handler to serialize JSON results with proper encoding.
    def dump_json(payload: object) -> str:
        return json.dumps(payload, ensure_ascii=False, default=str)
Behavior4/5

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

Annotations already indicate readOnly, idempotent, openWorld. Description adds that it returns JSON with specific structures for quotes, news, or both. No mention of rate limits or other constraints, but sufficient for a search tool.

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?

Description is detailed with clear sections for each search_type output. Could be slightly more concise, but structure aids readability and understanding.

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

Completeness5/5

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

Tool has output schema, and description fully explains return values for each search_type. Input parameters are well-described. Context is complete for a search tool, with no missing behavioral details.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema has 100% coverage with descriptions for both parameters. Description adds substantial value by explaining how search_type modifies output and detailing return fields for each type, which goes beyond schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states it searches Yahoo Finance for stocks, ETFs, and news, differentiating from sibling tools like yfinance_get_ticker_info and yfinance_get_ticker_news. It explicitly says 'Use this to find ticker symbols, discover related securities, or search financial news.'

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Description explains how to filter results via search_type parameter and what each type returns. It implicitly guides usage but does not explicitly state when to avoid or compare with alternatives among siblings.

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/narumiruna/yfinance-mcp'

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