Skip to main content
Glama
aywengo

MCP Kafka Schema Reg

export_context

Export all subjects within a specified context, including metadata, configurations, and versions, for Kafka Schema Registry management and analysis.

Instructions

Export all subjects within a context.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextYes
include_configNo
include_metadataNo
include_versionsNoall
registryNo

Implementation Reference

  • Primary MCP tool handler implementing export_context with progress reporting, registry mode handling (single/multi), error handling, resource linking, and delegation to core common_export_context function.
    @structured_output("export_context", fallback_on_error=True)
    async def export_context_tool(
        context: str,
        registry_manager,
        registry_mode: str,
        registry: Optional[str] = None,
        include_metadata: bool = True,
        include_config: bool = True,
        include_versions: str = "all",
        mcp_context: Optional["Context"] = None,
    ) -> Dict[str, Any]:
        """
        Export all subjects within a context.
    
        Args:
            context: The context name
            registry: Optional registry name (ignored in single-registry mode)
            include_metadata: Include export metadata
            include_config: Include configuration data
            include_versions: Which versions to include (all, latest)
            mcp_context: MCP Context for progress reporting
    
        Returns:
            Dictionary containing context export data with structured validation and resource links
        """
        try:
            # Initial setup (0-10%)
            if mcp_context:
                await mcp_context.info(f"Starting context export: {context}")
                await mcp_context.report_progress(0.0, 100.0, "Initializing context export")
    
            if registry_mode == "single":
                # Single-registry mode: use common function
                client = get_default_client(registry_manager)
                if client is None:
                    return create_error_response(
                        "No default registry configured",
                        error_code="REGISTRY_NOT_CONFIGURED",
                        registry_mode="single",
                    )
    
                if mcp_context:
                    await mcp_context.report_progress(5.0, 100.0, "Using default registry client")
    
                result = common_export_context(client, context, include_metadata, include_config, include_versions)
                result["registry_mode"] = "single"
                result["mcp_protocol_version"] = "2025-06-18"
    
                # Add resource links
                registry_name = _get_registry_name_for_linking(registry_mode, client, registry)
                result = add_links_to_response(result, "context", registry_name, context=context)
    
                if mcp_context:
                    await mcp_context.info("Context export completed successfully")
                    await mcp_context.report_progress(100.0, 100.0, "Context export completed")
    
                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",
                    )
    
                if mcp_context:
                    await mcp_context.report_progress(10.0, 100.0, f"Registry client '{registry}' initialized")
    
                # Get all subjects in context (10-25%)
                if mcp_context:
                    await mcp_context.info(f"Fetching subjects from context: {context}")
                    await mcp_context.report_progress(15.0, 100.0, f"Fetching subjects from context '{context}'")
    
                subjects_list = client.get_subjects(context)
                if isinstance(subjects_list, dict) and "error" in subjects_list:
                    return create_error_response(
                        f"Failed to get subjects for context '{context}': {subjects_list.get('error')}",
                        error_code="CONTEXT_SUBJECTS_RETRIEVAL_FAILED",
                        registry_mode=registry_mode,
                    )
    
                if mcp_context:
                    await mcp_context.report_progress(25.0, 100.0, f"Found {len(subjects_list)} subjects in context")
    
                # Export each subject (25-70%)
                subjects_data = []
                if mcp_context:
                    await mcp_context.info(f"Exporting {len(subjects_list)} subjects")
                    await mcp_context.report_progress(30.0, 100.0, f"Starting export of {len(subjects_list)} subjects")
    
                for i, subject in enumerate(subjects_list):
                    # Report progress for subject export
                    if mcp_context and len(subjects_list) > 0:
                        progress = 30.0 + (i / len(subjects_list)) * 40.0  # 30% to 70%
                        await mcp_context.report_progress(
                            progress, 100.0, f"Exporting subject {i+1}/{len(subjects_list)}: {subject}"
                        )
    
                    subject_export = export_subject_tool(
                        subject,
                        registry_manager,
                        registry_mode,
                        context,
                        include_metadata,
                        include_config,
                        include_versions,
                        registry,
                    )
                    if "error" not in subject_export:
                        subjects_data.append(subject_export)
    
                if mcp_context:
                    await mcp_context.report_progress(70.0, 100.0, f"Exported {len(subjects_data)} subjects successfully")
    
                # Build result structure (70-80%)
                if mcp_context:
                    await mcp_context.report_progress(75.0, 100.0, "Building export result structure")
    
                result = {
                    "context": context,
                    "subjects": subjects_data,
                    "subject_count": len(subjects_data),
                    "registry": client.config.name,
                    "registry_mode": registry_mode,
                    "mcp_protocol_version": "2025-06-18",
                }
    
                # Add configuration data if requested (80-90%)
                if include_config:
                    if mcp_context:
                        await mcp_context.report_progress(80.0, 100.0, "Fetching context configuration")
    
                    global_config = client.get_global_config(context)
                    if "error" not in global_config:
                        result["global_config"] = global_config
    
                    global_mode = client.get_mode(context)
                    if "error" not in global_mode:
                        result["global_mode"] = global_mode
    
                    if mcp_context:
                        await mcp_context.report_progress(85.0, 100.0, "Context configuration added")
                else:
                    if mcp_context:
                        await mcp_context.report_progress(85.0, 100.0, "Skipping context configuration")
    
                # Add metadata if requested (90-95%)
                if include_metadata:
                    if mcp_context:
                        await mcp_context.report_progress(90.0, 100.0, "Adding export metadata")
    
                    from datetime import datetime
    
                    result["metadata"] = {
                        "exported_at": datetime.now().isoformat(),
                        "registry_url": client.config.url,
                        "registry_name": client.config.name,
                        "export_version": "2.0.0",
                        "registry_mode": "multi",
                    }
    
                # Add resource links (95-100%)
                if mcp_context:
                    await mcp_context.report_progress(95.0, 100.0, "Adding resource links")
    
                registry_name = _get_registry_name_for_linking(registry_mode, client, registry)
                result = add_links_to_response(result, "context", registry_name, context=context)
    
                if mcp_context:
                    await mcp_context.info("Context export completed successfully")
                    await mcp_context.report_progress(100.0, 100.0, "Context export completed")
    
                return result
        except Exception as e:
            if mcp_context:
                await mcp_context.error(f"Context export failed: {str(e)}")
            return create_error_response(str(e), error_code="CONTEXT_EXPORT_FAILED", registry_mode=registry_mode)
  • Core helper function containing the fundamental export logic: lists subjects in the given context, recursively exports each subject's versions/config, assembles context-level result with optional global config, mode, and metadata.
    def export_context(
        client: RegistryClient,
        context: str,
        include_metadata: bool = True,
        include_config: bool = True,
        include_versions: str = "all",
    ) -> Dict[str, Any]:
        """Export all subjects within a context."""
        try:
            # Get all subjects in context
            subjects_list = client.get_subjects(context)
    
            # Export each subject
            subjects_data = []
            for subject in subjects_list:
                subject_export = export_subject(
                    client,
                    subject,
                    context,
                    include_metadata,
                    include_config,
                    include_versions,
                )
                if "error" not in subject_export:
                    subjects_data.append(subject_export)
    
            result = {"context": context, "subjects": subjects_data}
    
            if include_config:
                global_config = client.get_global_config(context)
                if "error" not in global_config:
                    result["global_config"] = global_config
    
                global_mode = client.get_mode(context)
                if "error" not in global_mode:
                    result["global_mode"] = global_mode
    
            if include_metadata:
                result["metadata"] = {
                    "exported_at": datetime.now().isoformat(),
                    "registry_url": client.config.url,
                    "export_version": "1.7.0",
                }
    
            return result
        except Exception as e:
            return {"error": str(e)}
  • JSON Schema output validation definition for the export_context tool (noted as complex structure allowing additional properties).
    "export_context": {
        "type": "object",
        "additionalProperties": True,
    },  # Complex export structure
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'export' but fails to explain what that entails—whether it's a read-only operation, if it requires specific permissions, what the output format is, or any side effects. This leaves critical behavioral traits unspecified.

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, straightforward sentence with no wasted words, making it easy to parse quickly. It's appropriately sized for its content, though the 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 the complexity implied by 5 parameters, no annotations, no output schema, and 0% schema description coverage, the description is incomplete. It doesn't cover what 'export' means in practice, the parameter roles, or the expected output, leaving the agent with insufficient context for effective use.

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?

The input schema has 5 parameters with 0% description coverage, and the tool description adds no information about any parameters. It doesn't explain what 'context', 'include_config', 'include_metadata', 'include_versions', or 'registry' mean or how they affect the export, failing to compensate for the schema's lack of descriptions.

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 'Export all subjects within a context' clearly states the action (export) and target (subjects within a context), but it's vague about what 'export' entails (e.g., format, destination, or purpose). It doesn't differentiate from sibling tools like 'export_global' or 'export_subject', leaving ambiguity about scope and alternatives.

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 is provided on when to use this tool versus alternatives such as 'export_global' or 'export_subject'. The description lacks context about prerequisites, exclusions, or typical use cases, offering no help in tool selection.

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