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.css b/main/xiaozhi-server/test/test_page.css index c70c9706..bea04994 100644 --- a/main/xiaozhi-server/test/test_page.css +++ b/main/xiaozhi-server/test/test_page.css @@ -21,9 +21,9 @@ h1 { } .section { - margin-bottom: 20px; - padding: 15px; - border-radius: 8px; + margin-bottom: 5px; + padding: 10px; + border-radius: 10px; background-color: #f9f9f9; } diff --git a/main/xiaozhi-server/test/test_page.html b/main/xiaozhi-server/test/test_page.html index 879d627b..a6672dbc 100644 --- a/main/xiaozhi-server/test/test_page.html +++ b/main/xiaozhi-server/test/test_page.html @@ -56,6 +56,163 @@ #fileProtocolWarning button:hover { background-color: #45a049; } + + /* MCP 工具管理样式 */ + .mcp-tools-container { + display: grid; + gap: 12px; + margin-top: 10px; + } + + .mcp-tool-card { + background-color: white; + border: 1px solid #e0e0e0; + border-radius: 8px; + padding: 15px; + transition: all 0.2s; + } + + .mcp-tool-card:hover { + box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); + } + + .mcp-tool-card.disabled { + opacity: 0.6; + pointer-events: none; + } + + .mcp-tool-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 10px; + } + + .mcp-tool-name { + font-size: 15px; + font-weight: 600; + color: #333; + flex: 1; + } + + .mcp-tool-actions { + display: flex; + gap: 6px; + } + + .mcp-tool-description { + color: #666; + font-size: 13px; + line-height: 1.5; + margin-bottom: 8px; + } + + .mcp-tool-info { + background-color: #f9f9f9; + border: 1px solid #e0e0e0; + border-radius: 4px; + padding: 8px; + font-size: 12px; + } + + .mcp-tool-info-row { + display: flex; + gap: 15px; + margin-bottom: 4px; + } + + .mcp-tool-info-label { + color: #999; + min-width: 60px; + } + + .mcp-tool-info-value { + color: #333; + font-family: 'Courier New', monospace; + } + + .mcp-property-item { + background-color: white; + border: 1px solid #e0e0e0; + border-radius: 5px; + padding: 12px; + margin-bottom: 10px; + } + + .mcp-property-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 10px; + } + + .mcp-property-name { + font-weight: 600; + color: #333; + } + + .mcp-property-row { + display: grid; + grid-template-columns: 1fr 1fr; + gap: 10px; + margin-bottom: 8px; + } + + .mcp-property-row-full { + margin-bottom: 8px; + } + + .mcp-small-label { + display: block; + margin-bottom: 4px; + font-size: 12px; + color: #666; + } + + .mcp-small-input { + width: 100%; + padding: 6px 8px; + border: 1px solid #ddd; + border-radius: 4px; + font-size: 13px; + } + + .mcp-checkbox-label { + display: flex; + align-items: center; + gap: 6px; + font-size: 13px; + color: #666; + cursor: pointer; + } + + .mcp-error { + background-color: #ffebee; + color: #c62828; + padding: 10px; + border-radius: 5px; + margin-bottom: 15px; + font-size: 14px; + } + + .mcp-badge { + display: inline-block; + padding: 2px 8px; + border-radius: 12px; + font-size: 11px; + font-weight: 500; + margin-left: 8px; + } + + .mcp-badge-required { + background-color: #ffebee; + color: #c62828; + } + + .mcp-badge-optional { + background-color: #e3f2fd; + color: #1976d2; + }