Skip to main content
Glama
itshare4u

Agent Knowledge MCP

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

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")
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states that the tool 'overwrites current config', indicating a destructive mutation, which is useful context. However, it lacks details on permissions required, error handling, or confirmation steps, leaving gaps in behavioral understanding for a tool that modifies configuration.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core action ('Reset config.json to defaults from config.default.json') and adds clarifying details ('manual reset - overwrites current config') without any wasted words. Every part of the sentence contributes to understanding the tool's purpose and behavior.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a destructive reset operation), the description is reasonably complete: it explains what the tool does and its overwriting behavior. With an output schema present, the description does not need to detail return values. However, for a mutation tool with no annotations, it could benefit from more context on side effects or safety warnings.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has 0 parameters, and schema description coverage is 100%, so no parameter documentation is needed. The description does not add parameter-specific information, but this is appropriate given the lack of parameters. A baseline score of 4 is applied as it meets expectations for a parameterless tool.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Reset config.json to defaults from config.default.json') and resource ('config.json'), distinguishing it from sibling tools like 'update_config' or 'reload_config'. It explicitly mentions 'manual reset - overwrites current config', which clarifies the operation's nature.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying 'manual reset' and that it 'overwrites current config', suggesting it should be used when reverting to defaults is needed. However, it does not explicitly state when to use this tool versus alternatives like 'update_config' or 'reload_config', nor does it provide exclusions or prerequisites.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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