Skip to main content
Glama
aywengo

MCP Kafka Schema Reg

create_context

Create a new schema context for Kafka Schema Registry to organize and manage schema definitions effectively. Simplify schema governance and ensure compatibility across messaging systems.

Instructions

Create a new schema context.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contextYes
registryNo

Implementation Reference

  • The core handler function that implements the 'create_context' tool logic. Sends POST to /contexts/{context} in Kafka Schema Registry to create the context, handles registry modes, viewonly checks, error handling, and adds MCP-standard metadata and HATEOAS links.
    @structured_output("create_context", fallback_on_error=True)
    def create_context_tool(
        context: str,
        registry_manager,
        registry_mode: str,
        registry: Optional[str] = None,
        auth=None,
        headers=None,
        schema_registry_url: str = "",
    ) -> Dict[str, str]:
        """
        Create a new schema context.
    
        Args:
            context: The context name to create
            registry: Optional registry name (ignored in single-registry mode)
    
        Returns:
            Success message with structured validation and resource links
        """
        # Check viewonly mode
        viewonly_check = _check_viewonly_mode(registry_manager, registry)
        if viewonly_check:
            return validate_registry_response(viewonly_check, registry_mode)
    
        try:
            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",
                    )
    
                response = client.session.post(
                    f"{client.config.url}/contexts/{context}", auth=client.auth, headers=client.headers
                )
                response.raise_for_status()
                result = create_success_response(f"Context '{context}' created successfully", registry_mode="single")
    
                # Add resource links
                registry_name = _get_registry_name(registry_mode, registry)
                result = add_links_to_response(result, "context", registry_name, 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",
                    )
    
                response = client.session.post(
                    f"{client.config.url}/contexts/{context}", auth=client.auth, headers=client.headers
                )
                response.raise_for_status()
                result = create_success_response(
                    f"Context '{context}' created successfully",
                    data={"registry": client.config.name},
                    registry_mode="multi",
                )
    
                # Add resource links
                result = add_links_to_response(result, "context", client.config.name, context=context)
    
                return result
        except Exception as e:
            return create_error_response(str(e), error_code="CONTEXT_CREATE_FAILED", registry_mode=registry_mode)
  • JSON Schema definition for the output of the create_context tool (CONTEXT_OPERATION_SCHEMA), used for structured validation.
    CONTEXT_OPERATION_SCHEMA = {
        "type": "object",
        "properties": {
            "message": {"type": "string", "description": "Operation result message"},
            "context": {"type": "string", "description": "Context name"},
            "registry": {
                "type": "string",
                "description": "Registry name (multi-registry mode)",
            },
            **METADATA_FIELDS,
        },
        "required": ["message"],
        "additionalProperties": True,
    }
  • Registration of the create_context tool's output schema in the master TOOL_OUTPUT_SCHEMAS dictionary, mapping tool name to its output schema for MCP compliance.
    "list_contexts": LIST_CONTEXTS_SCHEMA,
    "create_context": CONTEXT_OPERATION_SCHEMA,
    "delete_context": CONTEXT_OPERATION_SCHEMA,
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 'Create a new schema context' which implies a write operation, but doesn't cover permissions, side effects, error handling, or what 'new' entails (e.g., overwriting, uniqueness). This leaves significant gaps in understanding the tool's behavior.

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, clear sentence with no wasted words. It's front-loaded with the core action and resource, making it highly efficient and easy to parse, which is ideal for conciseness.

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 (a creation tool with 2 parameters, no annotations, and no output schema), the description is incomplete. It doesn't explain what a 'schema context' is, how parameters are used, what happens on success/failure, or how this differs from interactive versions. For a tool with no structured support, more context is needed.

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 'schema context' but doesn't explain the 'context' parameter (a required string) or the optional 'registry' parameter. No additional meaning is provided beyond the basic action, failing to clarify parameter roles or formats.

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 'Create a new schema context' clearly states the action (create) and resource (schema context), which is adequate. However, it doesn't differentiate from sibling tools like 'create_context_interactive' or explain what a 'schema context' is specifically, making it somewhat vague compared to more specific 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 like 'create_context_interactive' or other context-related tools such as 'list_contexts' or 'delete_context'. The description lacks any context about prerequisites, timing, or comparisons, leaving the agent with no usage direction.

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