File tree Expand file tree Collapse file tree 3 files changed +133
-0
lines changed
Expand file tree Collapse file tree 3 files changed +133
-0
lines changed Original file line number Diff line number Diff line change 1+ ## 后台运行小红书 MCP 的解决方案 - Mac 端
2+
3+ 通过此方法你可以:通过系统进程管理小红书 MCP
4+
5+ ### 快速开始
6+
7+ #### 1. 安装配置
8+
9+ 1 . 打开当前目录下 xhsmcp.plist
10+ 1 . 必须:替换 {二进制路径} 为你的小红书 MCP 二进制路径
11+ 2 . 必须:替换 {工作路径} 为你的小红书 MCP 工作路径,必须在有 cookies.json 文件的目录才能正常工作
12+ 3 . 可选:修改默认日志路径 StandardOutPath
13+ 4 . 可选:修改默认错误日志路径 StandardErrorPath
14+ 5 . 可选:修改错误退出的行为是否重启 KeepAlive
15+ 6 . 可选:修改是否开机自动重启 RunAtLoad
16+ 2 . 安装配置
17+ 1 . ln -s {你编辑后的 plist} ~ /Library/LaunchAgents/xhsmcp.plist
18+ 2 . launchctl load ~ /Library/LaunchAgents/xhsmcp.plist
19+
20+ 至此就完成了配置安装
21+
22+ #### 2. 使用配置
23+
24+ 启动小红书 MCP 服务
25+
26+ ``` bash
27+ launchctl start xhsmcp
28+ ```
29+
30+ 关闭小红书 MCP 服务
31+
32+ ``` bash
33+ launchctl stop xhsmcp
34+ ```
35+
36+ 查看服务状态,输出有进程 ID 则为运行中,也可以通过 curl 检查服务运行状态
37+
38+ ``` bash
39+ launchctl list | grep xhsmcp
40+ ```
41+
42+ ### Shell 脚本管理 (进阶用法)
43+
44+ 如果你使用 fish shell,可以安装该目录下的 xhsmcp.fish,实现类似这样的效果:
45+
46+ ``` bash
47+ ~ /home
48+ > launchctl list | grep
49+
50+ - 0 xhsmcp
51+
52+ ~ /home
53+ > xhsmcp_status
54+
55+ ✗ xhsmcp 未运行
56+ 是否启动服务? (yes/其他): yes
57+ ✓ 服务启动成功 (PID: 76061)
58+
59+ ~ /home
60+ > launchctl list | grep
61+ 76061 0 xhsmcp
62+ ```
Original file line number Diff line number Diff line change 1+ function xhsmcp_stop
2+ launchctl stop xhsmcp
3+ end
4+
5+ function xhsmcp_start
6+ launchctl start xhsmcp
7+ end
8+
9+ function xhsmcp_status
10+ gomcp
11+ set service_name " xhsmcp"
12+
13+ # 获取服务状态
14+ set pid_status (launchctl list | grep $service_name | awk ' {print $1}' )
15+
16+ if test " $pid_status " != " -"
17+ echo " ✓ $service_name 正在运行 (PID: $pid_status )"
18+ read -P " 是否停止服务? (yes/其他): " answer
19+ if test " $answer " = " yes"
20+ xhsmcp_stop
21+ echo " ✓ 服务已停止"
22+ else
23+ echo " 取消操作"
24+ end
25+ else
26+ echo " ✗ $service_name 未运行"
27+ read -P " 是否启动服务? (yes/其他): " answer
28+ if test " $answer " = " yes"
29+ xhsmcp_start
30+ sleep 1
31+ set pid_status (launchctl list | grep $service_name | awk ' {print $1}' )
32+ if test " $pid_status " != " -"
33+ echo " ✓ 服务启动成功 (PID: $pid_status )"
34+ else
35+ echo " ✗ 服务启动失败,检查日志: /tmp/xhsmcp.err"
36+ return 1
37+ end
38+ else
39+ echo " 取消操作"
40+ return 1
41+ end
42+ end
43+ end
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+ <plist version =" 1.0" >
4+ <dict >
5+ <key >Label </key >
6+ <string >xhsmcp </string >
7+
8+ <key >ProgramArguments </key >
9+ <array >
10+ <string >{二进制路径} </string >
11+ </array >
12+
13+ <key >WorkingDirectory </key >
14+ <string >{工作路径} </string >
15+
16+ <key >RunAtLoad </key >
17+ <false />
18+
19+ <key >KeepAlive </key >
20+ <false />
21+
22+ <key >StandardOutPath </key >
23+ <string >/tmp/xhsmcp.log </string >
24+
25+ <key >StandardErrorPath </key >
26+ <string >/tmp/xhsmcp.err </string >
27+ </dict >
28+ </plist >
You can’t perform that action at this time.
0 commit comments