web_search
Search the web for information using natural language queries to find answers and data from across the internet.
Instructions
Search the web for information about the given query
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Input Schema (JSON Schema)
{
"properties": {
"query": {
"title": "Query",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
}
Implementation Reference
- server.py:12-16 (handler)The web_search tool handler function. It is registered via the @mcp.tool() decorator, defines input (query: str) and output (str) schema via type hints and docstring, and implements the logic by calling TavilyClient.get_search_context with the query and returning the search results.@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 (registration)Registration of the web_search tool using the FastMCP @mcp.tool() decorator.@mcp.tool()
- server.py:13-14 (schema)Schema definition via function signature (input: query str, output: str) and docstring describing the tool.def web_search(query: str) -> str: """Search the web for information about the given query"""
- server.py:10-11 (helper)Initialization of the TavilyClient instance used by the web_search handler.client = TavilyClient(os.getenv("TAVILY_API_KEY"))
- server.py:3-3 (helper)Import of TavilyClient library required for web_search implementation.from tavily import TavilyClient