Skip to content

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:

SectionPurpose
[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
[memory]Memory retrieval, writeback, feedback correction
[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
[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.

toml
[bot]
platform = "qq"
qq_account = 123456789
platforms = []
nickname = "MaiMai"
alias_names = ["XiaoMai", "MaiZi"]
FieldTypeDefaultDescription
platformstr""Main platform identifier, such as qq
qq_accountint0QQ account used by the bot, used to identify @mentions and self messages
platformslist[str][]Other platform identifiers, used in multi-platform scenarios
nicknamestr"麦麦"Bot nickname
alias_nameslist[str][]Bot aliases, used when detecting mentions

Personality [personality]

[personality] controls MaiBot's character setting and language style.

toml
[personality]
personality = "是一个大二在读女大学生,现在正在上网和群友聊天,有时有点攻击性,有时比较温柔"
reply_style = "请不要刻意突出自身学科背景。可以参考贴吧,知乎和微博的回复风格。"
multiple_reply_style = []
multiple_probability = 0.3
FieldTypeDefaultDescription
personalitystrSee default configCharacter setting, recommended within 100 Chinese characters
reply_stylestrSee default configDefault expression style, recommended 1-2 lines
multiple_reply_stylelist[str][]Optional style list; can randomly replace reply_style when not empty
multiple_probabilityfloat0.3Probability of using multiple_reply_style, range 0.0-1.0

Visual [visual]

[visual] controls how image messages are handled by the planner and replyer.

toml
[visual]
planner_mode = "auto"
replyer_mode = "auto"

The image description prompt is managed by the Prompt template prompts/<locale>/image_description.prompt.

FieldTypeDefaultDescription
planner_mode"text" | "multimodal" | "auto""auto"Planner visual mode. auto chooses based on model metadata
replyer_mode"text" | "multimodal" | "auto""auto"Replyer visual mode. auto chooses based on model metadata

Chat [chat]

[chat] controls reply frequency, context length, group/private chat prompts, and dynamic talk frequency rules.

toml
[chat]
talk_value = 1.0
mentioned_bot_reply = false
inevitable_at_reply = true
enable_reply_quote = true
max_context_size = 30
planner_interrupt_max_consecutive_count = 2
group_chat_prompt = "..."
private_chat_prompts = "..."
chat_prompts = []
enable_talk_value_rules = true
FieldTypeDefaultDescription
talk_valuefloat1.0Chat frequency. Smaller means quieter, range 0-1
mentioned_bot_replyboolfalseWhether to tend to reply when the bot name is mentioned in plain text
inevitable_at_replybooltrueWhether to always reply when @mentioned
enable_reply_quotebooltrueWhether to include quoted replies
max_context_sizeint30Number of context messages sent to the model
planner_interrupt_max_consecutive_countint2Maximum consecutive planner interruptions by new messages. 0 disables interruption protection
group_chat_promptstrSee default configGeneral group chat instructions
private_chat_promptsstrSee default configGeneral private chat instructions
chat_promptslist[ExtraPromptItem][]Extra prompts by platform/chat flow
enable_talk_value_rulesbooltrueWhether to enable dynamic talk frequency rules
talk_value_ruleslist[TalkRulesItem]Two default rulesAdjusts talk_value by chat flow and time range

talk_value_rules

toml
[[chat.talk_value_rules]]
platform = ""
item_id = ""
rule_type = "group"
time = "00:00-08:59"
value = 0.8
FieldTypeDescription
platformstrPlatform. Empty together with item_id means global
item_idstrUser/group ID. Empty together with platform means global
rule_type"group" | "private"Chat flow type
timestrTime range in "HH:MM-HH:MM" format. Overnight ranges are supported
valuefloatChat frequency value for this range, 0-1

chat_prompts

toml
[[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.

FieldTypeDefaultDescription
image_parse_thresholdint5Parse images only when image count in one message does not exceed this threshold
ban_wordsset[str]set()Filter word list
ban_msgs_regexset[str]set()Filter regex list. Invalid regex causes configuration validation failure

Memory [memory]

[memory] controls long-term memory retrieval, person fact writeback, chat summary writeback, and feedback correction.

Common Memory Fields

FieldTypeDefaultDescription
global_memoryboolfalseWhether memory retrieval can ignore the current chat flow restriction
global_memory_blacklistlist[TargetItem][]Global memory blacklist, used to exclude specific chat flows
enable_memory_query_toolbooltrueWhether to enable Maisaka's built-in long-term memory tool query_memory
memory_query_default_limitint5Default return count for query_memory, range 1-20
person_fact_writeback_enabledbooltrueWhether to extract and write person facts after replies
chat_summary_writeback_enabledbooltrueWhether to write chat summaries by message window
chat_summary_writeback_message_thresholdint12Message window threshold for chat summary writeback
chat_summary_writeback_context_lengthint50Number of messages to look back for summary writeback, range 1-500

global_memory_blacklist

toml
[[memory.global_memory_blacklist]]
platform = "qq"
item_id = "123456"
rule_type = "group"

Common TargetItem fields:

FieldTypeDescription
platformstrPlatform. Empty together with item_id means global
item_idstrUser/group ID. Empty together with platform means global
rule_type"group" | "private"Chat flow type

Feedback Correction Fields

Feedback correction is disabled by default and is an advanced feature. It uses user feedback after query_memory to try correcting stale memories.

FieldTypeDefaultDescription
feedback_correction_enabledboolfalseWhether to enable feedback-driven delayed memory correction
feedback_correction_window_hoursfloat12.0Feedback window duration in hours
feedback_correction_check_interval_minutesint30Polling interval in minutes
feedback_correction_batch_sizeint20Maximum tasks per round, range 1-200
feedback_correction_auto_apply_thresholdfloat0.85Minimum confidence for automatically applying correction, range 0-1
feedback_correction_max_feedback_messagesint30Maximum feedback messages used per correction task
feedback_correction_prefilter_enabledbooltrueWhether to enable prefiltering
feedback_correction_paragraph_mark_enabledbooltrueWhether to mark affected paragraphs with corrected-old-fact metadata
feedback_correction_paragraph_hard_filter_enabledbooltrueWhether to hard-filter paragraphs with stale marks in user queries
feedback_correction_profile_refresh_enabledbooltrueWhether to enqueue affected person profiles for refresh
feedback_correction_profile_force_refresh_on_readbooltrueWhether to force-refresh dirty profiles on read
feedback_correction_episode_rebuild_enabledbooltrueWhether to enqueue affected sources for episode rebuild
feedback_correction_episode_query_block_enabledbooltrueWhether to block user queries while episode sources are rebuilding
feedback_correction_reconcile_interval_minutesint5Second-stage consistency polling interval
feedback_correction_reconcile_batch_sizeint20Queue batch size for second-stage consistency

Expression Learning [expression]

[expression] controls expression learning, jargon learning, expression auto-checking, and shared expression groups.

FieldTypeDescription
learning_listlist[LearningItem]Expression learning configuration by chat flow
advanced_chosenboolWhether to enable sub-agent based second-stage expression selection
expression_groupslist[ExpressionGroup]Shared expression learning groups
expression_checked_onlyboolWhether to select only checked and non-rejected expressions
expression_self_reflectboolWhether to enable automatic expression optimization
expression_auto_check_intervalintAuto-check interval in seconds
expression_auto_check_countintNumber of expressions randomly selected for each auto-check
expression_auto_check_custom_criterialist[str]Additional custom evaluation criteria
all_global_jargonboolWhether to enable global jargon mode

learning_list

toml
[[expression.learning_list]]
platform = ""
item_id = ""
rule_type = "group"
use_expression = true
enable_learning = true
enable_jargon_learning = true
FieldTypeDescription
platformstrPlatform. Empty together with item_id means global
item_idstrUser/group ID. Empty together with platform means global
rule_type"group" | "private"Chat flow type
use_expressionboolWhether to use learned expressions
enable_learningboolWhether to enable expression optimization learning
enable_jargon_learningboolWhether to enable jargon learning

Voice [voice]

FieldTypeDefaultDescription
enable_asrboolSee default configWhether to enable speech recognition

Emoji [emoji]

FieldTypeDescription
emoji_send_numintNumber of emoji candidates to choose from when sending, maximum 64
max_reg_numintMaximum number of registered emojis
do_replaceboolWhether to replace old emojis after reaching the maximum
check_intervalintEmoji check interval in minutes
steal_emojiboolWhether to collect emojis from chat
content_filtrationboolWhether to enable emoji filtering
filtration_promptstrEmoji filtering requirement

Keyword Reaction [keyword_reaction]

toml
[[keyword_reaction.keyword_rules]]
keywords = ["keyword"]
reaction = "reaction after trigger"

[[keyword_reaction.regex_rules]]
regex = ["^regex.*"]
reaction = "reaction after trigger"
FieldTypeDescription
keyword_ruleslist[KeywordRuleConfig]Keyword rule list
regex_ruleslist[KeywordRuleConfig]Regex rule list

KeywordRuleConfig fields:

FieldTypeDescription
keywordslist[str]Keyword list
regexlist[str]Regex list
reactionstrReaction after keyword or regex trigger

Response Post-Processing

response_post_process

FieldTypeDescription
enable_response_post_processboolWhether to enable response post-processing, including typo generation and response splitting

chinese_typo

FieldTypeDescription
enableboolWhether to enable Chinese typo generation
error_ratefloatSingle-character replacement probability
min_freqintMinimum character frequency threshold
tone_error_ratefloatTone error probability
word_replace_ratefloatWhole-word replacement probability

response_splitter

FieldTypeDescription
enableboolWhether to enable response splitting
max_lengthintMaximum allowed response length
max_sentence_numintMaximum allowed sentence count
enable_kaomoji_protectionboolWhether to protect kaomoji
enable_overflow_return_allboolWhether to return all content when sentence count exceeds the limit

Telemetry and Debug

telemetry

FieldTypeDescription
enableboolWhether to enable telemetry

debug

FieldTypeDescription
enable_maisaka_stage_boardboolWhether to enable the Maisaka stage board
show_maisaka_thinkingboolWhether to show replyer reasoning
fold_maisaka_thinkingboolWhether to fold the Maisaka prompt display entry
show_jargon_promptboolWhether to show jargon-related prompts
show_memory_promptboolWhether to show memory retrieval prompts
enable_reply_effect_trackingboolWhether to enable reply effect score tracking

Message Service [maim_message]

[maim_message] contains both the legacy WebSocket service and the additional new API Server configuration.

FieldTypeDefaultDescription
ws_server_hoststr127.0.0.1Legacy WebSocket server host
ws_server_portint8080Legacy WebSocket server port
auth_tokenlist[str][]Legacy API auth tokens. Empty means no auth
enable_api_serverboolSee default configWhether to enable the additional new API Server
api_server_hoststrSee default configNew API Server host
api_server_portintSee default configNew API Server port
api_server_use_wssboolSee default configWhether the new API Server uses WSS
api_server_cert_filestr""SSL certificate file path
api_server_key_filestr""SSL key file path
api_server_allowed_api_keyslist[str][]Allowed API key list. Empty allows all connections

WebUI [webui]

FieldTypeDefaultDescription
enabledbooltrueWhether to enable WebUI
hoststr127.0.0.1WebUI bind host
portint8001WebUI bind port
mode"development" | "production""production"WebUI running mode
anti_crawler_mode"false" | "strict" | "loose" | "basic""basic"Anti-crawler mode
allowed_ipsstr127.0.0.1IP whitelist, comma-separated; supports exact IP, CIDR, and wildcard
trusted_proxiesstr""Trusted proxy IP list
trust_xffboolfalseWhether to parse X-Forwarded-For
secure_cookieboolfalseWhether to enable secure cookies, HTTPS only
enable_paragraph_contentboolfalseWhether to load full paragraph content in the knowledge graph; uses extra memory

Database [database]

FieldTypeDefaultDescription
save_binary_databoolfalseWhether to save binary data such as voice as independent files. Only affects newly stored messages

MCP [mcp]

[mcp] controls MaiBot's MCP client host capabilities and external MCP server connections.

FieldTypeDescription
enableboolWhether to enable MCP
clientMCPClientConfigMCP client host capability configuration
serverslist[MCPServerItemConfig]MCP server configuration list

mcp.client

FieldTypeDescription
client_namestrMCP client implementation name
client_versionstrMCP client implementation version
roots.enableboolWhether to expose Roots capability to MCP servers
roots.itemslist[MCPRootItemConfig]Roots list
sampling.enableboolWhether to declare Sampling capability
sampling.task_namestrMain model task name used for Sampling requests
sampling.include_context_supportboolWhether to declare support for non-none includeContext semantics
sampling.tool_supportboolWhether to declare support for continuing to use tools in Sampling
elicitation.enableboolWhether to declare Elicitation capability
elicitation.allow_formboolWhether to allow form-mode Elicitation
elicitation.allow_urlboolWhether to allow URL-mode Elicitation

mcp.servers

toml
[[mcp.servers]]
name = "example"
enabled = true
transport = "stdio"
command = "uvx"
args = ["some-mcp-server"]
env = {}
FieldTypeDescription
namestrServer name, must be unique
enabledboolWhether to enable this server
transport"stdio" | "streamable_http"Transport mode
commandstrCommand used to start the server in stdio mode
argslist[str]Command arguments in stdio mode
envdict[str, str]Extra environment variables in stdio mode
urlstrMCP endpoint in streamable_http mode
headersdict[str, str]Extra HTTP headers
http_timeout_secondsfloatHTTP request timeout
read_timeout_secondsfloatSession read timeout
authorization.mode"none" | "bearer"HTTP authorization mode
authorization.bearer_tokenstrBearer Token, only used when mode = "bearer"

Plugin Runtime [plugin_runtime]

[plugin_runtime] controls the plugin runner and plugin runtime browser rendering capability.

FieldTypeDescription
enabledboolWhether to enable the plugin system
health_check_interval_secfloatHealth check interval
max_restart_attemptsintMaximum auto-restarts after runner crash
runner_spawn_timeout_secfloatTimeout waiting for runner subprocess startup and registration
hook_blocking_timeout_secfloatGlobal timeout for blocking hook steps
ipc_socket_pathstrCustom IPC socket path, Linux/macOS only; empty means auto-generated

plugin_runtime.render

FieldTypeDescription
enabledboolWhether to enable browser rendering in plugin runtime
browser_ws_endpointstrExisting Chromium CDP address to reuse first
executable_pathstrBrowser executable path; empty means auto-detect
browser_install_rootstrPlaywright-managed browser directory
headlessboolWhether to launch browser in headless mode
launch_argslist[str]Browser launch arguments
concurrency_limitintMaximum concurrent rendering tasks
startup_timeout_secfloatBrowser connection or startup timeout
render_timeout_secfloatDefault timeout for a single render
auto_download_chromiumboolWhether to automatically download Playwright Chromium if no browser is found
download_connection_timeout_secfloatConnection timeout when automatically downloading Chromium
restart_after_render_countintRebuild local browser after this many renders; 0 disables this policy

Common Examples

Beginner Minimal Configuration

toml
[bot]
platform = "qq"
qq_account = 123456789
nickname = "MaiMai"
alias_names = ["XiaoMai"]

[chat]
talk_value = 0.7
inevitable_at_reply = true
max_context_size = 30

[memory]
global_memory = false
enable_memory_query_tool = true
person_fact_writeback_enabled = true
chat_summary_writeback_enabled = true

Connect an Adapter

toml
[maim_message]
ws_server_host = "127.0.0.1"
ws_server_port = 8080
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