Bot Configuration
bot_config.toml is MaiBot's main configuration file. It contains bot identity, personality, chat behavior, memory, expression learning, message connection, WebUI, MCP, plugin runtime, and more.
This document is organized according to src/config/official_configs.py and src/config/config.py. The configuration file is generated and upgraded by MaiBot automatically. Do not manually add fields that do not exist in the code.
Configuration File Structure
bot_config.toml contains these top-level sections:
[bot]— Bot identity, platform, nickname, aliases[personality]— Character setting and reply style[visual]— Image understanding mode and visual prompt[chat]— Reply frequency, context, chat prompts[message_receive]— Image parsing threshold and message filtering[a_memorix]— Long-term memory system: storage, vectorization, retrieval, profiles, evolution, and Web operations[expression]— Expression learning, jargon learning, expression checking[voice]— Speech recognition[emoji]— Emoji collection, filtering, sending[keyword_reaction]— Keyword/regex triggered reactions[response_post_process]— Global response post-processing switch[chinese_typo]— Chinese typo generation[log]— Log configuration[response_splitter]— Response splitting[telemetry]— Telemetry switch[debug]— Debug display and tracking[maim_message]— maim_message WebSocket/API Server[webui]— WebUI service and security settings[database]— Message binary data saving policy[mcp]— MCP client and server configuration[plugin_runtime]— Plugin runtime and browser rendering configuration
TIP
The [inner] version at the top of the configuration file is managed by the program. Users usually do not need to edit this version manually.
Basic Information [bot]
[bot] contains the bot's identity information. The most commonly used fields are platform, qq_account, nickname, and alias_names.
[bot]
platform = "qq"
qq_account = 123456789
platforms = []
nickname = "MaiMai"
alias_names = ["XiaoMai", "MaiZi"]platform— Main platform identifier, such as qq. Default: emptyqq_account— QQ account used by the bot, used to identify @mentions and self messages. Default: 0platforms— Other platform identifiers, used in multi-platform scenarios. Default: emptynickname— Bot nickname. Default:麦麦alias_names— Bot aliases, used when detecting mentions. Default: empty
Personality [personality]
[personality] controls MaiBot's character setting and language style.
[personality]
personality = "你是一个大二女大学生,现在正在上网和群友聊天。"
reply_style = "请不要刻意突出自身学科背景。可以参考贴吧,知乎和微博的回复风格。"
multiple_reply_style = []
multiple_probability = 0.2personality— Character setting, recommended within 100 Chinese characters. See default configreply_style— Default expression style, recommended 1-2 lines. See default configmultiple_reply_style— Optional style list; can randomly replace reply_style when not empty. Default: emptymultiple_probability— Probability of using multiple_reply_style, range 0.0-1.0. Default: 0.2
Visual [visual]
[visual] controls how image messages are handled by the planner and replyer.
[visual]
planner_mode = "auto"
replyer_mode = "auto"The image description prompt is managed by the Prompt template prompts/<locale>/image_description.prompt.
planner_mode— Planner visual mode, options are text, multimodal, or auto; auto chooses based on model metadata. Default:autoreplyer_mode— Replyer visual mode, options are text, multimodal, or auto; auto chooses based on model metadata. Default:auto
Chat [chat]
[chat] controls reply frequency, context length, group/private chat prompts, and dynamic talk frequency rules.
[chat]
talk_value = 1.0
private_talk_value = 1.0
mentioned_bot_reply = false
inevitable_at_reply = true
enable_at = true
enable_reply_quote = true
max_context_size = 40
max_private_context_size = 60
enable_context_optimization = true
mid_term_memory = true
mid_term_memory_lenth = 5
enable_independent_timing_gate = true
planner_interrupt_max_consecutive_count = 2
group_chat_prompt = "..."
private_chat_prompts = "..."
chat_prompts = []
enable_talk_value_rules = truetalk_value— Chat frequency. Smaller means quieter, range 0-1. Default: 1.0private_talk_value— Private chat frequency. Smaller means quieter, range 0-1. Default: 1.0mentioned_bot_reply— Whether to tend to reply when the bot name is mentioned in plain text. Default: disabledinevitable_at_reply— Whether to always reply when @mentioned. Default: enabledenable_at— Whether to allow using at mentions. Default: enabledenable_reply_quote— Whether to include quoted replies. Default: enabledmax_context_size— Number of context messages sent to the model. Default: 40max_private_context_size— Private chat context length. Default: 60enable_context_optimization— Whether to optimize Planner context usage, with possible cache impact. Default: enabledmid_term_memory— Whether to summarize trimmed chat history with the utils model and keep it as an expandable complex message. Default: enabledmid_term_memory_lenth— Maximum number of mid-term summary messages to retain; the oldest one is removed when exceeded. Default: 5enable_independent_timing_gate— Whether to use an independent Timing Gate; when disabled, pacing tools are merged into Planner. Default: enabledplanner_interrupt_max_consecutive_count— Maximum consecutive planner interruptions by new messages. 0 disables interruption protection. Default: 2group_chat_prompt— General group chat instructions. See default configprivate_chat_prompts— General private chat instructions. See default configchat_prompts— Extra prompts by platform/chat flow. Default: emptyenable_talk_value_rules— Whether to enable dynamic talk frequency rules. Default: enabledtalk_value_rules— Adjusts talk_value by chat flow and time range. Two default rules
talk_value_rules
[[chat.talk_value_rules]]
platform = ""
item_id = ""
rule_type = "group"
time = "00:00-08:59"
value = 0.8
[[chat.talk_value_rules]]
platform = ""
item_id = ""
rule_type = "group"
time = "09:00-18:59"
value = 1.0platform— Platform. Empty together with item_id means globalitem_id— User/group ID. Empty together with platform means globalrule_type— Chat flow type, group or privatetime— Time range inHH:MM-HH:MMformat. Overnight ranges are supportedvalue— Chat frequency value for this range, 0-1
chat_prompts
[[chat.chat_prompts]]
platform = "qq"
item_id = "123456"
rule_type = "group"
prompt = "Speak more briefly in this group."platform, item_id, and prompt must all be filled in; otherwise the extra prompt entry is invalid.
Message Receiving [message_receive]
[message_receive] controls image parsing and message filtering.
image_parse_threshold— Parse images only when image count in one message does not exceed this threshold. Default: 5ban_words— Filter word list. Default: emptyban_msgs_regex— Filter regex list. Invalid regex causes configuration validation failure. Default: empty
Memory [a_memorix]
A_Memorix is MaiBot's long-term memory system. It handles memory storage, vectorization, retrieval, person profiles, memory evolution, and WebUI operations. It replaces the old [memory] section with finer-grained controls.
Use lowercase [a_memorix] in bot_config.toml; TOML section names are case-sensitive.
[a_memorix]
[a_memorix.plugin]
enabled = true
[a_memorix.integration]
enable_memory_query_tool = true
memory_query_default_limit = 5
person_fact_writeback_enabled = true
chat_summary_writeback_enabled = trueMain subsections include integration, plugin, storage, embedding, retrieval, threshold, filter, episode, person_profile, memory, advanced, and web.
Legacy [memory] fields migrate into [a_memorix.integration] and [a_memorix.filter]. For example, old global_memory_blacklist is now represented by filter.mode = "blacklist" and filter.chats.
Expression Learning [expression]
[expression] controls expression learning, jargon learning, expression auto-checking, and shared expression groups.
learning_list— Expression learning configuration by chat flowadvanced_chosen— Whether to enable sub-agent based second-stage expression selectionexpression_groups— Shared expression learning groupsexpression_checked_only— Whether to select only checked and non-rejected expressionsexpression_self_reflect— Whether to enable automatic expression optimizationexpression_auto_check_interval— Auto-check interval in secondsexpression_auto_check_count— Number of expressions randomly selected for each auto-checkexpression_auto_check_custom_criteria— Additional custom evaluation criteriaall_global_jargon— Whether to enable global jargon mode
learning_list
[[expression.learning_list]]
platform = ""
item_id = ""
rule_type = "group"
use_expression = true
enable_learning = true
enable_jargon_learning = trueplatform— Platform. Empty together with item_id means globalitem_id— User/group ID. Empty together with platform means globalrule_type— Chat flow type, group or privateuse_expression— Whether to use learned expressionsenable_learning— Whether to enable expression optimization learningenable_jargon_learning— Whether to enable jargon learning
Voice [voice]
enable_asr— Whether to enable speech recognition. See default config
Emoji [emoji]
emoji_send_num— Number of emoji candidates to choose from when sending, maximum 64max_reg_num— Maximum number of registered emojisdo_replace— Whether to replace old emojis after reaching the maximumcheck_interval— Emoji check interval in minutessteal_emoji— Whether to collect emojis from chatcontent_filtration— Whether to enable emoji filteringfiltration_prompt— Emoji filtering requirement
Keyword Reaction [keyword_reaction]
[[keyword_reaction.keyword_rules]]
keywords = ["keyword"]
reaction = "reaction after trigger"
[[keyword_reaction.regex_rules]]
regex = ["^regex.*"]
reaction = "reaction after trigger"keyword_rules— Keyword rule listregex_rules— Regex rule list
KeywordRuleConfig fields:
keywords— Keyword listregex— Regex listreaction— Reaction after keyword or regex trigger
Response Post-Processing
response_post_process
enable_response_post_process— Whether to enable response post-processing, including typo generation and response splitting
chinese_typo
enable— Whether to enable Chinese typo generationerror_rate— Single-character replacement probabilitymin_freq— Minimum character frequency thresholdtone_error_rate— Tone error probabilityword_replace_rate— Whole-word replacement probability
log
[log] controls log output format, level, and file management.
[log]
date_style = "m-d H:i:s"
log_level_style = "lite"
color_text = "full"
log_level = "INFO"
console_log_level = "INFO"
file_log_level = "DEBUG"
log_file_max_bytes = 5242880
max_log_files = 30
log_cleanup_days = 30
llm_request_snapshot_limit = 128
maisaka_prompt_preview_limit = 256
maisaka_reply_effect_limit = 256
suppress_libraries = ["faiss", "httpx", "urllib3", "asyncio", "websockets", "httpcore", "requests", "sqlalchemy", "openai", "uvicorn", "jieba"]
library_log_levels = { aiohttp = "WARNING" }date_style— Log date format. Default:m-d H:i:slog_level_style— Log level display style, options are lite, compact, or full. Default:litecolor_text— Console log color mode, options are none, title, or full. Default:fulllog_level— Global log level, options are DEBUG, INFO, WARNING, ERROR, or CRITICAL. Default:INFOconsole_log_level— Console log level. Default:INFOfile_log_level— File log level. Default:DEBUGlog_file_max_bytes— Maximum bytes per log file, default 5MB. Default: 5242880max_log_files— Maximum number of main log files to keep. Default: 30log_cleanup_days— Main log file retention days. Default: 30llm_request_snapshot_limit— Maximum number of failed request snapshots to keep. Default: 128maisaka_prompt_preview_limit— Maximum number of Maisaka Prompt preview groups per session. Default: 256maisaka_reply_effect_limit— Maximum number of Maisaka reply effect records per session. Default: 256suppress_libraries— List of third-party libraries to completely suppress logs. 11 librarieslibrary_log_levels— Log levels for specific third-party libraries. Default:{"aiohttp": "WARNING"}
response_splitter
enable— Whether to enable response splittingmax_length— Maximum allowed response lengthmax_sentence_num— Maximum allowed sentence countenable_kaomoji_protection— Whether to protect kaomojienable_overflow_return_all— Whether to return all content when sentence count exceeds the limit
Telemetry and Debug
telemetry
enable— Whether to enable telemetry
debug
enable_maisaka_stage_board— Whether to enable the Maisaka stage boardshow_maisaka_thinking— Whether to show replyer reasoningfold_maisaka_thinking— Whether to fold the Maisaka prompt display entryshow_jargon_prompt— Whether to show jargon-related promptsshow_memory_prompt— Whether to show memory retrieval promptsenable_reply_effect_tracking— Whether to enable reply effect score trackingrecord_reply_request— Whether to record Replyer request body. Disabled by defaultenable_llm_cache_stats— Whether to record LLM prompt cache debug statistics. Disabled by default
Message Service [maim_message]
[maim_message] contains both the legacy WebSocket service and the additional new API Server configuration.
ws_server_host— Legacy WebSocket server host. Default:127.0.0.1ws_server_port— Legacy WebSocket server port. Default: 8000auth_token— Legacy API auth tokens. Empty means no auth. Default: emptyenable_api_server— Whether to enable the additional new API Server. See default configapi_server_host— New API Server host. See default configapi_server_port— New API Server port. See default configapi_server_use_wss— Whether the new API Server uses WSS. See default configapi_server_cert_file— SSL certificate file path. Default: emptyapi_server_key_file— SSL key file path. Default: emptyapi_server_allowed_api_keys— Allowed API key list. Empty allows all connections. Default: empty
WebUI [webui]
enabled— Whether to enable WebUI. Default: enabledhost— WebUI bind host. Default:127.0.0.1port— WebUI bind port. Default: 8001mode— WebUI running mode, options are development or production. Default:productionanti_crawler_mode— Anti-crawler mode, options are false, strict, loose, or basic. Default:basicallowed_ips— IP whitelist, comma-separated; supports exact IP, CIDR, and wildcard. Default:127.0.0.1trusted_proxies— Trusted proxy IP list. Default: emptytrust_xff— Whether to parseX-Forwarded-For. Default: disabledsecure_cookie— Whether to enable secure cookies, HTTPS only. Default: disabledenable_paragraph_content— Whether to load full paragraph content in the knowledge graph; uses extra memory. Default: disabled
Database [database]
save_binary_data— Whether to save binary data such as voice as independent files. Only affects newly stored messages. Default: disabled
MCP [mcp]
[mcp] controls MaiBot's MCP client host capabilities and external MCP server connections.
enable— Whether to enable MCPclient— MCP client host capability configurationservers— MCP server configuration list
mcp.client
client_name— MCP client implementation nameclient_version— MCP client implementation versionroots.enable— Whether to expose Roots capability to MCP serversroots.items— Roots listsampling.enable— Whether to declare Sampling capabilitysampling.task_name— Main model task name used for Sampling requestssampling.include_context_support— Whether to declare support for non-none includeContext semanticssampling.tool_support— Whether to declare support for continuing to use tools in Samplingelicitation.enable— Whether to declare Elicitation capabilityelicitation.allow_form— Whether to allow form-mode Elicitationelicitation.allow_url— Whether to allow URL-mode Elicitation
mcp.servers
[[mcp.servers]]
name = "example"
enabled = true
transport = "stdio"
command = "uvx"
args = ["some-mcp-server"]
env = {}name— Server name, must be uniqueenabled— Whether to enable this servertransport— Transport mode, stdio or streamable_httpcommand— Command used to start the server in stdio modeargs— Command arguments in stdio modeenv— Extra environment variables in stdio modeurl— MCP endpoint in streamable_http modeheaders— Extra HTTP headershttp_timeout_seconds— HTTP request timeoutread_timeout_seconds— Session read timeoutauthorization.mode— HTTP authorization mode, none or bearerauthorization.bearer_token— Bearer Token, only used when mode is bearer
Plugin Runtime [plugin_runtime]
[plugin_runtime] controls the plugin runner and plugin runtime browser rendering capability.
enabled— Whether to enable the plugin systemhealth_check_interval_sec— Health check intervalmax_restart_attempts— Maximum auto-restarts after runner crashrunner_spawn_timeout_sec— Timeout waiting for runner subprocess startup and registrationhook_blocking_timeout_sec— Global timeout for blocking hook steps. Defaults to60secondsipc_socket_path— Custom IPC socket path, Linux/macOS only; empty means auto-generated
plugin_runtime.render
enabled— Whether to enable browser rendering in plugin runtimebrowser_ws_endpoint— Existing Chromium CDP address to reuse firstexecutable_path— Browser executable path; empty means auto-detectbrowser_install_root— Playwright-managed browser directoryheadless— Whether to launch browser in headless modelaunch_args— Browser launch argumentsconcurrency_limit— Maximum concurrent rendering tasksstartup_timeout_sec— Browser connection or startup timeoutrender_timeout_sec— Default timeout for a single renderauto_download_chromium— Whether to automatically download Playwright Chromium if no browser is founddownload_connection_timeout_sec— Connection timeout when automatically downloading Chromiumrestart_after_render_count— Rebuild local browser after this many renders; 0 disables this policy
Common Examples
Beginner Minimal Configuration
[bot]
platform = "qq"
qq_account = 123456789
nickname = "MaiMai"
alias_names = ["XiaoMai"]
[chat]
talk_value = 0.7
inevitable_at_reply = true
max_context_size = 40
[a_memorix]
[a_memorix.plugin]
enabled = true
[a_memorix.integration]
enable_memory_query_tool = true
person_fact_writeback_enabled = true
chat_summary_writeback_enabled = trueConnect an Adapter
[maim_message]
ws_server_host = "127.0.0.1"
ws_server_port = 8000
auth_token = []If the adapter runs in a Docker network or on another machine, adjust the listen address and port according to your deployment.
Next Steps
- Configure models: see Model Configuration
- Connect QQ: see NapCat Adapter
- Manage WebUI: see WebUI Configuration Management