Skip to main content
Glama
aywengo

MCP Kafka Schema Reg

check_compatibility

Verify schema compatibility with the latest version in Kafka Schema Registry to ensure data consistency and prevent integration issues.

Instructions

Check if a schema is compatible with the latest version.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNo
registryNo
schema_definitionYes
schema_typeNoAVRO
subjectYes

Implementation Reference

  • The core handler function `check_compatibility_tool` that POSTs the provided schema to the registry's compatibility endpoint (/compatibility/subjects/{subject}/versions/latest) to check backward compatibility with the latest version. Handles single/multi-registry modes, normalizes response fields, adds metadata/links, and uses structured output validation.
    @structured_output("check_compatibility", fallback_on_error=True)
    def check_compatibility_tool(
        subject: str,
        schema_definition: Dict[str, Any],
        registry_manager,
        registry_mode: str,
        schema_type: str = "AVRO",
        context: Optional[str] = None,
        registry: Optional[str] = None,
        auth=None,
        headers=None,
        schema_registry_url: str = "",
    ) -> Dict[str, Any]:
        """
        Check if a schema is compatible with the latest version.
    
        Args:
            subject: The subject name
            schema_definition: The schema definition to check
            schema_type: The schema type (AVRO, JSON, PROTOBUF)
            context: Optional schema context
            registry: Optional registry name (ignored in single-registry mode)
    
        Returns:
            Compatibility check result with structured validation and resource links
        """
        try:
            payload = {"schema": json.dumps(schema_definition), "schemaType": schema_type}
    
            if registry_mode == "single":
                # Single-registry mode: use secure session approach
                client = registry_manager.get_registry()
                if client is None:
                    return create_error_response(
                        "No default registry configured",
                        error_code="REGISTRY_NOT_FOUND",
                        registry_mode="single",
                    )
    
                url = client.build_context_url(f"/compatibility/subjects/{subject}/versions/latest", context)
    
                response = client.session.post(url, data=json.dumps(payload), auth=client.auth, headers=client.headers)
                response.raise_for_status()
                result = response.json()
    
                # Add structured output metadata and normalize field names
                if "is_compatible" not in result:
                    if "isCompatible" in result:
                        result["is_compatible"] = result.pop("isCompatible")
                    elif "compatible" in result:
                        result["is_compatible"] = result.pop("compatible")
                    else:
                        # Fallback: set default value if no compatibility field is found
                        logger.warning(f"No compatibility field found in response: {result.keys()}")
                        result["is_compatible"] = False
    
                result["registry_mode"] = "single"
                result["mcp_protocol_version"] = "2025-06-18"
    
                # Add resource links
                registry_name = _get_registry_name(registry_mode, registry)
                result = add_links_to_response(result, "compatibility", registry_name, subject=subject, context=context)
    
                return result
            else:
                # Multi-registry mode: use client approach
                client = registry_manager.get_registry(registry)
                if client is None:
                    return create_error_response(
                        f"Registry '{registry}' not found",
                        error_code="REGISTRY_NOT_FOUND",
                        registry_mode="multi",
                    )
    
                url = client.build_context_url(f"/compatibility/subjects/{subject}/versions/latest", context)
    
                response = client.session.post(url, data=json.dumps(payload), auth=client.auth, headers=client.headers)
                response.raise_for_status()
                result = response.json()
    
                # Add structured output metadata and normalize field names
                if "is_compatible" not in result:
                    if "isCompatible" in result:
                        result["is_compatible"] = result.pop("isCompatible")
                    elif "compatible" in result:
                        result["is_compatible"] = result.pop("compatible")
                    else:
                        # Fallback: set default value if no compatibility field is found
                        logger.warning(f"No compatibility field found in response: {result.keys()}")
                        result["is_compatible"] = False
    
                result["registry"] = client.config.name
                result["registry_mode"] = "multi"
                result["mcp_protocol_version"] = "2025-06-18"
    
                # Add resource links
                result = add_links_to_response(
                    result,
                    "compatibility",
                    client.config.name,
                    subject=subject,
                    context=context,
                )
    
                return result
        except Exception as e:
            return create_error_response(str(e), error_code="COMPATIBILITY_CHECK_FAILED", registry_mode=registry_mode)
  • JSON Schema defining the expected output format for the check_compatibility tool response, including is_compatible boolean, compatibility_level, messages array, and metadata.
    CHECK_COMPATIBILITY_SCHEMA = {
        "type": "object",
        "properties": {
            "is_compatible": {
                "type": "boolean",
                "description": "Whether the schema is compatible",
            },
            "compatibility_level": {
                "type": "string",
                "enum": [
                    "BACKWARD",
                    "FORWARD",
                    "FULL",
                    "NONE",
                    "BACKWARD_TRANSITIVE",
                    "FORWARD_TRANSITIVE",
                    "FULL_TRANSITIVE",
                ],
                "description": "Compatibility level used for check",
            },
            "messages": {
                "type": "array",
                "items": {"type": "string"},
                "description": "Detailed compatibility messages",
            },
            "registry": {
                "type": "string",
                "description": "Registry name (multi-registry mode)",
            },
            **METADATA_FIELDS,
        },
        "required": ["is_compatible"],
        "additionalProperties": True,
    }
  • The check_compatibility tool is registered/mapped to its output schema CHECK_COMPATIBILITY_SCHEMA in the central TOOL_OUTPUT_SCHEMAS dictionary used for structured validation.
    "check_compatibility": CHECK_COMPATIBILITY_SCHEMA,
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions checking compatibility but doesn't disclose behavioral traits such as whether this is a read-only operation, if it modifies data, what permissions are needed, or how results are returned. This is inadequate for a tool with 5 parameters and no output schema.

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 without waste. It's appropriately sized for a basic tool definition, though this conciseness comes at the cost of detail in other dimensions.

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

Completeness2/5

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

Given the complexity (5 parameters, nested objects, no output schema, and no annotations), the description is incomplete. It doesn't explain return values, error conditions, or how compatibility is determined, making it insufficient for an agent to use the tool effectively without additional context.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate by explaining parameters. It adds no meaning beyond the schema, failing to clarify what 'subject', 'schema_definition', 'schema_type', 'registry', or 'context' mean in this compatibility check context, leaving parameters largely undocumented.

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

Purpose3/5

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

The description states the tool's purpose as checking schema compatibility with the latest version, which is clear but vague. It specifies the action ('check') and resource ('schema'), but doesn't distinguish it from sibling tools like 'check_compatibility_interactive' or 'guided_schema_evolution', leaving ambiguity about scope and method.

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. With siblings like 'check_compatibility_interactive' and 'guided_schema_evolution', there's no indication of prerequisites, context, or exclusions, leaving the agent to guess based on tool names alone.

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

Related 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/aywengo/kafka-schema-reg-mcp'

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