Skip to main content
Glama
itshare4u

Agent Knowledge MCP

validate_config

Validate configuration structure, types, and values with detailed error reporting to ensure proper setup.

Instructions

Validate configuration object structure, types, and values with comprehensive error reporting

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
configNoConfiguration object to validate. If not provided, validates current config

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler function for the 'validate_config' MCP tool. Implements comprehensive validation of configuration structure, required sections, data types, and values with detailed error reporting and warnings. Uses FastMCP @app.tool decorator for registration. Handles both provided config objects and current loaded config.
    @app.tool(
        description="Validate configuration object structure, types, and values with comprehensive error reporting",
        tags={"admin", "config", "validate", "check", "schema"}
    )
    async def validate_config(
        config: Annotated[Optional[Dict[str, Any]], Field(description="Configuration object to validate. If not provided, validates current config")] = None
    ) -> str:
        """Validate configuration with comprehensive structure checking and detailed feedback."""
        try:
            if config is None:
                config = load_config()
    
            errors = []
            warnings = []
    
            # Validate structure - required sections
            required_sections = ["elasticsearch", "security", "document_validation", "document_schema", "server"]
            for section in required_sections:
                if section not in config:
                    errors.append(f"Missing required section: {section}")
    
            # Validate elasticsearch section
            if "elasticsearch" in config:
                es_config = config["elasticsearch"]
                if "host" not in es_config:
                    errors.append("elasticsearch.host is required")
                if "port" not in es_config:
                    errors.append("elasticsearch.port is required")
                elif not isinstance(es_config["port"], int):
                    errors.append("elasticsearch.port must be an integer")
                elif es_config["port"] <= 0 or es_config["port"] > 65535:
                    errors.append("elasticsearch.port must be between 1-65535")
    
            # Validate security section
            if "security" in config:
                sec_config = config["security"]
                if "allowed_base_directory" not in sec_config:
                    errors.append("security.allowed_base_directory is required")
                else:
                    base_dir = Path(sec_config["allowed_base_directory"])
                    if not base_dir.exists():
                        warnings.append(f"security.allowed_base_directory does not exist: {base_dir}")
                    elif not base_dir.is_dir():
                        errors.append(f"security.allowed_base_directory is not a directory: {base_dir}")
    
            # Validate document_validation section
            if "document_validation" in config:
                doc_config = config["document_validation"]
                bool_fields = ["strict_schema_validation", "allow_extra_fields", "required_fields_only", "auto_correct_paths"]
                for field in bool_fields:
                    if field in doc_config and not isinstance(doc_config[field], bool):
                        errors.append(f"document_validation.{field} must be a boolean")
    
            # Validate document_schema section
            if "document_schema" in config:
                schema_config = config["document_schema"]
                required_schema_fields = ["required_fields", "field_types", "priority_values", "source_types"]
                for field in required_schema_fields:
                    if field not in schema_config:
                        errors.append(f"document_schema.{field} is required")
    
                # Validate specific schema field types
                if "required_fields" in schema_config:
                    if not isinstance(schema_config["required_fields"], list):
                        errors.append("document_schema.required_fields must be a list")
                    elif not schema_config["required_fields"]:
                        warnings.append("document_schema.required_fields is empty")
    
                if "field_types" in schema_config:
                    if not isinstance(schema_config["field_types"], dict):
                        errors.append("document_schema.field_types must be a dictionary")
                    elif not schema_config["field_types"]:
                        warnings.append("document_schema.field_types is empty")
    
                if "priority_values" in schema_config:
                    if not isinstance(schema_config["priority_values"], list):
                        errors.append("document_schema.priority_values must be a list")
                    elif not schema_config["priority_values"]:
                        warnings.append("document_schema.priority_values is empty")
    
                if "source_types" in schema_config:
                    if not isinstance(schema_config["source_types"], list):
                        errors.append("document_schema.source_types must be a list")
                    elif not schema_config["source_types"]:
                        warnings.append("document_schema.source_types is empty")
    
            # Validate server section
            if "server" in config:
                server_config = config["server"]
                if "name" in server_config and not isinstance(server_config["name"], str):
                    errors.append("server.name must be a string")
                if "version" in server_config and not isinstance(server_config["version"], str):
                    errors.append("server.version must be a string")
    
            # Prepare result message
            if errors:
                message = f"āŒ Configuration validation failed!\n\n🚨 **Errors ({len(errors)}):**\n"
                for i, error in enumerate(errors, 1):
                    message += f"   {i}. {error}\n"
            else:
                message = "āœ… Configuration validation passed!"
    
            if warnings:
                message += f"\nāš ļø **Warnings ({len(warnings)}):**\n"
                for i, warning in enumerate(warnings, 1):
                    message += f"   {i}. {warning}\n"
    
            # Show current validation settings summary
            if "document_validation" in config:
                doc_val = config["document_validation"]
                message += f"\nšŸ“‹ **Current Document Validation Settings:**\n"
                message += f"   šŸ”’ Strict schema validation: {doc_val.get('strict_schema_validation', False)}\n"
                message += f"   šŸ“ Allow extra fields: {doc_val.get('allow_extra_fields', True)}\n"
                message += f"   āœ… Required fields only: {doc_val.get('required_fields_only', False)}\n"
                message += f"   šŸ”§ Auto correct paths: {doc_val.get('auto_correct_paths', True)}\n"
    
            # Show section summary
            sections_found = [s for s in required_sections if s in config]
            message += f"\nšŸ“Š **Configuration Summary:**\n"
            message += f"   šŸ“ Sections found: {len(sections_found)}/{len(required_sections)}\n"
            message += f"   āœ… Valid sections: {', '.join(sections_found)}\n"
            if len(sections_found) < len(required_sections):
                missing = [s for s in required_sections if s not in config]
                message += f"   āŒ Missing sections: {', '.join(missing)}\n"
    
            return message
    
        except json.JSONDecodeError as e:
            return f"āŒ JSON Error: Invalid JSON format in config data\nšŸ” Details: {str(e)}\nšŸ’” Check JSON syntax and structure"
        except Exception as e:
            return _format_admin_error(e, "validate configuration", "config structure validation")
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'comprehensive error reporting', which hints at output behavior, but doesn't specify what happens if validation fails (e.g., returns errors vs. throws exceptions), whether it's read-only or has side effects, or any performance considerations. This leaves significant gaps for a validation tool.

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 purpose ('Validate configuration object structure, types, and values') and adds value with 'comprehensive error reporting'. There is no wasted text, making it highly concise and well-structured for quick understanding.

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 moderate complexity (validation with error reporting), 100% schema coverage, and the presence of an output schema, the description is reasonably complete. It covers what the tool does and hints at output behavior. However, it could improve by addressing usage context or behavioral details, especially since no annotations are provided to fill those gaps.

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%, with the single parameter 'config' well-documented in the schema as 'Configuration object to validate. If not provided, validates current config'. The description adds no additional parameter semantics beyond this, such as examples of valid config structures or validation rules. Baseline 3 is appropriate since the schema does the heavy lifting.

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 tool's purpose: 'Validate configuration object structure, types, and values with comprehensive error reporting.' It specifies the verb (validate), resource (configuration object), and scope (structure, types, values, error reporting). However, it doesn't explicitly differentiate from sibling tools like 'get_config' or 'update_config', which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, such as needing a config object to validate, or compare it to related tools like 'reload_config' or 'reset_config'. Without such context, users might struggle to choose the right tool for validation tasks.

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