web_search
Search the web for information using natural language queries to find relevant data and answers to your questions.
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:15-19 (handler)The main handler function for the 'web_search' tool. It uses a TavilyClient to perform the web search based on the query parameter 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:15-15 (registration)The @mcp.tool() decorator registers the web_search function as an MCP tool.@mcp.tool()
- server.py:16-16 (schema)The function signature defines the input schema (query: str) and output (str).def web_search(query: str) -> str:
- server.py:13-13 (helper)Global initialization of TavilyClient instance used by the web_search tool.client = TavilyClient(os.getenv("TAVILY_API_KEY"))