
参考内容OpenWebSearch网络搜索MCP - 腾讯云简介这是一个基于多引擎搜索结果的模型上下文协议MCP服务器支持无需API密钥的免费网络搜索。部署因为环境OS版本低无法安装高版本node因此采用镜像安装docker run -d --name web-search -p 3000:3000 -e ENABLE_CORStrue -e CORS_ORIGIN* ghcr.io/aas-ee/open-web-search:latest客户端测试服务器提供四种工具search、fetchLinuxDoArticle、fetchCsdnArticle和fetchGithubReadme。如果想直接使用这个mcp可用在自己的MCP客户端配置比如Cherry Studio、VSCode、Claude Desktop等。这里因为测试环境原因我没有部署这些客户端而是使用pyton3.12写了一个客户端测试。python尽量使用最新版本需要安装依赖的mcp库# 这里为了加速安装使用了国内python库源可替换 pip3 install mcp -i https://repo.huaweicloud.com/repository/pypi/simple --trusted-host repo.huaweicloud.com客户端脚本参考import asyncio from mcp import ClientSession, StdioServerParameters from mcp.client.sse import sse_client import logging # 设置日志便于调试 logging.basicConfig(levellogging.DEBUG) async def connect_and_call_mcp(): # 替换为你实际的 MCP Server SSE 地址 # 注意不是 /tools 或 /chat而是 /sse 端点 server_url http://127.0.0.1:3000/sse print(f 正在连接 MCP Server (SSE): {server_url}) try: # 使用 sse_client 建立连接 async with sse_client(urlserver_url) as (read_stream, write_stream): async with ClientSession(read_stream, write_stream) as session: await session.initialize() print(✅ MCP Session 初始化成功) # 获取可用工具列表 tools await session.list_tools() print(f\n️ 可用工具 ({len(tools.tools)} 个):) for tool in tools.tools: print(f - {tool.name}: {tool.description}) # 示例调用第一个工具请根据实际工具名修改 if tools.tools: first_tool tools.tools[0] print(f\n 调用工具: {first_tool.name}) # 构造参数根据工具 schema 调整 arguments {query: 阿里云最新AI产品} # 示例参数 result await session.call_tool(first_tool.name, argumentsarguments) print(f 工具返回结果:\n{result}) else: print(️ 没有可用工具请检查 MCP Server 配置) except Exception as e: print(f❌ 连接或调用失败: {e}) import traceback traceback.print_exc() # 运行异步函数 if __name__ __main__: asyncio.run(connect_and_call_mcp())拓展python工具源码编译python工具二进制编译参考文档https://comate.baidu.com/zh/page/w40sheyik8hwget https://www.python.org/ftp/python/3.12.1/Python-3.12.1.tgz tar -xvf Python-3.12.1.tgz cd Python-3.12.1 ./configure --prefix/usr/local/python-3.12 --with-zlib/usr/include/ --with-openssl-rpathauto --with-openssl/usr/include/openssl OPENSSL_LDFLAGS-L/usr/include/openssl OPENSSL_LIBS-l/usr/include/openssl/ssl OPENSSL_INCLUDES-I/usr/include/openssl # python编译遇到openssl版本过低问题 wget https://www.openssl.org/source/openssl-1.1.1w.tar.gz tar -xvf openssl-1.1.1w.tar.gz cd openssl-1.1.1w/ ./config --prefix/usr/local/openssl --openssldir/usr/local/openssl shared zlib make make install # 重新编译 ./configure --prefix/usr/local/python-3.12 --with-zlib/usr/include/ --with-openssl-rpathauto --with-openssl/usr/local/openssl OPENSSL_LDFLAGS-L/usr/local/openssl OPENSSL_LIBS-l/usr/local/openssl/ssl OPENSSL_INCLUDES-I/usr/local/openssl