import gradio as gr from duckduckgo_search import DDGS def search_duckduckgo(query: str) -> list[dict]: """ Extract the information based on the query. Args: query (str): the query for getiing information Returns: list[dict]: A list of dictionaries containing title, href and body """ with DDGS() as ddgs: results = ddgs.text(query, max_results=5) # return "\n".join([f"{r['title']} - {r['href']} - {r['body']}" for r in results]) return results with gr.Blocks() as app: gr.Markdown("# DuckDuckGo Search Tool"), gr.Markdown("## Please checkout below video to know about this MCP Server"), gr.HTML( """""", label="Featured Video" ), with gr.Row(): query_input = gr.Textbox(label="Enter Search Query") search_btn = gr.Button("Search") output = gr.Textbox(label="Results", interactive=False) search_btn.click(fn=search_duckduckgo, inputs=query_input, outputs=output) app.launch(mcp_server=True)