# MCP桥接插件 - 配置文件示例 # 将 MCP (Model Context Protocol) 服务器的工具桥接到 MaiBot # # 使用方法:复制此文件为 config.toml,然后根据需要修改配置 # # ============================================================ # 🎯 快速开始(三步) # ============================================================ # 1. 在下方 [servers] 添加 MCP 服务器配置 # 2. 将 enabled 改为 true 启用服务器 # 3. 重启 MaiBot 或发送 /mcp reconnect # # ============================================================ # 📚 去哪找 MCP 服务器? # ============================================================ # # 【远程服务(推荐新手)】 # - ModelScope: https://mcp.modelscope.cn/ (免费,推荐) # - Smithery: https://smithery.ai/ # - Glama: https://glama.ai/mcp/servers # # 【本地服务(需要 npx 或 uvx)】 # - 官方列表: https://github.com/modelcontextprotocol/servers # # ============================================================ # ============================================================ # 🔌 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 = "2.0.0" config_version = "2.0.0" enabled = false # 默认禁用,在 WebUI 中启用 # ============================================================ # Workflow(硬流程/工具链) # ============================================================ # # 作用:把多个工具按顺序执行;后续步骤可引用前序输出。 # # ✅ 推荐配置方式:WebUI「Workflow(硬流程/工具链)」里用“快速添加”表单。 # ✅ 也可以直接写 chains_list(JSON 数组)。 # # 变量替换: # ${input.xxx} - 用户输入 # ${step.} - 指定步骤输出(需设置 output_key) # ${prev} - 上一步输出 # ${prev.字段} - 上一步输出(JSON)的字段 # ${step.geo.return.0.location} - 数组/下标访问(dot) # ${step.geo.return[0].location} - 数组/下标访问([]) # ${step.geo['return'][0]['location']} - bracket 写法 # # ============================================================ [tool_chains] chains_enabled = true 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 工具和原生工具 tool_prefix = "mcp" # ⏱️ 连接超时(秒) connect_timeout = 30.0 # ⏱️ 调用超时(秒) call_timeout = 60.0 # 🔄 自动连接 - 启动时自动连接所有已启用的服务器 auto_connect = true # 🔁 重试次数 - 连接失败时的重试次数 retry_attempts = 3 # ⏳ 重试间隔(秒) retry_interval = 5.0 # 💓 心跳检测 - 定期检测服务器连接状态 heartbeat_enabled = true # 💓 心跳间隔(秒)- 建议 30-120 秒 heartbeat_interval = 60.0 # 🔄 自动重连 - 检测到断开时自动尝试重连 auto_reconnect = true # 🔄 最大重连次数 - 连续重连失败后暂停重连 max_reconnect_attempts = 3 # ============================================================ # 高级功能(实验性) # ============================================================ # 📦 启用 Resources - 允许读取 MCP 服务器提供的资源 enable_resources = false # 📝 启用 Prompts - 允许使用 MCP 服务器提供的提示模板 enable_prompts = false # ============================================================ # 结果后处理功能 # ============================================================ # 当 MCP 工具返回的内容过长时,使用 LLM 对结果进行摘要提炼 # 🔄 启用结果后处理 post_process_enabled = false # 📏 后处理阈值(字符数)- 结果长度超过此值才触发后处理 post_process_threshold = 500 # 🔢 后处理输出限制 - LLM 摘要输出的最大 token 数 post_process_max_tokens = 500 # 🤖 后处理模型(可选)- 留空则使用 utils 模型组 post_process_model = "" # 🧠 后处理提示词模板 post_process_prompt = '''用户问题:{query} 工具返回内容: {result} 请从上述内容中提取与用户问题最相关的关键信息,简洁准确地输出:''' # ============================================================ # 调用链路追踪 # ============================================================ # 记录工具调用详情,便于调试和分析 # 🔍 启用调用追踪 trace_enabled = true # 📊 追踪记录上限 - 内存中保留的最大记录数 trace_max_records = 50 # 📝 追踪日志文件 - 是否将追踪记录写入日志文件 # 启用后记录写入 plugins/MaiBot_MCPBridgePlugin/logs/trace.jsonl trace_log_enabled = false # ============================================================ # 工具调用缓存 # ============================================================ # 缓存相同参数的调用结果,减少重复请求 # 🗄️ 启用调用缓存 cache_enabled = false # ⏱️ 缓存有效期(秒) cache_ttl = 300 # 📦 最大缓存条目 - 超出后 LRU 淘汰 cache_max_entries = 200 # 🚫 缓存排除列表 - 即不缓存的工具(每行一个,支持通配符 *) # 时间类、随机类工具建议排除 cache_exclude_tools = ''' mcp_*_time_* mcp_*_random_* ''' # ============================================================ # 工具管理 # ============================================================ [tools] # 📋 工具清单(只读)- 启动后自动生成 tool_list = "(启动后自动生成)" # 🚫 禁用工具列表 - 要禁用的工具名(每行一个) # 从上方工具清单复制工具名,禁用后该工具不会被 LLM 调用 # 示例: # disabled_tools = ''' # mcp_filesystem_delete_file # mcp_filesystem_write_file # ''' disabled_tools = "" # ============================================================ # 权限控制 # ============================================================ [permissions] # 🔐 启用权限控制 - 按群/用户限制工具使用 perm_enabled = false # 📋 默认模式 # allow_all: 未配置规则的工具默认允许 # deny_all: 未配置规则的工具默认禁止 perm_default_mode = "allow_all" # ──────────────────────────────────────────────────────────── # 🚀 快捷配置(推荐新手使用) # ──────────────────────────────────────────────────────────── # 🚫 禁用群列表 - 这些群无法使用任何 MCP 工具(每行一个群号) # 示例: # quick_deny_groups = ''' # 123456789 # 987654321 # ''' quick_deny_groups = "" # ✅ 管理员白名单 - 这些用户始终可以使用所有工具(每行一个QQ号) # 示例: # quick_allow_users = ''' # 111111111 # ''' quick_allow_users = "" # ──────────────────────────────────────────────────────────── # 📜 高级权限规则(可选,针对特定工具配置) # ──────────────────────────────────────────────────────────── # 格式: qq:ID:group/private/user,工具名支持通配符 * # 示例: # perm_rules = ''' # [ # {"tool": "mcp_*_delete_*", "denied": ["qq:123456:group"]} # ] # ''' perm_rules = "[]" # ============================================================ # 状态显示(只读) # ============================================================ [status] connection_status = "未初始化"