web_search
Search the web for information using natural language queries through the Tavily API to find answers and data from internet sources.
Instructions
Search the web for information about the given query
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- server.py:14-18 (handler)The handler function for the 'web_search' tool. Decorated with @mcp.tool() for registration, it defines the input schema implicitly via type hints (query: str) and docstring, executes the web search using the TavilyClient, and returns the search results as a string.@mcp.tool() def web_search(query: str) -> str: """Search the web for information about the given query""" search_results = web_search_client.get_search_context(query=query) return search_results
- server.py:11-11 (helper)Initialization of the TavilyClient instance used by the web_search tool handler.web_search_client = TavilyClient(os.getenv("TAVILY_API_KEY"))
- server.py:3-3 (helper)Import of the TavilyClient library required for web_search functionality.from tavily import TavilyClient