alter-topic-config
Modify Kafka topic configurations in Confluent Cloud by setting or deleting parameters. Specify the topic name, cluster ID, and desired configurations to update.
Instructions
Alter topic configuration in Confluent Cloud.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| baseUrl | No | The base URL of the Confluent Cloud Kafka REST API. | |
| clusterId | No | The unique identifier for the Kafka cluster. | |
| topicConfigs | Yes | ||
| topicName | Yes | Name of the topic to alter | |
| validateOnly | No |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"baseUrl": {
"default": "",
"description": "The base URL of the Confluent Cloud Kafka REST API.",
"format": "uri",
"type": "string"
},
"clusterId": {
"description": "The unique identifier for the Kafka cluster.",
"type": "string"
},
"topicConfigs": {
"items": {
"additionalProperties": false,
"properties": {
"name": {
"description": "Configuration parameter name",
"minLength": 1,
"type": "string"
},
"operation": {
"description": "Operation type",
"enum": [
"SET",
"DELETE"
],
"type": "string"
},
"value": {
"description": "Configuration parameter value",
"type": "string"
}
},
"required": [
"name",
"value",
"operation"
],
"type": "object"
},
"minItems": 1,
"type": "array"
},
"topicName": {
"description": "Name of the topic to alter",
"minLength": 1,
"type": "string"
},
"validateOnly": {
"default": false,
"type": "boolean"
}
},
"required": [
"topicName",
"topicConfigs"
],
"type": "object"
}
Implementation Reference
- AlterTopicConfigHandler class implementing the core tool execution logic via the handle() method, using Confluent Cloud Kafka REST API to alter topic configs.export class AlterTopicConfigHandler extends BaseToolHandler { async handle( clientManager: ClientManager, toolArguments: Record<string, unknown>, ): Promise<CallToolResult> { const { clusterId, topicName, topicConfigs, validateOnly, baseUrl } = alterTopicConfigArguments.parse(toolArguments); const kafka_cluster_id = getEnsuredParam( "KAFKA_CLUSTER_ID", "Kafka Cluster ID is required", clusterId, ); if (baseUrl !== undefined && baseUrl !== "") { clientManager.setConfluentCloudKafkaRestEndpoint(baseUrl); } const pathBasedClient = wrapAsPathBasedClient( clientManager.getConfluentCloudKafkaRestClient(), ); const { data: response, error } = await pathBasedClient[ `/kafka/v3/clusters/${kafka_cluster_id}/topics/${topicName}/configs:alter` ].POST({ body: { data: topicConfigs, validate_only: validateOnly, }, }); if (error) { return this.createResponse( `Failed to alter topic config: ${JSON.stringify(error)}`, true, ); } return this.createResponse( `Successfully altered topic config: ${JSON.stringify(response)}`, ); } getToolConfig(): ToolConfig { return { name: ToolName.ALTER_TOPIC_CONFIG, description: "Alter topic configuration in Confluent Cloud.", inputSchema: alterTopicConfigArguments.shape, }; } getRequiredEnvVars(): EnvVar[] { return ["KAFKA_API_KEY", "KAFKA_API_SECRET", "BOOTSTRAP_SERVERS"]; } isConfluentCloudOnly(): boolean { return true; } }
- Zod input schema validation for the tool arguments including baseUrl, clusterId, topicName, topicConfigs array, and validateOnly.const alterTopicConfigArguments = z.object({ baseUrl: z .string() .describe("The base URL of the Confluent Cloud Kafka REST API.") .url() .default(() => env.KAFKA_REST_ENDPOINT ?? "") .optional(), clusterId: z .string() .optional() .describe("The unique identifier for the Kafka cluster."), topicName: z.string().describe("Name of the topic to alter").nonempty(), topicConfigs: z .array( z.object({ name: z.string().describe("Configuration parameter name").nonempty(), value: z.string().describe("Configuration parameter value"), operation: z.enum(["SET", "DELETE"]).describe("Operation type"), }), ) .nonempty(), validateOnly: z.boolean().default(false), });
- src/confluent/tools/tool-factory.ts:60-60 (registration)Registration of the AlterTopicConfigHandler instance in the ToolFactory's static handlers Map using the tool name enum.[ToolName.ALTER_TOPIC_CONFIG, new AlterTopicConfigHandler()],
- src/confluent/tools/tool-name.ts:22-22 (registration)Enum definition ToolName.ALTER_TOPIC_CONFIG = "alter-topic-config" used for tool identification and registration.ALTER_TOPIC_CONFIG = "alter-topic-config",
- src/confluent/tools/tool-factory.ts:18-18 (registration)Import statement for the AlterTopicConfigHandler in ToolFactory.import { AlterTopicConfigHandler } from "@src/confluent/tools/handlers/kafka/alter-topic-config.js";