Skip to main content
Glama
lensesio

Lenses MCP Server

by lensesio

create_topic_with_schema

Create Kafka topics with configurable formats and schemas for structured data streaming. Define partitions, replication, and data formats like AVRO or JSON.

Instructions

Creates a new Kafka topic with optional format and schema configuration.

Args: environment: The environment name. name: Topic name. partitions: Number of partitions (default: 1). replication: Replication factor (default: 1). configs: Topic configurations. key_format: Key format (AVRO, JSON, CSV, XML, INT, LONG, STRING, BYTES, etc.). key_schema: Key schema (required for AVRO, JSON, CSV, XML). value_format: Value format. value_schema: Value schema.

Returns: Creation result.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
environmentYes
nameYes
partitionsNo
replicationNo
configsNo
key_formatNo
key_schemaNo
value_formatNo
value_schemaNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function decorated with @mcp.tool(), implementing the logic to create a Kafka topic with schema support via HTTP API request to Lenses.
    @mcp.tool()
    async def create_topic_with_schema(
        environment: str,
        name: str,
        partitions: int = 1,
        replication: int = 1,
        configs: Optional[Dict[str, str]] = None,
        key_format: Optional[str] = None,
        key_schema: Optional[str] = None,
        value_format: Optional[str] = None,
        value_schema: Optional[str] = None
    ) -> Dict[str, Any]:
        """
        Creates a new Kafka topic with optional format and schema configuration.
        
        Args:
            environment: The environment name.
            name: Topic name.
            partitions: Number of partitions (default: 1).
            replication: Replication factor (default: 1).
            configs: Topic configurations.
            key_format: Key format (AVRO, JSON, CSV, XML, INT, LONG, STRING, BYTES, etc.).
            key_schema: Key schema (required for AVRO, JSON, CSV, XML).
            value_format: Value format.
            value_schema: Value schema.
        
        Returns:
            Creation result.
        """
        payload = {
            "name": name,
            "partitions": partitions,
            "replication": replication
        }
        
        if configs:
            payload["configs"] = configs
        else:
            payload["configs"] = {}
        
        if key_format or value_format:
            format_config = {}
            if key_format:
                format_config["key"] = {"format": key_format}
                if key_schema:
                    format_config["key"]["schema"] = key_schema
            if value_format:
                format_config["value"] = {"format": value_format}
                if value_schema:
                    format_config["value"]["schema"] = value_schema
            payload["format"] = format_config
        
        endpoint = f"/api/v1/environments/{environment}/proxy/api/v1/kafka/topic"
        try:
            return await api_client._make_request("POST", endpoint, payload)
        except Exception as e:
            raise ToolError(f"Topic creation failed: {e}")
  • Invocation of register_topics(mcp) which defines and registers the create_topic_with_schema tool among others.
    register_topics(mcp)
  • Function that contains the definition of all topic tools including create_topic_with_schema, which are registered when this function is called.
    def register_topics(mcp: FastMCP):
Behavior2/5

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

With no annotations provided, the description carries full burden but only states it 'Creates' without disclosing behavioral traits like permissions needed, whether it's idempotent, error handling, or rate limits. It mentions a return but doesn't describe what 'Creation result' entails beyond the 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.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with a clear summary sentence followed by structured Args and Returns sections. Every sentence adds value, though the parameter explanations could be more front-loaded in the summary for better initial clarity.

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

Completeness3/5

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

For a 9-parameter creation tool with no annotations, the description covers parameters well but lacks behavioral context. The presence of an output schema reduces the need to explain returns, but more guidance on usage and error cases would improve completeness given the tool's complexity.

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

Parameters4/5

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

Schema description coverage is 0%, but the description compensates by listing all 9 parameters with brief explanations, including defaults for partitions and replication, and clarifying when key_schema is required. It adds meaningful context beyond the bare schema, though some details like configs structure remain vague.

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

Purpose5/5

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

The description clearly states the verb 'Creates' and the resource 'new Kafka topic', specifying it includes 'optional format and schema configuration'. It distinguishes from sibling 'create_topic' by explicitly mentioning schema capabilities, making the purpose specific and differentiated.

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

Usage Guidelines3/5

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

The description implies usage for creating topics with schema configuration, but doesn't explicitly state when to use this vs. the simpler 'create_topic' sibling tool. It mentions optional parameters but lacks clear guidance on alternatives or exclusions.

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/lensesio/lenses-mcp'

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