Skip to main content
Glama
16Coffee

Yahoo Finance MCP Server

by 16Coffee

search_companies

Search for company information using a keyword with customizable parameters like result limit and exchange code. Retrieve detailed financial data from Yahoo Finance to analyze or track specific companies.

Instructions

根据关键字搜索公司信息。

参数说明: query: str 搜索关键字 limit: int 返回结果数量,默认 10 exchange: str 交易所代码,可选

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exchangeNo
limitNo
queryYes

Implementation Reference

  • The main handler function that implements the search_companies tool. It queries the Financial Modeling Prep API search endpoint with the given query, limit, and optional exchange, returning JSON data of matching companies.
    async def search_companies(query: str, limit: int = 10, exchange: str = "") -> str:
        """根据关键字搜索公司"""
    
        api_key = os.environ.get("FMP_API_KEY")
        if not api_key:
            return "Error: FMP_API_KEY environment variable not set."
    
        params = {"query": query, "limit": limit, "apikey": api_key}
        if exchange:
            params["exchange"] = exchange
    
        url = "https://financialmodelingprep.com/api/v3/search"
        try:
            resp = requests.get(url, params=params, timeout=10)
            resp.raise_for_status()
            data = resp.json()
        except Exception as e:
            return f"Error: searching companies: {e}"
        return json.dumps(data)
  • server.py:650-662 (registration)
    The @fmp_server.tool decorator registers the search_companies tool, specifying its name and description including input parameter schema.
    @fmp_server.tool(
        name="search_companies",
        description="""根据关键字搜索公司信息。
    
    参数说明:
        query: str
            搜索关键字
        limit: int
            返回结果数量,默认 10
        exchange: str
            交易所代码,可选
    """,
    )
  • Type annotations in the function signature define the input schema: query (str), limit (int, default 10), exchange (str, default empty), returning str (JSON).
    async def search_companies(query: str, limit: int = 10, exchange: str = "") -> str:
        """根据关键字搜索公司"""
    
        api_key = os.environ.get("FMP_API_KEY")
        if not api_key:
            return "Error: FMP_API_KEY environment variable not set."
    
        params = {"query": query, "limit": limit, "apikey": api_key}
        if exchange:
            params["exchange"] = exchange
    
        url = "https://financialmodelingprep.com/api/v3/search"
        try:
            resp = requests.get(url, params=params, timeout=10)
            resp.raise_for_status()
            data = resp.json()
        except Exception as e:
            return f"Error: searching companies: {e}"
        return json.dumps(data)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While '搜索' (search) implies a read operation, the description doesn't address important behavioral aspects like whether this requires authentication, rate limits, what happens with no results, whether results are paginated, or what format the results take. For a search tool with zero annotation coverage, this 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.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded with the core purpose first, followed by parameter explanations. The Chinese text is efficient with no wasted words, though the parameter section could be slightly more integrated with the main description rather than appearing as a separate block.

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?

For a search tool with 3 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what constitutes a 'company' in this context, what fields are returned, how results are ranked, or what happens with ambiguous queries. The parameter explanations help, but key behavioral and output information is missing.

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

Parameters4/5

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

With 0% schema description coverage, the description provides meaningful parameter information that compensates well. It explains that 'query' is the search keyword, 'limit' controls result count with a default of 10, and 'exchange' is an optional exchange code. This covers all three parameters with useful semantic context beyond what the bare schema provides.

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 tool's purpose as '根据关键字搜索公司信息' (search for company information based on keywords), which is a specific verb+resource combination. However, it doesn't explicitly distinguish this tool from sibling tools like 'get_directory_list' or 'lookup_identifier', which might also retrieve company information through different mechanisms.

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 many sibling tools available for retrieving financial data (e.g., 'get_directory_list', 'lookup_identifier', various crypto tools), there's no indication of when this keyword-based company search is appropriate versus other data retrieval methods.

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

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