Skip to main content
Glama

mcp-confluent

Official
by confluentinc

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

NameRequiredDescriptionDefault
baseUrlNoThe base URL of the Confluent Cloud Kafka REST API.
clusterIdNoThe unique identifier for the Kafka cluster.
topicConfigsYes
topicNameYesName of the topic to alter
validateOnlyNo

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), });
  • Registration of the AlterTopicConfigHandler instance in the ToolFactory's static handlers Map using the tool name enum.
    [ToolName.ALTER_TOPIC_CONFIG, new AlterTopicConfigHandler()],
  • Enum definition ToolName.ALTER_TOPIC_CONFIG = "alter-topic-config" used for tool identification and registration.
    ALTER_TOPIC_CONFIG = "alter-topic-config",
  • Import statement for the AlterTopicConfigHandler in ToolFactory.
    import { AlterTopicConfigHandler } from "@src/confluent/tools/handlers/kafka/alter-topic-config.js";

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/confluentinc/mcp-confluent'

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