Feature: Add MCP (Model Context Protocol) server integration

Add an optional MCP server (JSON-RPC 2.0 over Streamable HTTP) exposing
an online-host listing tool, protected by a Bearer token. Disabled by
default; configured via a new "Extensions > MCP Settings" dialog.

- McpServer: httplib + JSON-RPC 2.0 dispatch (initialize/ping/tools/list/tools/call)
- McpSettingsDlg: runtime-created dialog for enable/port/bind/token
- HostJson: extract single-host JSON serialization shared with WebService
- FRP: expose MCP port (union with listening/Web ports) when bound to 0.0.0.0
- i18n: en_US / zh_TW translations

Co-Authored-By: deepseek-v4-pro
This commit is contained in:
yuanyuanxiang
2026-08-16 13:58:36 +02:00
parent 43398e405e
commit 13052b7cae
17 changed files with 1313 additions and 95 deletions

View File

@@ -0,0 +1,15 @@
#pragma once
#include "jsoncpp/json.h"
class context;
class _ClientList;
// 公共函数:将单台在线主机 context 序列化为 JSONUTF-8含 GBK/UTF-8 编码处理)。
// 供 Web UICWebService::BuildDeviceListJson与 MCP 工具list_online_hosts复用
// 避免两处重复易错的编码转换(见 docs/Mcp_Design.md §3.4 方案 C
//
// 职责边界:本函数只负责「单台主机 → Json::Value」的字段序列化与编码转换。
// 分组/用户过滤、m_cs 加锁、外层结构Web 的 {"cmd","devices"} vs MCP 的 {"hosts"}
// 属于调用方,不进本函数。调用方须在 m_cs 锁内调用。
Json::Value BuildHostJson(context* ctx, _ClientList* clientMap);