web_search
Search the web by submitting a query. Retrieve relevant results to find answers and gather information from online sources.
Instructions
Search the web for information about the given query
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- server.py:13-17 (handler)The web_search tool handler function. Uses @mcp.tool() decorator to register with FastMCP. Accepts a query string, calls TavilyClient.get_search_context() to perform web search, and returns 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:13-17 (registration)Tool registration via @mcp.tool() decorator on FastMCP instance 'mcp'. The function name 'web_search' becomes the tool name exposed over the MCP protocol.
@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:14-14 (schema)Input schema: the function signature 'def web_search(query: str) -> str' defines the single required string parameter 'query' and string return type, which FastMCP translates into the tool's JSON schema.
def web_search(query: str) -> str: