delete-topics
Remove Kafka topics by specifying their names to manage and optimize your Confluent Kafka environment. Supports bulk deletion for streamlined topic management.
Instructions
Delete the topic with the given names.
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 delete",
"type": "string"
},
"minItems": 1,
"type": "array"
}
},
"required": [
"topicNames"
],
"type": "object"
}
Implementation Reference
- DeleteTopicsHandler class implementing the core logic for the 'delete-topics' tool. The handle() method parses input, deletes topics using Kafka admin client, and returns a success response.export class DeleteTopicsHandler extends BaseToolHandler { async handle( clientManager: ClientManager, toolArguments: Record<string, unknown>, ): Promise<CallToolResult> { const { topicNames } = deleteKafkaTopicsArguments.parse(toolArguments); await ( await clientManager.getAdminClient() ).deleteTopics({ topics: topicNames }); return this.createResponse(`Deleted Kafka topics: ${topicNames.join(",")}`); } getToolConfig(): ToolConfig { return { name: ToolName.DELETE_TOPICS, description: "Delete the topic with the given names.", inputSchema: deleteKafkaTopicsArguments.shape, }; } getRequiredEnvVars(): EnvVar[] { return ["KAFKA_API_KEY", "KAFKA_API_SECRET", "BOOTSTRAP_SERVERS"]; } }
- Zod schema defining the input arguments for the delete-topics tool: a non-empty array of topic names.const deleteKafkaTopicsArguments = z.object({ topicNames: z .array(z.string().describe("Names of kafka topics to delete")) .nonempty(), });
- src/confluent/tools/tool-factory.ts:45-45 (registration)Registration of the DeleteTopicsHandler in the ToolFactory's static handlers Map using the ToolName.DELETE_TOPICS constant.[ToolName.DELETE_TOPICS, new DeleteTopicsHandler()],
- src/confluent/tools/tool-factory.ts:21-21 (registration)Import statement for the DeleteTopicsHandler in ToolFactory.import { DeleteTopicsHandler } from "@src/confluent/tools/handlers/kafka/delete-topics-handler.js";
- src/confluent/tools/tool-name.ts:4-4 (registration)ToolName enum definition for 'delete-topics' used in registration and tool config.DELETE_TOPICS = "delete-topics",