Browse Source

🐞 fix: 修复部分问题

Pchen. 1 month ago
parent
commit
e6dbabcff9
2 changed files with 10 additions and 10 deletions
  1. 6 6
      apis/MCP/McpRPC.js
  2. 4 4
      lib/Lepao/Mcp.js

+ 6 - 6
apis/MCP/McpRPC.js

@@ -20,7 +20,7 @@ class McpRpc extends API {
                 result = {
                 result = {
                     protocolVersion: "1.0",
                     protocolVersion: "1.0",
                     capabilities: { "tools": {} },
                     capabilities: { "tools": {} },
-                    serverInfo: { name: "runforge-mcp", version: "1.0" }
+                    serverInfo: { name: "runforge", version: "1.0" }
                 }
                 }
             } else if (method === 'tools/list') {
             } else if (method === 'tools/list') {
                 result = {
                 result = {
@@ -57,14 +57,14 @@ class McpRpc extends API {
                         },
                         },
                         {
                         {
                             "name": "set_notification",
                             "name": "set_notification",
-                            "description": "消息通知设置,type参数:bot:智能机器人通知、email:邮件通知、none:关闭通知",
+                            "description": "消息通知设置,mode参数:bot:智能机器人通知、email:邮件通知、none:关闭通知",
                             "inputSchema": {
                             "inputSchema": {
                                 "type": "object",
                                 "type": "object",
                                 "properties": {
                                 "properties": {
                                     "sender": { "type": "string" },
                                     "sender": { "type": "string" },
-                                    "type": { "type": "string" }
+                                    "mode": { "mode": "string" }
                                 },
                                 },
-                                "required": ["sender", "type"]
+                                "required": ["sender", "mode"]
                             }
                             }
                         }
                         }
                     ]
                     ]
@@ -99,13 +99,13 @@ class McpRpc extends API {
             // 返回标准 JSON-RPC 响应
             // 返回标准 JSON-RPC 响应
             return res.json({
             return res.json({
                 jsonrpc: "2.0",
                 jsonrpc: "2.0",
-                id: req_id,
+                id: req_id ?? null,
                 result
                 result
             })
             })
         } catch (e) {
         } catch (e) {
             return res.json({
             return res.json({
                 jsonrpc: "2.0",
                 jsonrpc: "2.0",
-                id: req_id,
+                id: req_id ?? null,
                 error: { code: -32000, message: e.message }
                 error: { code: -32000, message: e.message }
             })
             })
         }
         }

+ 4 - 4
lib/Lepao/Mcp.js

@@ -140,10 +140,10 @@ class Mcp {
         }
         }
     }
     }
 
 
-    async set_notification({ sender, type }) {
+    async set_notification({ sender, mode }) {
         try {
         try {
-            this.logger.info(`MCP接收设置通知请求:${sender},type:${type}`)
-            if(type !== 'email' || type !== 'bot' || type !== 'none') return '通知type不合法,仅支持 email, bot, none三种模式'
+            this.logger.info(`MCP接收设置通知请求:${sender},mode:${mode}`)
+            if(mode !== 'email' || mode !== 'bot' || mode !== 'none') return '通知type不合法,仅支持 email, bot, none三种模式'
 
 
             let insertSql = `
             let insertSql = `
                 UPDATE 
                 UPDATE 
@@ -157,7 +157,7 @@ class Mcp {
                 WHERE 
                 WHERE 
                     le.bot_account = ?
                     le.bot_account = ?
             `
             `
-            let insertRows = await db.query(insertSql, [type, sender])
+            let insertRows = await db.query(insertSql, [mode, sender])
             if (!insertRows || insertRows.affectedRows !== 1)
             if (!insertRows || insertRows.affectedRows !== 1)
                 return '系统出错,请稍后再试'
                 return '系统出错,请稍后再试'
             return `操作成功`
             return `操作成功`