search
Retrieve stock quotes and news articles from Yahoo Finance using ticker symbols or company names. Filter search results by type for tailored financial insights.
Instructions
Fetches and organizes search results from Yahoo Finance, including stock quotes and news articles.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The search query (ticker symbol or company name) | |
| search_type | Yes | Type of search results to retrieve |
Implementation Reference
- src/yfmcp/server.py:53-68 (handler)The handler function for the 'search' tool, decorated with @mcp.tool() for registration. It takes a query and search_type, performs a Yahoo Finance search using yf.Search, and returns JSON based on the search_type (all, quotes, or news).@mcp.tool() def search( query: Annotated[str, Field(description="The search query (ticker symbol or company name)")], search_type: Annotated[SearchType, Field(description="Type of search results to retrieve")], ) -> str: """Fetches and organizes search results from Yahoo Finance, including stock quotes and news articles.""" s = yf.Search(query) match search_type.lower(): case "all": return json.dumps(s.all, ensure_ascii=False) case "quotes": return json.dumps(s.quotes, ensure_ascii=False) case "news": return json.dumps(s.news, ensure_ascii=False) case _: return "Invalid output_type. Use 'all', 'quotes', or 'news'."
- src/yfmcp/types.py:3-7 (schema)Pydantic-compatible type definition (Literal) for the search_type parameter of the search tool, defining allowed values: 'all', 'quotes', 'news'.SearchType = Literal[ "all", "quotes", "news", ]