Windows 本地部署小红书 MCP + OpenAI Tunnel + ChatGPT 接入全流程
本文记录一套已经实际跑通的方案:
text
ChatGPT
↓
OpenAI Secure MCP Tunnel
↓
tunnel-client
↓
http://127.0.0.1:18060/mcp
↓
xiaohongshu-mcp
↓
Headless Browser
↓
小红书
最终效果是:Windows 登录后自动后台启动,不弹 PowerShell、不弹浏览器;ChatGPT 可以直接搜索、读取小红书内容。
一、准备文件
Windows x64 下载:
text
xiaohongshu-login-windows-amd64.exe
xiaohongshu-mcp-windows-amd64.exe
建议固定放到:
text
D:\tools\xiaohongshu-mcp\
OpenAI Tunnel Client 下载对应的:
text
tunnel-client-<VERSION>-windows-amd64.zip
不要误下载:
text
linux-amd64
windows-arm64
解压到:
text
D:\tools\openai-tunnel\
如果 Windows 报:
text
指定的可执行文件不是此操作系统平台的有效应用程序
检查文件头:
powershell
$bytes = [System.IO.File]::ReadAllBytes(
(Resolve-Path .\tunnel-client)
)
"{0:X2} {1:X2} {2:X2} {3:X2}" -f `
$bytes[0],$bytes[1],$bytes[2],$bytes[3]
Windows PE 应该以:
text
4D 5A
开头。
如果是:
text
7F 45 4C 46
说明下载成 Linux ELF 版了。
二、小红书首次登录
进入目录:
powershell
cd D:\tools\xiaohongshu-mcp
运行:
powershell
.\xiaohongshu-login-windows-amd64.exe
首次运行可能触发 Windows Defender 对 Rod 的:
text
leakless.exe
误报,例如:
text
Operation did not complete successfully because
the file contains a virus or potentially unwanted software
不要关闭整个 Defender,只针对本次实际生成的:
text
C:\Users\<USER>\AppData\Local\Temp\leakless-amd64-<HASH>\
添加排除项:
powershell
Add-MpPreference `
-ExclusionPath "C:\Users\<USER>\AppData\Local\Temp\leakless-amd64-<HASH>"
然后重新运行登录程序,扫码完成登录。
看到:
text
登录成功!
即可。
三、启动小红书 MCP
日常运行直接:
powershell
cd D:\tools\xiaohongshu-mcp
.\xiaohongshu-mcp-windows-amd64.exe
默认就是 Headless 模式,不会弹浏览器。
MCP 地址:
text
http://127.0.0.1:18060/mcp
REST 调试接口基础地址:
text
http://127.0.0.1:18060
快速检查:
powershell
Test-NetConnection 127.0.0.1 -Port 18060
应看到:
text
TcpTestSucceeded : True
四、验证登录和搜索
登录:
powershell
curl.exe -sS `
"http://127.0.0.1:18060/api/v1/login/status"
首页:
powershell
curl.exe -sS `
"http://127.0.0.1:18060/api/v1/feeds/list"
搜索建议第一阶段不要传 filters:
powershell
$Keyword = [uri]::EscapeDataString("北邮 考研")
curl.exe -sS `
"http://127.0.0.1:18060/api/v1/feeds/search?keyword=$Keyword"
这里有一个踩坑点:
text
filters 中的 "不限" ≠ 空字符串
某些版本会真的打开筛选 UI 去寻找"笔记类型、排序依据"等控件。如果当前小红书页面没有对应筛选组,就可能搜索失败。
因此最稳的是:
text
keyword only
详情读取需要搜索结果里的:
text
feed_id
xsecToken
五、创建 OpenAI Tunnel
在 OpenAI Platform 创建 Tunnel,例如:
text
名称:小红书
Tunnel ID:tunnel_<REDACTED>
然后初始化本地 Tunnel Client:
powershell
cd D:\tools\openai-tunnel
.\tunnel-client.exe init `
--sample sample_mcp_remote_no_auth `
--profile xiaohongshu `
--tunnel-id tunnel_<REDACTED> `
--mcp-server-url "http://127.0.0.1:18060/mcp"
成功后 profile 会保存到:
text
C:\Users\<USER>\AppData\Roaming\tunnel-client\xiaohongshu.yaml
以后不需要重新 init。
六、配置 Runtime API Key
在 OpenAI Platform 创建 Tunnel Runtime 使用的 API Key。
不要把 Key 写进博客、GitHub 或截图。
当前 PowerShell 临时加载:
powershell
$env:CONTROL_PLANE_API_KEY = "<API_KEY>".Trim()
之前遇到过一个非常简单但隐蔽的问题:
powershell
" sk-..."
^
Key 前多一个空格会导致:
text
control plane API key is malformed
因此最好统一 .Trim()。
如果希望重启后仍然存在,持久化成 Windows 用户环境变量:
powershell
$RuntimeKey = $env:CONTROL_PLANE_API_KEY.Trim()
[Environment]::SetEnvironmentVariable(
"CONTROL_PLANE_API_KEY",
$RuntimeKey,
"User"
)
检查但不输出 Key:
powershell
if (
[Environment]::GetEnvironmentVariable(
"CONTROL_PLANE_API_KEY",
"User"
)
) {
Write-Host "Runtime Key: PERSISTED"
}
七、检查 Tunnel
执行:
powershell
.\tunnel-client.exe doctor `
--profile xiaohongshu `
--explain
正常关键项:
text
CHECK tunnel_id PASS
CHECK control_plane_api_key PASS
CHECK mcp_target PASS
CHECK mcp_server_reachable PASS
RESULT ok
然后正式启动:
powershell
.\tunnel-client.exe run `
--profile xiaohongshu
正常最终会看到类似:
text
mcp session initialized
server_name: xiaohongshu-mcp
🟢 tunnel-client started
Tunnel 本地管理界面:
text
http://127.0.0.1:8080/ui
八、ChatGPT 接入
ChatGPT 中首先开启:
text
设置
→ 开发人员模式
→ 开启
创建 Developer Mode MCP 连接时:
text
名称:小红书
Connection:
Tunnel
Tunnel:
选择"小红书"
或填写 tunnel_<REDACTED>
Authentication:
No Authentication
这里必须注意:
text
No Authentication ✅
OAuth ❌
因为本地初始化使用的是:
text
sample_mcp_remote_no_auth
如果错误选择 OAuth,会出现:
text
MCP server ... does not implement OAuth
连接成功后 ChatGPT 可以发现:
text
check_login_status
list_feeds
search_feeds
get_feed_detail
user_profile
...
实测:
text
ChatGPT
→ search_feeds("北邮 考研")
→ 获取 feed_id + xsecToken
→ get_feed_detail(...)
→ 成功读取正文、图片信息和评论
说明链路彻底打通。
九、配置完全静默的开机自启
手工运行时需要两个进程:
text
xiaohongshu-mcp.exe
tunnel-client.exe
为了实现:
text
Windows 登录
→ 自动启动
→ 不弹 PowerShell
→ 不弹 Chrome
→ 崩溃后自动拉起
最终采用:
text
Windows Task Scheduler
↓
wscript.exe
↓
隐藏 powershell supervisor.ps1
↓
xiaohongshu-mcp.exe
↓
等待 18060 Ready
↓
tunnel-client.exe
目录:
text
D:\tools\xiaohongshu-stack\
├── supervisor.ps1
├── launcher.vbs
├── control.ps1
├── control.cmd
└── logs\
计划任务名:
text
Xiaohongshu-ChatGPT-Bridge
触发条件:
text
当前用户登录 Windows
长期任务设置:
text
ExecutionTimeLimit = 0
MultipleInstances = IgnoreNew
Supervisor 每约 20 秒检查:
text
xiaohongshu-mcp 是否存在
18060 是否监听
tunnel-client 是否存在
进程掉了就自动拉起。
十、日常管理
最后做了一个:
text
D:\tools\xiaohongshu-stack\control.cmd
以后双击即可:
text
========================================
Xiaohongshu <-> ChatGPT Bridge
========================================
[1] 启动 Bridge
[2] 停止 Bridge
[3] 启用开机自动启动
[4] 禁用开机自动启动
[5] 重启 Bridge
[6] 查看状态
[7] 打开 Tunnel Web UI
[0] 退出
正常状态:
text
自动启动任务 : Running
Supervisor : RUNNING
Xiaohongshu MCP : RUNNING
Tunnel Client : RUNNING
Port 18060 : PASS
Port 8080 : PASS
Runtime Key : PERSISTED
整体状态 : ONLINE
注意:
text
[2] 停止
只是临时停止,本次 Windows 会话不再运行;如果自动启动仍启用,下次登录 Windows 会重新启动。
text
[4] 禁用自动启动
才是以后登录 Windows 都不再自动运行。
不建议直接在任务管理器杀:
text
xiaohongshu-mcp.exe
tunnel-client.exe
因为 Supervisor 会再次把它们拉起来。
最终部署结构
text
D:\tools\
├── xiaohongshu-mcp\
│ ├── xiaohongshu-login-windows-amd64.exe
│ └── xiaohongshu-mcp-windows-amd64.exe
│
├── openai-tunnel\
│ ├── tunnel-client.exe
│ ├── cloudflared.exe
│ └── ...
│
└── xiaohongshu-stack\
├── supervisor.ps1
├── launcher.vbs
├── control.ps1
├── control.cmd
└── logs\
最终使用体验就是:
text
开机
↓
登录 Windows
↓
后台自动启动
↓
无需打开 PowerShell
↓
无需打开浏览器
↓
打开 ChatGPT
↓
直接:
"搜索小红书上的 XXX,并阅读相关帖子和评论"
脱敏注意事项
公开文章或 GitHub 中绝对不要出现:
text
API Key / sk-...
真实 Tunnel ID
小红书 user_id
账号真实昵称(如需匿名)
fingerprint seed
cookies.json
完整 PowerShell 历史
个人 Windows 用户名
建议统一替换成:
text
<USER>
<API_KEY>
tunnel_<REDACTED>
<XHS_USER_ID>
<HASH>