feat: vendor MCPBridgePlugin v2.0.0

- Update built-in MCP bridge plugin to v2.0.0 (Claude mcpServers config)\n- Preserve Workflow (toolchains) + ReAct dual-track\n- Fix WebUI status display persistence and reduce workflow registration noise\n- Default plugin disabled in WebUI\n- Add CHANGELOG.md and refactor docs; remove test scripts
This commit is contained in:
CharTyr
2025-12-20 01:56:18 +00:00
parent 8dba63eb5c
commit b2ac055921
13 changed files with 3388 additions and 2754 deletions

View File

@@ -1,4 +1,4 @@
# MCP桥接插件 v1.7.0 - 配置文件示例
# MCP桥接插件 - 配置文件示例
# 将 MCP (Model Context Protocol) 服务器的工具桥接到 MaiBot
#
# 使用方法:复制此文件为 config.toml然后根据需要修改配置
@@ -24,31 +24,123 @@
#
# ============================================================
# ============================================================
# 🔌 MCP 服务器配置
# ============================================================
#
# ⚠️ 重要配置格式Claude Desktop 规范)
# ────────────────────────────────────────────────────────────
# 统一使用 Claude Desktop 的 mcpServers JSON。
#
# claude_config_json 的内容应为 JSON 对象:
# {
# "mcpServers": {
# "server_name": { ...server config... },
# "another": { ... }
# }
# }
#
# 每个服务器支持字段:
# transport - 传输方式: "stdio" / "sse" / "http" / "streamable_http"(可选)
# url - 服务器地址sse/http/streamable_http 模式)
# command - 启动命令stdio 模式,如 "npx" / "uvx"
# args - 命令参数数组stdio 模式)
# env - 环境变量对象stdio 模式,可选)
# headers - 鉴权头(可选,如 {"Authorization": "Bearer xxx"}
# enabled - 是否启用(可选,默认 true
# post_process - 服务器级别后处理配置(可选)
#
# ============================================================
[servers]
claude_config_json = '''
{
"mcpServers": {
"time-mcp-server": {
"enabled": false,
"transport": "streamable_http",
"url": "https://mcp.api-inference.modelscope.cn/server/mcp-server-time"
},
"my-auth-server": {
"enabled": false,
"transport": "streamable_http",
"url": "https://mcp.api-inference.modelscope.net/xxxxxx/mcp",
"headers": {
"Authorization": "Bearer ms-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
},
"fetch-local": {
"enabled": false,
"command": "uvx",
"args": ["mcp-server-fetch"]
}
}
}
'''
# ============================================================
# 插件基本信息
# ============================================================
[plugin]
name = "mcp_bridge_plugin"
version = "1.7.0"
config_version = "1.7.0"
version = "2.0.0"
config_version = "2.0.0"
enabled = false # 默认禁用,在 WebUI 中启用
# ============================================================
# 🆕 v1.5.4 快速入门只读WebUI 显示
# Workflow硬流程/工具链
# ============================================================
#
# 作用:把多个工具按顺序执行;后续步骤可引用前序输出。
#
# ✅ 推荐配置方式WebUI「Workflow硬流程/工具链)」里用“快速添加”表单。
# ✅ 也可以直接写 chains_listJSON 数组)。
#
# 变量替换:
# ${input.xxx} - 用户输入
# ${step.<output_key>} - 指定步骤输出(需设置 output_key
# ${prev} - 上一步输出
# ${prev.字段} - 上一步输出JSON的字段
# ${step.geo.return.0.location} - 数组/下标访问dot
# ${step.geo.return[0].location} - 数组/下标访问([]
# ${step.geo['return'][0]['location']} - bracket 写法
#
# ============================================================
[guide]
# 🚀 快速入门 - 三步开始使用
quick_start = "1. 从下方链接获取 MCP 服务器 2. 在「快速添加」填写信息 3. 保存后发送 /mcp reconnect"
# 🌐 获取 MCP 服务器 - 复制链接到浏览器打开,获取免费 MCP 服务器
# 魔搭 ModelScope 国内免费推荐,复制服务器 URL 到「快速添加」即可
mcp_sources = "https://modelscope.cn/mcp (魔搭·推荐) | https://smithery.ai | https://glama.ai | https://mcp.so"
[tool_chains]
chains_enabled = true
# 📝 配置示例 - 复制到服务器列表可直接使用(免费时间服务器)
example_config = '{"name": "time", "enabled": true, "transport": "streamable_http", "url": "https://mcp.api-inference.modelscope.cn/server/mcp-server-time"}'
chains_list = '''
[
{
"name": "search_and_detail",
"description": "先搜索,再根据结果获取详情",
"input_params": { "query": "搜索关键词" },
"steps": [
{ "tool_name": "把这里替换成你的搜索工具名", "args_template": { "keyword": "${input.query}" }, "output_key": "search" },
{ "tool_name": "把这里替换成你的详情工具名", "args_template": { "id": "${prev}" } }
]
}
]
'''
# ============================================================
# 全局设置
# ReAct软流程
# ============================================================
#
# 作用:把 MCP 工具注册到 MaiBot 的 ReAct 系统LLM 可自主多轮调用。
#
# 注意ReAct 适合“探索式/不确定”场景Workflow 适合“固定/可控”场景。
#
# ============================================================
[react]
react_enabled = false
filter_mode = "whitelist" # whitelist / blacklist
tool_filter = "" # 每行一个工具名,支持通配符 *
# ============================================================
# 全局设置(高级设置建议保持默认)
# ============================================================
[settings]
# 🏷️ 工具前缀 - 用于区分 MCP 工具和原生工具
@@ -75,13 +167,6 @@ heartbeat_enabled = true
# 💓 心跳间隔(秒)- 建议 30-120 秒
heartbeat_interval = 60.0
# 🧠 智能心跳 - 根据服务器稳定性自动调整心跳间隔v1.5.2
# 稳定服务器逐渐增加间隔,断开的服务器缩短间隔
heartbeat_adaptive = true
# 📈 最大间隔倍数 - 稳定服务器心跳间隔最高可达 基准间隔 × 此值v1.5.3
heartbeat_max_multiplier = 3.0
# 🔄 自动重连 - 检测到断开时自动尝试重连
auto_reconnect = true
@@ -89,16 +174,7 @@ auto_reconnect = true
max_reconnect_attempts = 3
# ============================================================
# v1.7.0 状态实时刷新
# ============================================================
# 📊 启用状态实时刷新 - 定期更新 WebUI 状态显示
status_refresh_enabled = true
# 📊 状态刷新间隔(秒)- 值越小刷新越频繁,但会增加少量磁盘写入
status_refresh_interval = 10.0
# ============================================================
# v1.2.0 高级功能(实验性)
# 高级功能(实验性)
# ============================================================
# 📦 启用 Resources - 允许读取 MCP 服务器提供的资源
enable_resources = false
@@ -107,7 +183,7 @@ enable_resources = false
enable_prompts = false
# ============================================================
# v1.3.0 结果后处理功能
# 结果后处理功能
# ============================================================
# 当 MCP 工具返回的内容过长时,使用 LLM 对结果进行摘要提炼
@@ -117,13 +193,13 @@ post_process_enabled = false
# 📏 后处理阈值(字符数)- 结果长度超过此值才触发后处理
post_process_threshold = 500
# <EFBFBD> 后处理输e出限制 - LLM 摘要输出的最大 token 数
# 🔢 后处理输出限制 - LLM 摘要输出的最大 token 数
post_process_max_tokens = 500
# 🤖 后处理模型(可选)- 留空则使用 utils 模型组
post_process_model = ""
# <EFBFBD> 后处理提示词模板-
# 🧠 后处理提示词模板
post_process_prompt = '''用户问题:{query}
工具返回内容:
@@ -132,7 +208,7 @@ post_process_prompt = '''用户问题:{query}
请从上述内容中提取与用户问题最相关的关键信息,简洁准确地输出:'''
# ============================================================
# 🆕 v1.4.0 调用链路追踪
# 调用链路追踪
# ============================================================
# 记录工具调用详情,便于调试和分析
@@ -140,14 +216,14 @@ post_process_prompt = '''用户问题:{query}
trace_enabled = true
# 📊 追踪记录上限 - 内存中保留的最大记录数
trace_max_records = 100
trace_max_records = 50
# 📝 追踪日志文件 - 是否将追踪记录写入日志文件
# 启用后记录写入 plugins/MaiBot_MCPBridgePlugin/logs/trace.jsonl
trace_log_enabled = false
# ============================================================
# 🆕 v1.4.0 工具调用缓存
# 工具调用缓存
# ============================================================
# 缓存相同参数的调用结果,减少重复请求
@@ -160,7 +236,7 @@ cache_ttl = 300
# 📦 最大缓存条目 - 超出后 LRU 淘汰
cache_max_entries = 200
# <EFBFBD> 缓存排除列表 - 即不缓存的工具(每行一个,支持通配符 *
# 🚫 缓存排除列表 - 即不缓存的工具(每行一个,支持通配符 *
# 时间类、随机类工具建议排除
cache_exclude_tools = '''
mcp_*_time_*
@@ -168,7 +244,7 @@ mcp_*_random_*
'''
# ============================================================
# 🆕 v1.4.0 工具管理
# 工具管理
# ============================================================
[tools]
# 📋 工具清单(只读)- 启动后自动生成
@@ -184,48 +260,7 @@ tool_list = "(启动后自动生成)"
disabled_tools = ""
# ============================================================
# 🆕 v1.5.1 快速添加服务器
# ============================================================
# 表单式配置,无需手写 JSON
[quick_add]
# 📛 服务器名称 - 服务器唯一名称(英文,如 time-server
server_name = ""
# 📡 传输类型 - 远程服务器选 streamable_http/http/sse本地选 stdio
server_type = "streamable_http"
# 🌐 服务器 URL - 远程服务器必填streamable_http/http/sse 类型)
server_url = ""
# ⌨️ 启动命令 - stdio 类型必填(如 uvx、npx、python
server_command = ""
# 📝 命令参数 - stdio 类型使用,每行一个参数
server_args = ""
# 🔑 鉴权头(可选)- JSON 格式,如 {"Authorization": "Bearer xxx"}
server_headers = ""
# ============================================================
# 🆕 v1.6.0 配置导入导出
# ============================================================
# 支持从 Claude Desktop / Kiro / MaiBot 格式导入导出
[import_export]
# 📥 导入配置 - 粘贴 Claude Desktop 或其他格式的 MCP 配置 JSON
# 粘贴配置后点击保存2秒内自动导入。查看下方「导入结果」确认状态
import_config = ""
# 📋 导入结果(只读)- 显示导入操作的结果
import_result = ""
# 📤 导出格式 - claude: Claude Desktop 格式 | kiro: Kiro MCP 格式 | maibot: 本插件格式
export_format = "claude"
# 📤 导出结果(只读,可复制)- 点击保存后生成,可复制到 Claude Desktop 或其他支持 MCP 的应用
export_result = "(点击保存后生成)"
# ============================================================
# 🆕 v1.4.0 权限控制
# 权限控制
# ============================================================
[permissions]
# 🔐 启用权限控制 - 按群/用户限制工具使用
@@ -267,66 +302,6 @@ quick_allow_users = ""
# '''
perm_rules = "[]"
# ============================================================
# 🔌 MCP 服务器配置
# ============================================================
#
# ⚠️ 重要JSON 格式说明
# ────────────────────────────────────────────────────────────
# 服务器列表必须是 JSON 数组格式!
#
# ❌ 错误写法:
# { "name": "server1", ... },
# { "name": "server2", ... }
#
# ✅ 正确写法:
# [
# { "name": "server1", ... },
# { "name": "server2", ... }
# ]
#
# ────────────────────────────────────────────────────────────
# 每个服务器的配置字段:
# name - 服务器名称(唯一标识)
# enabled - 是否启用 (true/false)
# transport - 传输方式: "stdio" / "sse" / "http" / "streamable_http"
# url - 服务器地址sse/http/streamable_http 模式必填)
# headers - 🆕 鉴权头(可选,如 {"Authorization": "Bearer xxx"}
# command - 启动命令stdio 模式,如 "npx" 或 "uvx"
# args - 命令参数数组stdio 模式)
# env - 环境变量对象stdio 模式,可选)
# post_process - 服务器级别后处理配置(可选)
#
# ============================================================
[servers]
list = '''
[
{
"name": "time-mcp-server",
"enabled": false,
"transport": "streamable_http",
"url": "https://mcp.api-inference.modelscope.cn/server/mcp-server-time"
},
{
"name": "my-auth-server",
"enabled": false,
"transport": "streamable_http",
"url": "https://mcp.api-inference.modelscope.net/xxxxxx/mcp",
"headers": {
"Authorization": "Bearer ms-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
},
{
"name": "fetch-local",
"enabled": false,
"transport": "stdio",
"command": "uvx",
"args": ["mcp-server-fetch"]
}
]
'''
# ============================================================
# 状态显示(只读)
# ============================================================