create-topics
Use this tool to create new Kafka topics in your Confluent cluster by specifying topic names. It integrates with Confluent Kafka and Confluent Cloud REST APIs for streamlined topic management.
Instructions
Create new topic(s) in the Kafka cluster.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| topicNames | Yes |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"topicNames": {
"items": {
"description": "Names of kafka topics to create",
"type": "string"
},
"minItems": 1,
"type": "array"
}
},
"required": [
"topicNames"
],
"type": "object"
}
Implementation Reference
- CreateTopicsHandler class implementing the core logic for the 'create-topics' tool, including the handle method that creates Kafka topics using the admin client.export class CreateTopicsHandler extends BaseToolHandler { async handle( clientManager: ClientManager, toolArguments: Record<string, unknown>, ): Promise<CallToolResult> { const { topicNames } = createTopicArgs.parse(toolArguments); const success = await ( await clientManager.getAdminClient() ).createTopics({ topics: topicNames.map((name) => ({ topic: name })), }); if (!success) { return this.createResponse( `Failed to create Kafka topics: ${topicNames.join(",")}`, true, ); } return this.createResponse(`Created Kafka topics: ${topicNames.join(",")}`); } getToolConfig(): ToolConfig { return { name: ToolName.CREATE_TOPICS, description: "Create one or more Kafka topics.", inputSchema: createTopicArgs.shape, }; } getRequiredEnvVars(): EnvVar[] { return ["KAFKA_API_KEY", "KAFKA_API_SECRET", "BOOTSTRAP_SERVERS"]; } }
- Zod input schema defining the topicNames array for the create-topics tool.const createTopicArgs = z.object({ topicNames: z .array(z.string().describe("Names of kafka topics to create")) .nonempty(), });
- src/confluent/tools/tool-factory.ts:44-44 (registration)Registration of the CreateTopicsHandler in the ToolFactory's handlers Map under the CREATE_TOPICS key.[ToolName.CREATE_TOPICS, new CreateTopicsHandler()],
- src/confluent/tools/tool-name.ts:3-3 (helper)Enum definition for the tool name 'create-topics' used across the codebase.CREATE_TOPICS = "create-topics",