Skip to main content
Glama
mcp2everything

MCP2Tavily

search_web

Search the web for real-time information using the Tavily API to answer queries and gather current data.

Instructions

Search the web for information using Tavily API

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Implementation Reference

  • The main handler function for the 'search_web' tool, decorated with @mcp.tool() for registration and execution. It delegates the actual search logic to the internal _do_search helper.
    @mcp.tool()
    def search_web(query: str) -> str:
        """Search the web for information using Tavily API"""
        return _do_search(query)
  • Helper function containing the core logic for web search using TavilyClient, including UTF-8 handling, API call, response parsing, and error management.
    def _do_search(query: str) -> str:
        """Internal function to handle the search logic with UTF-8 support"""
        try:
            # 确保查询字符串是UTF-8编码
            query = query.encode('utf-8').decode('utf-8')
            tavily_client = TavilyClient(api_key=API_KEY)
            response = tavily_client.search(
                query=query,
                search_depth="basic",
                include_answer=True,
                include_raw_content=False
            )
            
            # 确保响应文本是UTF-8编码
            answer = response.get('answer', 'No answer found').encode('utf-8').decode('utf-8')
            sources = response.get('sources', [])
            
            result = f"Answer: {answer}\n\nSources:"
            for source in sources[:3]:
                title = source.get('title', 'No title').encode('utf-8').decode('utf-8')
                url = source.get('url', 'No URL')
                result += f"\n- {title}: {url}"
                
            return result
        except UnicodeError as e:
            logger.error(f"Encoding error: {str(e)}")
            return "Error: Unicode encoding issue occurred"
        except Exception as e:
            logger.error(f"Search error: {str(e)}")
            return f"Error performing search: {str(e)}"
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral context. It mentions the Tavily API but doesn't disclose rate limits, authentication requirements, result formats, pagination behavior, or any limitations of the search. For a web search tool with zero annotation coverage, this leaves significant gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

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

The description is extremely concise - a single sentence with no wasted words. It's front-loaded with the core functionality and efficiently includes the API information. Every word serves a purpose.

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 web search tool with no annotations, no output schema, and minimal parameter documentation, the description is inadequate. It doesn't explain what kind of results to expect, how they're formatted, any limitations of the Tavily API, or how this differs from the sibling 'search_web_info' tool.

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

Parameters3/5

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

Schema description coverage is 0%, but there's only one parameter ('query'). The description adds minimal context by implying this is a search query parameter, but doesn't provide guidance on query formatting, length limits, or special syntax. With a single parameter, the baseline is higher, but the description doesn't fully compensate for the lack of schema documentation.

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 action ('Search the web') and resource ('for information'), specifying the method ('using Tavily API'). It distinguishes from sibling 'get_url_content' and 'get_url_content_info' by focusing on search rather than content retrieval, but doesn't explicitly differentiate from 'search_web_info'.

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?

No guidance is provided on when to use this tool versus alternatives like 'search_web_info' or 'get_url_content'. The description mentions the Tavily API but doesn't explain when this search approach is preferred over other methods or what types of queries it handles best.

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/mcp2everything/mcp2tavily'

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