sakurafrp-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@sakurafrp-mcp list my tunnels and show which ones are online"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
sakurafrp-mcp
English | 简体中文
An MCP server for SakuraFrp (樱花内网穿透 / Sakura Frp reverse proxy). Zero dependencies, single file, stdio transport.
Lets an AI manage your SakuraFrp tunnels directly: check traffic, browse nodes, create/edit/delete tunnels, and control the local launcher service.
Why this exists
SakuraFrp tunnel configuration lives only in the cloud console. Changing a tunnel's local port means either clicking through the web UI or hand-writing curl commands. This MCP turns those operations into structured tools an AI can call.
Several non-obvious gotchas, all handled in the implementation:
Gotcha | Symptom | How it's handled |
Editing online doesn't take effect |
|
|
| Only means frpc is alive, not that it picked up the new config | Verification looks at real public responses, not cloud fields |
| Passing | Always |
Singular vs plural paths differ |
| Calls the actual paths |
Local gRPC | It wipes | Not exposed |
Related MCP server: connect-to-server-mcp
Tools (12)
Read-only
Tool | Description |
| Tunnels: id/name/node/node-name/type/local/remote/online/auto-start |
| Traffic usage and quota, speed limit, tunnel quota, realname level, VIP expiry |
| All available nodes with host and description |
| Process liveness, frpc TCP connections, |
| Tail of the launcher log, filterable by tunnel name |
Write operations (all require confirm: true)
Tool | Description |
| Create a tunnel. |
| Modify a tunnel. Strictly four steps: stop → edit → start → verify |
| Delete a tunnel. Stops first, auto-rolls back on failure, optional |
| Start a tunnel (adds to |
| Stop a tunnel |
| Restart |
| Replace |
Every write operation backs up the config to mcp-backups/ beside it before executing.
Installation
Requirements
Node.js >= 18 (uses built-in
fetch)SakuraFrp Launcher installed on Windows (provides
SakuraFrpService)A SakuraFrp access key (panel → user info → view access key)
Clone
git clone https://github.com/arstoya/sakurafrp-mcp.git
cd sakurafrp-mcpNo npm install needed — zero dependencies.
DeepSeek Harness
Append to cordis.patch.yml:
- insert:
- id: mcp-sakurafrp
name: '@deepseek-ai/dsh-mcp-client'
- id: mcp-sakurafrp
disabled: false
config:
serverName: sakurafrp
transport: stdio
command: 'C:\Program Files\nodejs\node.exe'
args:
- 'D:\path\to\sakurafrp-mcp\server.mjs'
toolCallTimeoutMs: 60000
failOnStartupError: false
reconnect:
enabled: true
initialDelayMs: 500
maxDelayMs: 30000
maxAttempts: 10
env:
SAKURA_CONFIG: 'C:\ProgramData\SakuraFrpService\config.json'
SAKURA_LOG_DIR: 'C:\ProgramData\SakuraFrpService\Logs'Note: config is replaced wholesale, not deep-merged — include every key you need.
Claude Desktop
claude_desktop_config.json:
{
"mcpServers": {
"sakurafrp": {
"command": "node",
"args": ["D:\\path\\to\\sakurafrp-mcp\\server.mjs"],
"env": {
"SAKURA_CONFIG": "C:\\ProgramData\\SakuraFrpService\\config.json"
}
}
}
}Environment variables
Variable | Default | Description |
|
| Launcher config; token is read from here |
|
| Log directory |
|
| Windows service name |
| auto-detected | PowerShell executable. Default order: |
|
| Cloud API base |
|
| Per-request timeout in ms |
The token is read from config.json only — no second copy is stored anywhere.
Why config changes require stopping the tunnel first
This is the most important piece of knowledge in this project. Measured results:
# BAD: edit while running
edit: local_port 28092 -> 28920
API returns {}
Cloud reads back: local_port=28920, online=true <- looks successful
Public probe: HTTPS(28920) -> 000, HTTP(28092) -> 501 <- did not take effect at all
# GOOD: stop, edit, start
1. Remove from auto_start_tunnels + Restart-Service -> online=false
2. edit
3. Add back to auto_start_tunnels + Restart-Service -> online=true
Public probe: HTTPS(28920) -> 200 <- actually worksfrpc reads its config at process start. The cloud edit only updates a database row; it does not hot-reload. Only restarting the service re-launches frpc with the new config.
That's why edit_tunnel refuses the "edit without restart" shortcut — it would hand the AI a false success signal.
A sharp port trap
A tunnel's local_port may point at plain HTTP or at self-signed HTTPS. SakuraFrp's mainland China nodes intercept plain HTTP (returning 501 Not Implemented with Server: SakuraFrp).
If your service speaks HTTPS (Jellyfin's 8920, for instance), the tunnel must target that HTTPS port, not 8096. local_status tries http then https automatically and reports which one hit in the scheme field.
Protocol details (for further development)
The local named pipe \\.\pipe\SakuraFrpService3 speaks gRPC over HTTP/2, but server reflection is not registered. Full proto recovered from the binary:
service NatfrpService { // path /NatfrpService/<Method>
rpc UpdateTunnel(TunnelUpdate) returns (TunnelUpdate);
rpc UpdateConfig(ServiceConfig) returns (Empty);
rpc AuthTunnel(TunnelAuthRequest) returns (Empty);
rpc ReloadTunnels(Empty) returns (Empty);
// ...
}
message Tunnel {
int64 id = 1;
int32 node = 2;
string name = 3;
string type = 4;
string note = 5;
string extra = 6;
int32 status = 7;
bool enabled = 8;
State state = 9; // IDLE/STARTED/RUNNING/STOPPING/CRASHED
string local_ip = 10;
int32 local_port = 11;
string remote = 12;
int32 frpc_state = 13;
}
message TunnelUpdate {
Action action = 1; // Unknown=0 Add=1 Update=2 Delete=3 Clear=4 Edit=5
Tunnel tunnel = 2;
}Warning: UpdateTunnel(action=Update) only mutates local design state, does not push to the cloud, and wipes auto_start_tunnels from config.json, dropping every tunnel. This project does not expose it.
Cloud API cheat sheet
Operation | Endpoint | Notes |
List tunnels |
| |
Account info |
|
|
Node list |
| Returns a map keyed by node id |
Create tunnel |
| Requires name/type/node/local_ip/local_port |
Edit tunnel |
| Whole-object overwrite semantics |
Delete tunnel |
| Body |
Singular paths (/v4/tunnel/*) operate on one tunnel; plural (/v4/tunnels) operates on the collection. Mixing them up yields 404s all the way down.
Development
npm test # run all unit tests (27, zero network calls)
npm run check # syntax check
npm start # run directly in stdio modeTests come in two layers:
test/unit.test.mjs— pure logic: tool registration completeness, tunnel-name rules, cloud payload shape, timestamp precision, schema self-consistencytest/protocol.test.mjs— JSON-RPC dispatch: initialize / tools/list / error codes / the confirm gate on write tools
CI runs on GitHub Actions across Node 18/20/22 × Ubuntu/Windows — six combinations. A separate guard job rejects commits containing hardcoded tokens or real account/tunnel ids.
After editing server.mjs, the running MCP child process still holds the old code. In DSH:
plugin_manager action=set_plugin target="include:mcp-sakurafrp" enabled=false
plugin_manager action=set_plugin target="include:mcp-sakurafrp" enabled=trueNo need to restart the whole host.
Known limitations
Windows only.
restart_servicerelies on PowerShell'sRestart-Service, and the default config paths are Windows ones. Service-control tools fail loudly rather than silently on other platforms.edit_tunnelinterrupts the tunnel. It must stop before editing. Other tunnels under the same service are briefly interrupted too, because the service restarts as a whole.Backups are never pruned. Each write operation leaves a file in
mcp-backups/; clean them up manually.
License
MIT
Available Tools
12 toolscreate_tunnelA
在账号下新建一条隧道。写操作,占用隧道额度,必须传 confirm: true。name 要求 3-20 字符仅字母数字下划线;remote 留空则自动分配远端端口。默认创建后即启动(start:false 可关)。
Inputs: name (required), node (required), local_ip (required), local_port (required), +6 more.
delete_tunnelA
永久删除隧道。写操作,必须传 confirm: true。不可恢复,公网入口立即失效。会先停隧道再删除,删除失败自动回滚。可额外传 name 做二次校验防止删错。
Inputs: tunnel (required), name, confirm.
edit_tunnelA
修改已有隧道配置。写操作,必须传 confirm: true。严格按「停隧道 → 改云端配置 → 重新启动 → 验证上线」四步执行:在线直接改云端不会生效,frpc 不会热重载配置。只覆盖显式传入的字段,其余沿用云端当前值。
Inputs: tunnel (required), name, node, note, +6 more.
list_tunnelsA
列出 SakuraFrp 账号下的全部隧道(含节点名、本地/远端端口、在线状态、是否开机自启)。只读。
Inputs: no named parameters.
local_statusA
本机状态:SakuraFrpService / SakuraLauncher / frpc 进程存活、frpc 与节点的 TCP 连接、当前 auto_start_tunnels、各隧道本地端口是否真的可访问、WebUI 端口。只读。
Inputs: no named parameters.
logsA
读取 SakuraFrpService 最新日志文件的尾部若干行,可按隧道名过滤。只读。
Inputs: limit, tunnel.
nodesA
列出全部可用节点(含 host 与说明)。只读。
Inputs: no named parameters.
restart_serviceA
重启 Windows 服务 SakuraFrpService(该服务下所有隧道短暂中断后自动恢复)。必须传 confirm: true。
Inputs: confirm.
set_auto_startB
整体设置 auto_start_tunnels 并重启服务(用于一次性打开/关闭多条)。必须传 confirm: true。
Inputs: tunnelIds (required), confirm.
start_tunnelA
启动指定隧道(按 id 或 name)。写操作:把隧道加入 auto_start_tunnels 并重启 SakuraFrpService,服务下所有隧道会短暂中断。必须传 confirm: true。
Inputs: tunnel (required), confirm.
stop_tunnelA
停止指定隧道(按 id 或 name)。写操作:把隧道从 auto_start_tunnels 移除并重启服务。必须传 confirm: true。
Inputs: tunnel (required), confirm.
user_infoA
账户信息:流量用量与配额、限速、隧道数配额、实名等级、VIP 到期时间。只读。
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Read-only tools (list_tunnels, user_info, nodes, local_status, logs) and per-tunnel write tools (start/stop/create/edit/delete_tunnel) are clearly separable. The one fuzzy boundary is start_tunnel/stop_tunnel versus set_auto_start, since start/stop are implemented by mutating auto_start_tunnels and all three restart the service — the descriptions help but an agent could still pick wrongly for 'permanently enable one tunnel'.
Write tools follow a clean verb_noun CRUD pattern (create_tunnel/edit_tunnel/delete_tunnel/start_tunnel/stop_tunnel/restart_service/set_auto_start). Read tools break it: list_tunnels uses a list_ verb while nodes, logs, user_info and local_status are bare nouns, so there are two competing conventions.
12 tools is well within the sweet spot and each maps to a distinct operation in the tunnel lifecycle (inspect, start/stop, CRUD, service control). No redundant or filler tools; read-only diagnostics and write actions are balanced.
Full tunnel lifecycle (list, create, edit, delete, start, stop, auto-start batch) plus account, nodes, service/process and log diagnostics covers the domain well. Minor gaps: no get_tunnel by id for single-tunnel detail, no way to start a tunnel without it being added to auto_start, and no per-tunnel traffic/latency stats.
Maintenance
Related MCP Connectors
Secure tunneling, reverse proxy and remote access for local applications.
Remote MCP for RunComfy: ComfyUI deployments, hosted models, LoRA training. 31 tools.
Manage PrivateByte servers, backups, proxies, billing and support tickets from an AI agent.
Manage NodePal Minecraft servers, worlds, mods, backups and console from AI agents.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI agents to connect to and control a Virtual Private Server via SSH. It provides a comprehensive suite of tools for remote file system operations, session management, and shell command execution.106 npm2ISC
- AlicenseAqualityNot gradedmaintenanceEnables AI agents to securely connect to and manage remote servers via SSH, with tools for running commands, file operations, log inspection, service management, and system monitoring under configurable access controls and audit logging.1212 npm1MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to manage temporary password-gated public tunnels on Windows, including creating, starting, stopping, updating, and deleting tunnels, setting passwords, and checking for updates.MIT
- AlicenseNot gradedqualityBmaintenanceEnables managing game servers, Discord bots, hosted apps, and VPS instances from one surface: powering machines on and off, reading consoles and live stats, editing server files, taking backups, deploying or rolling back apps, and adjusting firewalls, schedules, variables, and usage monitoring by forwarding each tool call to an upstream hosted service.50 npmMIT