config_manager.py•565 B
import json
import os
from pathlib import Path
CONFIG_PATH = Path.home() / ".xiaozhi_mcp_config.json"
def load_config():
try:
with open(CONFIG_PATH, 'r', encoding='utf-8') as f:
return json.load(f)
except (FileNotFoundError, json.JSONDecodeError):
return {
"MCP_ENDPOINT": "wss://api.xiaozhi.me/mcp/?token=...",
"ZHIPU_API_KEY": "xxxxxxxxxxxxxxxxxxxxxx",
}
def save_config(config):
with open(CONFIG_PATH, 'w', encoding='utf-8') as f:
json.dump(config, f, indent=2)