2025-10-29
深度学习
00

一个接口同时支持 HTTP 和 Streamable HTTP:MCP 双协议实现深度解析

前言

当你第一次看到这段代码时,可能会感到困惑:

typescript
展开代码
// server/api/mcp.post.ts const transport = new StreamableHTTPServerTransport(...) await transport.handleRequest(req, res, await readBody(event))

同一个 StreamableHTTPServerTransport,为什么既能处理 Cursor 的同步 HTTP 请求,又能处理 Inspector 的流式 SSE 连接?

这篇文章将揭开这个"魔法"背后的技术原理,带你理解 MCP 协议、HTTP vs Streamable HTTP 的本质区别,以及如何用一套代码优雅地支持两种模式。

2025-10-28
深度学习
00
bash
展开代码
import asyncio import json from mcp import ClientSession, StdioServerParameters from mcp.client.stdio import stdio_client async def call_newsnow_mcp(): """调用 newsnow MCP 获取知乎热门新闻""" # 1. 配置 MCP 服务器参数 server_params = StdioServerParameters( command="npx", args=["-y", "newsnow-mcp-server"], env={"BASE_URL": "http://101.126.150.28:9044"} ) # 2. 连接到 MCP 服务器 async with stdio_client(server_params) as (read, write): async with ClientSession(read, write) as session: # 3. 初始化会话 await session.initialize() # 4. 调用工具获取知乎新闻 result = await session.call_tool( name="get_hottest_latest_news", arguments={ "id": "zhihu", "count": 10 } ) # 5. 打印结果 print("=" * 50) print("知乎热门新闻(前10条)") print("=" * 50) # 解析返回的内容 for item in result.content: if hasattr(item, 'text'): # 尝试解析 JSON try: news_data = json.loads(item.text) print(json.dumps(news_data, indent=2, ensure_ascii=False)) except: print(item.text) # 运行 if __name__ == "__main__": asyncio.run(call_newsnow_mcp())
2025-10-28
深度学习
00

有个mcp服务是这样的:

bash
展开代码
"newsnow": { "command": "npx", "args": [ "-y", "newsnow-mcp-server" ], "env": { "BASE_URL": "http://101.126.150.28:9044" } }
2025-10-28
建站教程
00

我服务器的801端口是我的博客, 我现在想在外面套一层caddy,自动获取证书 我的域名是tao-blog.site 我如何配置这个caddy

2025-10-27
深度学习
00

https://huggingface.co/mPLUG/GUI-Owl-32B/tree/main

https://github.com/X-PLUG/MobileAgent

下载:

bash
展开代码
apt update && apt install -y aria2 wget https://hf-mirror.com/hfd/hfd.sh chmod a+x hfd.sh export HF_ENDPOINT=https://hf-mirror.com ./hfd.sh mPLUG/GUI-Owl-32B

部署:

bash
展开代码
# 使用vLLM启动 python -m vllm.entrypoints.openai.api_server \ --model /mnt/jfs6/model/GUI-Owl-32B \ --served-model-name ui-tars \ --host 0.0.0.0 \ --port 8000 \ --trust-remote-code \ --max-model-len 8192 \ --gpu-memory-utilization 0.9 \ --tensor-parallel-size 4 --api-key "123"
2025-10-24
深度学习
00

🚀 uiautomator2完整能力清单

1. 📸 截图能力

  • 全屏截图
  • 区域截图
  • 实时截图

2. 🔍 元素查找能力

  • 按文字查找:d.xpath('//*[@text="设置"]')
  • 按ID查找:d(resourceId="com.example:id/button")
  • 按类名查找:d(className="android.widget.Button")
  • 按内容描述查找:d(description="搜索")
  • 组合条件查找:d.xpath('//android.widget.Button[@text="确定"]')
2025-10-24
深度学习
00

Hugging Face 模型下载指南

安装

bash
展开代码
pip install -U huggingface_hub

国内镜像加速

bash
展开代码
export HF_ENDPOINT=https://hf-mirror.com

建议写入 ~/.bashrc~/.zshrc 永久生效:

bash
展开代码
echo 'export HF_ENDPOINT=https://hf-mirror.com' >> ~/.bashrc source ~/.bashrc
2025-10-24
Linux运维
00

安装uv:

bash
展开代码
# 使用官方安装脚本(推荐) curl -LsSf https://astral.sh/uv/install.sh | sh source $HOME/.local/bin/env # 这样也可以: pip install uv # win的powershell安装: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

创建虚拟环境,指定D:\python_envs\py313为环境安装目录:

2025-10-24
深度学习
00

部署:

bash
展开代码
# 使用vLLM启动 python -m vllm.entrypoints.openai.api_server \ --model /mnt/jfs6/model/UI-TARS-72B-DPO \ --served-model-name ui-tars \ --host 0.0.0.0 \ --port 8000 \ --trust-remote-code \ --max-model-len 8192 \ --gpu-memory-utilization 0.9 \ --tensor-parallel-size 8
2025-10-24
深度学习
00

crawl4ai

bash
展开代码
docker run -d -p 9045:11235 --name crawl4ai-local --shm-size=1g unclecode/crawl4ai:latest

使用:

bash
展开代码
"crawl4ai": { "url": "http://101.126.150.28:9045/mcp/sse", "description": "Crawl4AI网页爬取和处理服务 - 支持网页爬取、截图、PDF生成、JavaScript执行等" }