Skip to main content
Glama
itshare4u

Agent Knowledge MCP

update_config

Modify configuration settings for the Agent Knowledge MCP server by updating specific sections or replacing the entire configuration.

Instructions

Update configuration with section-specific changes or full configuration replacement

Input Schema

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler implementation for the 'update_config' tool. It supports updating specific config sections/keys or replacing the entire config.json file. Includes validation for required sections, automatic reinitialization of security and Elasticsearch components, and comprehensive error handling with user-friendly messages.
    @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}")
  • Registers the admin_server_app (containing update_config and other admin tools) by mounting it into the main FastMCP application. This makes the tools available server-wide, potentially with 'admin_' prefix as per comments.
    # Mount Administrative operations server with 'admin' prefix
    # This provides: admin_get_config, admin_update_config, admin_server_status, etc.
    app.mount(admin_server_app)
    
    # Mount Prompt server for AgentKnowledgeMCP guidance
  • Configuration rule in confirmation system that requires user confirmation for 'update_config' tool execution, with 60-minute timeout.
    "admin_tools": {
        "tools": ["update_config", "reset_config", "setup_elasticsearch"],
        "require_confirmation": True,
        "timeout_minutes": 60
    },
  • Input schema definition using Pydantic Annotated fields for config_section, config_key, config_value (for partial updates) or full_config (for complete replacement).
    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:
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is an update operation (implying mutation) but doesn't mention permissions required, whether changes are reversible, side effects, or how it interacts with tools like 'reload_config'. For a configuration mutation tool, this is a significant gap in transparency.

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 immediately conveys the core functionality. It's front-loaded with the main purpose and mentions both operation modes without unnecessary elaboration. Every word earns its place.

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

Completeness3/5

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

Given this is a mutation tool with no annotations but with 100% schema coverage and an output schema (implied by 'Has output schema: true'), the description is minimally adequate. However, for a configuration update operation that could have significant system impact, more behavioral context would be helpful despite the structured data coverage.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all four parameters thoroughly. The description adds minimal value by hinting at the two usage modes (section-specific vs full replacement), which aligns with the schema's structure but doesn't provide additional semantic context beyond what's in the parameter descriptions.

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

Purpose4/5

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

The description clearly states the verb ('Update') and resource ('configuration'), and specifies two modes: 'section-specific changes' and 'full configuration replacement'. This distinguishes it from sibling tools like 'get_config' or 'reset_config', though it doesn't explicitly name those alternatives.

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

Usage Guidelines3/5

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

The description implies usage context by mentioning two modes (section-specific vs full replacement), but doesn't provide explicit guidance on when to choose one over the other or mention related tools like 'reset_config' or 'reload_config'. The agent must infer usage from the parameter descriptions.

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