update:添加sql文件

This commit is contained in:
3030332422 2025-10-27 15:22:16 +08:00
parent 9c328896e9
commit 52eed9edf2
3 changed files with 17 additions and 5 deletions

View file

@ -0,0 +1,7 @@
-- 添加设备ID加密密钥参数
-- 用于MCP工具调用时加密设备ID,防止MAC地址被拦截和滥用
delete from `sys_params` where param_code = 'server.device_id_encrypt_key';
-- 添加device_id_encrypt_key参数
INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) VALUES
(122, 'server.device_id_encrypt_key', '你的mac地址加密密钥', 'string', 1, '设备ID加密密钥,用于MCP工具调用时加密设备MAC地址');

View file

@ -402,3 +402,10 @@ databaseChangeLog:
- sqlFile: - sqlFile:
encoding: utf8 encoding: utf8
path: classpath:db/changelog/202510191042.sql path: classpath:db/changelog/202510191042.sql
- changeSet:
id: 202510271030
author: cgd
changes:
- sqlFile:
encoding: utf8
path: classpath:db/changelog/202510271030.sql

View file

@ -28,9 +28,6 @@ class ServerMCPManager:
self.clients: Dict[str, ServerMCPClient] = {} self.clients: Dict[str, ServerMCPClient] = {}
self.tools = [] self.tools = []
# 初始化加密的设备ID
self.encrypted_device_id = self._get_encrypted_device_id()
def load_config(self) -> Dict[str, Any]: def load_config(self) -> Dict[str, Any]:
"""加载MCP服务配置""" """加载MCP服务配置"""
if len(self.config_path) == 0: if len(self.config_path) == 0:
@ -139,12 +136,13 @@ class ServerMCPManager:
raise ValueError(f"工具 {tool_name} 在任意MCP服务中未找到") raise ValueError(f"工具 {tool_name} 在任意MCP服务中未找到")
# 注入加密的设备ID到参数中 # 注入加密的设备ID到参数中
if self.encrypted_device_id: encrypted_device_id = self._get_encrypted_device_id()
if encrypted_device_id:
tool_data = target_client.tools_dict.get(tool_name) tool_data = target_client.tools_dict.get(tool_name)
if tool_data and hasattr(tool_data, 'inputSchema') and isinstance(tool_data.inputSchema, dict): if tool_data and hasattr(tool_data, 'inputSchema') and isinstance(tool_data.inputSchema, dict):
properties = tool_data.inputSchema.get('properties', {}) properties = tool_data.inputSchema.get('properties', {})
if 'encrypted_device_id' in properties: if 'encrypted_device_id' in properties:
arguments['encrypted_device_id'] = self.encrypted_device_id arguments['encrypted_device_id'] = encrypted_device_id
logger.bind(tag=TAG).info(f"已注入加密设备ID到MCP工具参数中") logger.bind(tag=TAG).info(f"已注入加密设备ID到MCP工具参数中")
# 带重试机制的工具调用 # 带重试机制的工具调用