Skip to main content
Glama

create_topic

Create a new Kafka topic with configurable partitions, replication, and settings for data streaming in Apache Kafka environments.

Instructions

Creates a new Kafka topic with optional configuration.

Args: environment: The environment name. topic_name: Topic name. partitions: Number of partitions (default: 1). replication: Replication factor (default: 1). configs: Topic configurations.

Returns: Creation result.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
environmentYes
topic_nameYes
partitionsNo
replicationNo
configsNo

Implementation Reference

  • The @mcp.tool()-decorated handler function that implements the logic for creating a new Kafka topic by making a POST request to the API endpoint with the specified parameters.
    @mcp.tool() async def create_topic( environment: str, topic_name: str, partitions: int = 1, replication: int = 1, configs: Optional[Dict[str, str]] = None ) -> str: """ Creates a new Kafka topic with optional configuration. Args: environment: The environment name. topic_name: Topic name. partitions: Number of partitions (default: 1). replication: Replication factor (default: 1). configs: Topic configurations. Returns: Creation result. """ payload = { "topicName": topic_name, "partitions": partitions, "replication": replication } if configs: payload["configs"] = configs else: payload["configs"] = {} endpoint = f"/api/v1/environments/{environment}/proxy/api/topics" try: return await api_client._make_request("POST", endpoint, payload) except Exception as e: raise ToolError(f"Topic creation failed: {e}")
  • The call to register_topics(mcp) which defines and registers the create_topic tool along with other topic-related tools.
    register_topics(mcp)

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

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