web_search
Perform web searches to retrieve information from the internet through natural language queries using the Tavily API.
Instructions
Search the web for information about the given query
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- server.py:16-20 (handler)The web_search tool handler implementation. It is registered using the @mcp.tool() decorator from FastMCP, takes a query string, uses a TavilyClient instance to fetch search context, and returns the results as a string. The function signature and docstring define the implicit schema.@mcp.tool() def web_search(query: str) -> str: """Search the web for information about the given query""" search_results = client.get_search_context(query=query) return search_results
- server.py:12-12 (helper)Initialization of the TavilyClient instance referenced in the web_search handler for performing web searches.client = TavilyClient(os.getenv("TAVILY_API_KEY"))
- server.py:3-3 (helper)Import of TavilyClient library used by the web_search tool.from tavily import TavilyClient