Skip to main content
Glama

update_config

Modify specific sections or replace entire configurations in the Agent Knowledge MCP server. Update individual keys or manage complete configs for streamlined system adjustments.

Instructions

Update configuration with section-specific changes or full configuration replacement

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
config_keyNoThe key within the section to update (e.g., 'allowed_base_directory')
config_sectionNoThe top-level section of the config to update (e.g., 'security')
config_valueNoThe new value for the specified key
full_configNoFull configuration object to save. Replaces the entire config

Implementation Reference

  • Handler function for the 'update_config' MCP tool. Updates config.json with either full replacement or section/key updates, performs basic validation, and automatically reinitializes affected components (security, Elasticsearch). Defines input schema via Annotated parameters.
    @app.tool( description="Update configuration with section-specific changes or full configuration replacement", tags={"admin", "config", "update", "modify", "settings"} ) async def update_config( config_section: Annotated[Optional[str], Field(description="The top-level section of the config to update (e.g., 'security')")] = None, config_key: Annotated[Optional[str], Field(description="The key within the section to update (e.g., 'allowed_base_directory')")] = None, config_value: Annotated[Optional[str], Field(description="The new value for the specified key")] = None, full_config: Annotated[Optional[Dict[str, Any]], Field(description="Full configuration object to save. Replaces the entire config")] = None ) -> str: """Update configuration with comprehensive validation and automatic component reinitialization.""" try: config_path = Path(__file__).parent.parent / "config.json" if full_config: # Full configuration replacement new_config = full_config # Validate new config structure required_sections = ["elasticsearch", "security", "document_validation", "server"] for section in required_sections: if section not in new_config: return f"❌ Error: Missing required config section '{section}'\n💡 Required sections: {', '.join(required_sections)}" # Write new config with open(config_path, 'w', encoding='utf-8') as f: json.dump(new_config, f, indent=2, ensure_ascii=False) message = "✅ Full configuration updated successfully!" elif config_section and config_key is not None: # Section-specific key update config = load_config() if config_section not in config: return f"❌ Error: Config section '{config_section}' not found\n💡 Available sections: {', '.join(config.keys())}" # Store old value for comparison old_value = config[config_section].get(config_key, "<not set>") # Update the value config[config_section][config_key] = config_value # Write updated config with open(config_path, 'w', encoding='utf-8') as f: json.dump(config, f, indent=2, ensure_ascii=False) message = f"✅ Configuration updated successfully!\n\n" message += f"📁 Section: {config_section}\n" message += f"🔑 Key: {config_key}\n" message += f"📤 Old value: {old_value}\n" message += f"📥 New value: {config_value}" else: return "❌ Error: Must provide either 'full_config' or both 'config_section' and 'config_key'\n💡 Choose: Section-specific update (config_section + config_key + config_value) OR Full replacement (full_config)" # Reload configuration in current session new_config = load_config() # Reinitialize security if security section was updated if (config_section == "security" and config_key == "allowed_base_directory") or full_config: init_security(new_config["security"]["allowed_base_directory"]) # Reinitialize Elasticsearch if elasticsearch section was updated if (config_section == "elasticsearch") or full_config: init_elasticsearch(new_config) reset_es_client() return message + f"\n\n💡 Configuration reloaded automatically - all components reinitialized" except json.JSONDecodeError as e: return f"❌ JSON Error: Invalid JSON format in full_config\n🔍 Details: {str(e)}\n💡 Check JSON syntax and structure" except Exception as e: return _format_admin_error(e, "update configuration", f"config_section={config_section}, config_key={config_key}")
  • Mounts the admin_server_app into the main FastMCP app, making the update_config tool (and others) available to the main server, likely with or without prefix for backward compatibility.
    # This provides: admin_get_config, admin_update_config, admin_server_status, etc. app.mount(admin_server_app)

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