Skip to main content
Glama
mingdedi

Internetsearch-mcp-server

InternetSearch

Search the internet for answers to questions using a search API. Provide a query to find relevant information online.

Instructions

联网搜索对应问题的答案

Args: query: 需要联网搜索的问题

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
txt_countNo

Implementation Reference

  • The main handler function for the InternetSearch tool. It is decorated with @mcp.tool() to register it with the FastMCP server. The function performs an internet search using the BochaAI API, extracts summaries from search results, and returns them concatenated with IDs.
    @mcp.tool()
    def InternetSearch(query,txt_count=5):
        """联网搜索对应问题的答案
    
        Args:
            query: 需要联网搜索的问题
        """
        headers = {
            "Authorization": f"Bearer {SEARCH_API_KEY}",  # 替换为你的实际 API Key
            "Content-Type": "application/json"
        }
    
        payload = {
            "query": f"{query}",
            "freshness": "noLimit",
            "count": txt_count,
            "answer": False,
            "stream": False
        }
    
        Webtxt=""
    
        try:
            print("开始联网搜索")
            response = requests.post(
                "https://api.bochaai.com/v1/ai-search",
                headers=headers,
                json=payload
            )
            response.raise_for_status()  # 检查 HTTP 错误 
            i=0
            for value in json.loads((response.json()["messages"][0]["content"]))["value"]:
                Webtxt=Webtxt+f"参考资料id:{i}\n"+value["summary"]+"\n"
                i+=1
            #为了兼容web-search添加的代码
            # for value in response.json()["data"]["webPages"]["value"]:
            #     Webtxt=Webtxt+f"参考资料id:{i}\n"+value["snippet"]+"\n"
            #     i+=1
             # 解析并叠加响应
        except requests.exceptions.RequestException as e:
            print(f"Request failed: {e}")
        except ValueError as e:
            print(f"Failed to parse JSON response: {e}")
        return Webtxt
  • Initialization of the FastMCP server instance named 'Internet-search', to which the tool is registered via decorator.
    mcp = FastMCP("Internet-search")
  • Docstring defining the tool's description and input parameters (query). Note: txt_count parameter is defined in function signature but not documented here.
    """联网搜索对应问题的答案
    
    Args:
        query: 需要联网搜索的问题
    """

Tool Definition Quality

Score is being calculated. Check back soon.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mingdedi/InternetSearch-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server