Skip to main content
Glama
aywengo

MCP Kafka Schema Reg

export_schema

Export Kafka Schema Registry schemas in a specified format. Define subject, version, context, and registry to generate the desired output.

Instructions

Export a single schema in the specified format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextNo
formatNojson
registryNo
subjectYes
versionNolatest

Implementation Reference

  • The main handler function for the 'export_schema' tool. It handles parameters, gets the appropriate registry client, calls the common export function, adds metadata and links, and returns structured output or error.
    @structured_output("export_schema", fallback_on_error=True)
    def export_schema_tool(
        subject: str,
        registry_manager,
        registry_mode: str,
        version: str = "latest",
        context: Optional[str] = None,
        format: str = "json",
        registry: Optional[str] = None,
    ) -> Union[Dict[str, Any], str]:
        """
        Export a single schema in the specified format.
    
        Args:
            subject: The subject name
            version: The schema version (default: latest)
            context: Optional schema context
            format: Export format (json, avro_idl)
            registry: Optional registry name (ignored in single-registry mode)
    
        Returns:
            Exported schema data with structured validation and resource links
        """
        try:
            if registry_mode == "single":
                client = get_default_client(registry_manager)
            else:
                client = registry_manager.get_registry(registry)
    
            if client is None:
                return create_error_response(
                    "No registry configured or registry not found",
                    error_code="REGISTRY_NOT_CONFIGURED",
                    registry_mode=registry_mode,
                )
    
            result = common_export_schema(client, subject, version, context, format)
    
            if isinstance(result, dict):
                # Add structured output metadata
                result["registry_mode"] = registry_mode
                result["mcp_protocol_version"] = "2025-06-18"
    
                # Ensure required fields for export schema
                if "subject" not in result:
                    result["subject"] = subject
                if "version" not in result:
                    result["version"] = version if version != "latest" else 1
                if "format" not in result:
                    result["format"] = format
    
                # Ensure content field is present - this is required by the schema
                if "content" not in result:
                    # Generate content from schema field
                    if "schema" in result:
                        if format == "json":
                            result["content"] = json.dumps(result["schema"], indent=2)
                        else:
                            result["content"] = str(result["schema"])
                    else:
                        result["content"] = ""
    
                # Add resource links for dictionary results
                registry_name = _get_registry_name_for_linking(registry_mode, client, registry)
                result = add_links_to_response(
                    result,
                    "schema",
                    registry_name,
                    subject=subject,
                    version=version,
                    context=context,
                )
    
            return result
        except Exception as e:
            return create_error_response(str(e), error_code="SCHEMA_EXPORT_FAILED", registry_mode=registry_mode)
  • JSON Schema definition for the output of the 'export_schema' tool, ensuring structured responses with required fields like subject, version, format, and content.
    EXPORT_SCHEMA_SCHEMA = {
        "type": "object",
        "properties": {
            "subject": {"type": "string", "description": "Subject name"},
            "version": {"type": "integer", "minimum": 1, "description": "Schema version"},
            "format": {
                "type": "string",
                "enum": ["json", "avro-idl"],
                "description": "Export format",
            },
            "content": {"type": "string", "description": "Exported schema content"},
            "metadata": {"type": "object", "description": "Schema metadata"},
            **METADATA_FIELDS,
        },
        "required": ["subject", "version", "format", "content"],
        "additionalProperties": True,
  • Mapping of 'export_schema' tool name to its output schema in the TOOL_OUTPUT_SCHEMAS dictionary, used for validation.
    "export_schema": EXPORT_SCHEMA_SCHEMA,
  • Core helper function implementing the schema export logic, called by the tool handler. Fetches schema data and optionally converts to Avro IDL format.
    def export_schema(
        client: RegistryClient,
        subject: str,
        version: str = "latest",
        context: Optional[str] = None,
        format: str = "json",
    ) -> Union[Dict[str, Any], str]:
        """Export a single schema in the specified format."""
        try:
            schema_data = get_schema_with_metadata(client, subject, version, context)
            if "error" in schema_data:
                return schema_data
    
            if format == "avro_idl":
                schema_str = schema_data.get("schema", "")
                return format_schema_as_avro_idl(schema_str, subject)
            else:
                return schema_data
        except Exception as e:
            return {"error": str(e)}
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 states the tool exports a schema but doesn't disclose behavioral traits like whether this is a read-only operation, what permissions are required, if it modifies data, rate limits, or what the output looks like. For a tool with 5 parameters and no annotation coverage, this is insufficient.

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 with no wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly, though this brevity contributes to gaps 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 5 parameters with 0% schema coverage, no annotations, no output schema, and multiple sibling export tools, the description is incomplete. It doesn't explain what a 'schema' is in this context, how parameters interact, or what the export produces, leaving significant gaps for the agent to operate effectively.

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 for undocumented parameters. It mentions 'specified format' which hints at the 'format' parameter but doesn't explain the other 4 parameters (context, registry, subject, version) or their relationships. The description adds minimal value beyond what the schema provides through property names.

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 action ('Export') and resource ('a single schema'), but is vague about what 'schema' refers to in this context and doesn't distinguish from siblings like 'export_context', 'export_global', or 'export_subject'. It specifies 'in the specified format' which adds some detail but remains generic.

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?

No guidance on when to use this tool versus alternatives like 'export_context' or 'export_subject'. The description implies it's for exporting schemas, but doesn't specify use cases, prerequisites, or exclusions, leaving the agent to infer usage from the tool name 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