ShallowCodeResearch_agent_web_search
Perform web searches to retrieve results with summaries and URLs for research purposes within the MCP Hub research assistant workflow.
Instructions
Wrapper for WebSearchAgent to perform web searches. Returns: Web search results with summaries and URLs
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | The search query to execute |
Implementation Reference
- app.py:738-748 (handler)Handler function exposed as MCP tool that delegates to WebSearchAgent.search for performing web searches via Tavily API.def agent_web_search(query: str) -> dict: """ Wrapper for WebSearchAgent to perform web searches. Args: query (str): The search query to execute Returns: dict: Web search results with summaries and URLs """ return web_search.search(query)
- app.py:979-987 (registration)Gradio Interface that registers the agent_web_search handler as an MCP tool with api_name 'agent_web_search_service', likely prefixed to 'ShallowCodeResearch_agent_web_search' in the HF space.with gr.Tab("Agent: Web Search", scale=1): gr.Interface( fn=agent_web_search, inputs=[gr.Textbox(label="Search Query", placeholder="Enter search term…", lines=12)], outputs=gr.JSON(label="Web Search Results (Tavily)", height=305), title="Web Search Agent", description="Perform a Tavily web search with configurable result limits.", api_name="agent_web_search_service", )
- mcp_hub/agents/web_search.py:55-99 (helper)The core WebSearchAgent.search method implementing the Tavily web search logic with decorators for performance tracking, retry, rate limiting, circuit breaking, and caching.@track_performance(operation_name="web_search") @retry_sync(**RetryConfig.SEARCH_API) @rate_limited("tavily") @circuit_protected("tavily") @cached(ttl=600) # Cache for 10 minutes def search(self, query: str) -> Dict[str, Any]: """ Perform a web search using the Tavily API to gather internet information. Executes a synchronous web search with the specified query and returns structured results including search summaries, URLs, and content snippets. Results are cached for performance optimization. Args: query (str): The search query string to look up on the web Returns: Dict[str, Any]: A dictionary containing search results, summaries, and metadata or error information if the search fails """ try: validate_non_empty_string(query, "Search query") logger.info(f"Performing web search: {query}") response = self.client.search( query=query, search_depth="basic", max_results=app_config.max_search_results, include_answer=True ) logger.info(f"Search completed, found {len(response.get('results', []))} results") return { "query": response.get("query", query), "tavily_answer": response.get("answer"), "results": response.get("results", []), "data_source": "Tavily Search API", } except ValidationError as e: logger.error(f"Web search validation failed: {str(e)}") return {"error": str(e), "query": query, "results": []} except Exception as e: logger.error(f"Web search failed: {str(e)}") return {"error": f"Tavily API Error: {str(e)}", "query": query, "results": []}
- app.py:147-152 (helper)Instantiation of the WebSearchAgent instance used by the handler.question_enhancer = QuestionEnhancerAgent() web_search = WebSearchAgent() llm_processor = LLMProcessorAgent() citation_formatter = CitationFormatterAgent() code_generator = CodeGeneratorAgent() code_runner = CodeRunnerAgent()
- app.py:1234-1240 (registration)Gradio app launch with mcp_server=True, enabling MCP protocol exposure of all registered tools including the web search agent.hub.launch( mcp_server=True, server_name="0.0.0.0", server_port=7860, show_error=True, share=True )