From eb743ab57706fb84a0462370148d2592f82807ad Mon Sep 17 00:00:00 2001 From: Chingfeng Li Date: Fri, 24 Oct 2025 15:58:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=8Ejson=E4=B8=AD=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=B7=A5=E5=85=B7=EF=BC=8C=E6=96=B9=E4=BE=BF?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89tools?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../test/default-mcp-tools.json | 72 +++++++++++++++++++ main/xiaozhi-server/test/test_page.html | 57 +-------------- 2 files changed, 73 insertions(+), 56 deletions(-) create mode 100644 main/xiaozhi-server/test/default-mcp-tools.json diff --git a/main/xiaozhi-server/test/default-mcp-tools.json b/main/xiaozhi-server/test/default-mcp-tools.json new file mode 100644 index 00000000..2d44f2dc --- /dev/null +++ b/main/xiaozhi-server/test/default-mcp-tools.json @@ -0,0 +1,72 @@ +[ + { + "name": "self.get_device_status", + "description": "Provides the real-time information of the device, including the current status of the audio speaker, screen, battery, network, etc.\nUse this tool for: \n1. Answering questions about current condition (e.g. what is the current volume of the audio speaker?)\n2. As the first step to control the device (e.g. turn up / down the volume of the audio speaker, etc.)", + "inputSchema": { + "type": "object", + "properties": {} + }, + "mockResponse": { + "audio_speaker": { + "volume": 50, + "muted": false + }, + "screen": { + "brightness": 80, + "theme": "light" + }, + "battery": { + "level": 85, + "charging": false + }, + "network": { + "connected": true, + "type": "wifi" + } + } + }, + { + "name": "self.audio_speaker.set_volume", + "description": "Set the volume of the audio speaker. If the current volume is unknown, you must call `self.get_device_status` tool first and then call this tool.", + "inputSchema": { + "type": "object", + "properties": { + "volume": { + "type": "integer", + "minimum": 0, + "maximum": 100 + } + }, + "required": [ + "volume" + ] + }, + "mockResponse": { + "success": true, + "volume": "${volume}", + "message": "音量已设置为 ${volume}" + } + }, + { + "name": "self.screen.set_brightness", + "description": "Set the brightness of the screen.", + "inputSchema": { + "type": "object", + "properties": { + "brightness": { + "type": "integer", + "minimum": 0, + "maximum": 100 + } + }, + "required": [ + "brightness" + ] + }, + "mockResponse": { + "success": true, + "brightness": "${brightness}", + "message": "亮度已设置为 ${brightness}" + } + } +] \ No newline at end of file diff --git a/main/xiaozhi-server/test/test_page.html b/main/xiaozhi-server/test/test_page.html index 2cf9a0ff..b00bb9c2 100644 --- a/main/xiaozhi-server/test/test_page.html +++ b/main/xiaozhi-server/test/test_page.html @@ -1794,62 +1794,7 @@ // ========================================== // 默认工具数据 - const defaultMcpTools = [ - { - name: "self.get_device_status", - description: "Provides the real-time information of the device, including the current status of the audio speaker, screen, battery, network, etc.\nUse this tool for: \n1. Answering questions about current condition (e.g. what is the current volume of the audio speaker?)\n2. As the first step to control the device (e.g. turn up / down the volume of the audio speaker, etc.)", - inputSchema: { - type: "object", - properties: {} - }, - mockResponse: { - audio_speaker: { volume: 50, muted: false }, - screen: { brightness: 80, theme: 'light' }, - battery: { level: 85, charging: false }, - network: { connected: true, type: 'wifi' } - } - }, - { - name: "self.audio_speaker.set_volume", - description: "Set the volume of the audio speaker. If the current volume is unknown, you must call `self.get_device_status` tool first and then call this tool.", - inputSchema: { - type: "object", - properties: { - volume: { - type: "integer", - minimum: 0, - maximum: 100 - } - }, - required: ["volume"] - }, - mockResponse: { - success: true, - volume: "${volume}", - message: "音量已设置为 ${volume}" - } - }, - { - name: "self.screen.set_brightness", - description: "Set the brightness of the screen.", - inputSchema: { - type: "object", - properties: { - brightness: { - type: "integer", - minimum: 0, - maximum: 100 - } - }, - required: ["brightness"] - }, - mockResponse: { - success: true, - brightness: "${brightness}", - message: "亮度已设置为 ${brightness}" - } - } - ]; + const defaultMcpTools = await fetch("default-mcp-tools.json").then(res => res.json()); // 全局变量 let mcpTools = [];