Skip to main content
Glama

reset_config

Restore configuration to default settings by overwriting the current config.json file with default values from config.default.json.

Instructions

Reset config.json to defaults from config.default.json (manual reset - overwrites current config)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'reset_config' tool. It resets the config.json file to the contents of config.default.json, creates a timestamped backup of the original config.json if it exists, reloads the configuration, reinitializes security and Elasticsearch components, and returns a detailed status message.
    @app.tool( description="Reset config.json to defaults from config.default.json (manual reset - overwrites current config)", tags={"admin", "config", "reset", "default", "restore"} ) async def reset_config() -> str: """Reset configuration to defaults, creating backup of current config.""" try: import shutil import time from src.config.config import load_config # Use the working config loader # Use same approach as working update_config function script_dir = Path(__file__).parent.parent # /src directory config_path = script_dir / "config.json" default_config_path = script_dir / "config.default.json" # Verify default config exists if not default_config_path.exists(): return f"āŒ **Default Configuration File Not Found!**\n\n🚨 **Error:** Cannot find {default_config_path}\nšŸ“ **Absolute Path:** {default_config_path.absolute()}\n\nšŸ› ļø **Resolution Steps:**\n 1. Verify config.default.json exists in src directory\n 2. Check if file was accidentally deleted or moved\n 3. Try reinstalling AgentKnowledgeMCP package\n\nšŸ’” **Manual Reset:** Copy config.default.json to config.json manually" # Create backup of current config if it exists backup_created = False backup_path = None backup_status = "" if config_path.exists(): try: import time timestamp = int(time.time()) backup_path = config_path.with_name(f"config.backup.{timestamp}.json") import shutil shutil.copy2(config_path, backup_path) backup_created = True backup_status = f"āœ… Current configuration backed up as: {backup_path.name}" except PermissionError: return "āŒ **Backup Creation Failed!**\n\n🚨 **Error:** Insufficient permissions to create backup file\nšŸ“ **Target:** config.backup.[timestamp].json\n\nšŸ› ļø **Resolution:**\n • Check file system permissions for src directory\n • Ensure user has write access to configuration directory\n • Try running with elevated permissions if necessary\n • Verify sufficient disk space for backup creation" except Exception as e: return f"āŒ **Backup Creation Error!**\n\n🚨 **Error:** Cannot create backup of current configuration\nšŸ” **Details:** {str(e)}\n\nšŸ’” **Options:**\n • Check file system permissions and disk space\n • Try manual backup: copy config.json to config.backup.manual.json\n • Proceed with caution if backup creation fails" else: backup_status = "ā„¹ļø No existing config.json to backup" # Copy config.default.json to config.json (overwrite) try: import shutil shutil.copy2(default_config_path, config_path) except PermissionError: return "āŒ **Configuration Reset Failed!**\n\n🚨 **Error:** Insufficient permissions to overwrite config.json\nšŸ“ **Target:** config.json\n\nšŸ› ļø **Resolution:**\n • Check file permissions for config.json\n • Ensure user has write access to configuration file\n • Try running with elevated permissions if necessary\n • Verify config.json is not locked by another process" except Exception as e: return f"āŒ **File Copy Error!**\n\n🚨 **Error:** Cannot copy default configuration\nšŸ” **Details:** {str(e)}\n\nšŸ› ļø **Manual Reset Steps:**\n 1. Copy contents of config.default.json\n 2. Paste into config.json (overwrite existing content)\n 3. Save file and try reloading configuration\n 4. Check file permissions and disk space if issues persist" # Reload configuration after reset try: config = load_config() except Exception as e: return f"āŒ **Configuration Reload Failed!**\n\n🚨 **Error:** Reset completed but cannot load new configuration\nšŸ” **Details:** {str(e)}\n\nāš ļø **Status:** config.json has been reset but system components not reinitialized\n\nšŸ› ļø **Recovery:**\n • Use reload_config tool to reinitialize components\n • Check config.json syntax and structure\n • Verify all required configuration sections are present" # Reinitialize components with reset config component_status = [] try: init_security(config["security"]["allowed_base_directory"]) component_status.append("āœ… Security component reinitialized") except Exception as e: component_status.append(f"āš ļø Security initialization failed: {str(e)}") try: init_elasticsearch(config) reset_es_client() component_status.append("āœ… Elasticsearch components reinitialized") except Exception as e: component_status.append(f"āš ļø Elasticsearch initialization failed: {str(e)}") # Build comprehensive success message message = "šŸŽ‰ **Configuration Reset Completed Successfully!**\n\n" # Reset summary message += f"šŸ“‹ **Reset Summary:**\n" message += f" {backup_status}\n" message += f" āœ… Configuration reset from config.default.json\n" message += f" šŸ”„ All components reinitialized with default settings\n\n" # Component reinitialization status message += f"šŸ”§ **Component Status:**\n" for status in component_status: message += f" {status}\n" message += f"\n" # Configuration details message += f"šŸ“„ **Current Configuration:**\n" try: message += f" šŸ”’ Security Base Directory: {config['security']['allowed_base_directory']}\n" message += f" šŸ” Elasticsearch: {config['elasticsearch']['host']}:{config['elasticsearch']['port']}\n" if "server" in config: server_config = config["server"] message += f" šŸš€ Server: {server_config.get('name', 'AgentKnowledgeMCP')} v{server_config.get('version', '1.0.0')}\n" except Exception as e: message += f" āš ļø Configuration display error: {str(e)}\n" # Next steps guidance message += f"\nšŸ’” **Next Steps:**\n" message += f" • Review reset configuration with get_config tool\n" message += f" • Customize settings using update_config tool\n" message += f" • Test system functionality after reset\n" if backup_created and backup_path: message += f" • Previous settings available in {backup_path.name}\n" # Restore instructions if needed if backup_created and backup_path: message += f"\nšŸ”„ **Restore Previous Configuration (if needed):**\n" message += f" 1. Copy {backup_path.name} to config.json\n" message += f" 2. Use reload_config tool to apply restored settings\n" message += f" 3. Verify components work with restored configuration\n" message += f"\nāœ… **System Ready:** Configuration reset complete with default settings active!" return message except ImportError as e: return f"āŒ Module Error: Missing required module for configuration reset\nšŸ” Details: {str(e)}\nšŸ’” Required modules: shutil (for file operations), time (for backup timestamps)" except FileNotFoundError as e: return f"āŒ File System Error: Required file not found during reset operation\nšŸ” Details: {str(e)}\nšŸ’” Check that both config.json and config.default.json exist in src directory" except Exception as e: return _format_admin_error(e, "reset configuration", "default configuration restore and component reinitialization")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/itshare4u/AgentKnowledgeMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server