Development Guide

XiaoZhi AI Development Documentation

This documentation is intended for developers who want to compile or modify the XiaoZhi AI program themselves. It includes the complete development environment setup process, core communication protocols, and implementation methods for extended functionality.

Development Environment

Communication Protocol Documentation

WebSocket Communication Protocol

Detailed explanation of WebSocket communication implementation between devices and servers, including connection establishment, message formats, audio transmission, and other core functions.

MQTT + UDP Hybrid Protocol

MQTT control channel combined with an encrypted UDP audio channel.

MCP Protocol

JSON-RPC 2.0 based MCP flow between the device and the backend: tool discovery, tool calls and user-only tools.

MCP IoT Control Usage

Device-side tool registration, built-in tools and common call examples.

Dynamic Text Glyph Push Extension

The server pushes bitmap glyphs missing from the device font; WebSocket and MQTT/UDP share one format.

Asynchronous Voice Notifications

The cloud plays a one-way voice notification while the device is idle, streaming Ogg Opus audio with timed subtitles.

Emoji Emotion Display

Introduction to how large language models use Emoji to express emotional states, as well as related data formats and usage instructions.

Project Source Code Structure

The XiaoZhi AI project consists of the following main components:

  1. Main Control Program: Runs on ESP32 series chips
  2. Server Side: Handles device connections and voice forwarding
  3. Frontend Interface: Network configuration and settings page

Detailed source code structure and function descriptions can be found in the GitHub repository.

Common Development Issues

  • Compilation Error Resolution: Usually related to ESP-IDF version mismatch; please use the specific ESP-IDF version recommended in the documentation
  • Connection Timeout: Check WebSocket server configuration and network connection
  • Insufficient Memory: ESP32-S3 development boards offer higher performance and are recommended

Documentation Index

Document NameDescriptionUpdate Time
ESP-IDF Development Environment SetupESP-IDF v6.0.1+ environment setup and XiaoZhi build guide2026-10-23
Custom Board GuideDirectory layout, configuration and build flow for a new board2026-10-23
Custom Assets GuidePack and write wake word, fonts, emoji and chat background2026-10-23
Ecosystem ProjectsCommunity servers, clients and ports2026-10-23
WebSocket Communication ProtocolWebSocket client and server communication protocol documentation2026-10-23
MQTT + UDP Hybrid ProtocolMQTT control channel and UDP audio channel2026-10-23
MCP ProtocolMCP flow, tool discovery and calls2026-10-23
MCP IoT Control UsageTool registration, built-in tools and examples2026-10-23
Dynamic Text Glyph Push Extensionglyph_push protocol extension v12026-10-23
Asynchronous Voice Notificationsnotify message and Ogg Opus streaming playback2026-10-23
Emoji Emotion DisplayCommunication protocol for large language models to express emotional states via Emoji2025-03-06