create-topic-tags
Define and organize new topic tags in Confluent Cloud using the Schema Registry REST API to streamline data categorization and management.
Instructions
Create new tag definitions in Confluent Cloud.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| baseUrl | No | The base URL of the Schema Registry REST API. | |
| tags | Yes | Array of tag definitions to create |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"baseUrl": {
"default": "",
"description": "The base URL of the Schema Registry REST API.",
"format": "uri",
"type": "string"
},
"tags": {
"description": "Array of tag definitions to create",
"items": {
"additionalProperties": false,
"properties": {
"description": {
"default": "Tag created via API",
"description": "Description for the tag",
"type": "string"
},
"tagName": {
"description": "Name of the tag to create",
"minLength": 1,
"type": "string"
}
},
"required": [
"tagName"
],
"type": "object"
},
"minItems": 1,
"type": "array"
}
},
"required": [
"tags"
],
"type": "object"
}
Implementation Reference
- The handle() method in CreateTopicTagsHandler that implements the core logic: parses args, sets endpoint if provided, creates tag definitions for kafka_topic entities, POSTs to /catalog/v1/types/tagdefs, and returns success/error response.async handle( clientManager: ClientManager, toolArguments: Record<string, unknown>, ): Promise<CallToolResult> { const { tags, baseUrl } = createTagsArguments.parse(toolArguments); if (baseUrl !== undefined && baseUrl !== "") { clientManager.setConfluentCloudSchemaRegistryEndpoint(baseUrl); } const pathBasedClient = wrapAsPathBasedClient( clientManager.getConfluentCloudSchemaRegistryRestClient(), ); const tagDefinitions = tags.map((tag) => ({ entityTypes: ["kafka_topic"], name: tag.tagName, description: tag.description, })); const { data: response, error } = await pathBasedClient[ "/catalog/v1/types/tagdefs" ].POST({ body: tagDefinitions, }); if (error) { return this.createResponse( `Failed to create tag: ${JSON.stringify(error)}`, true, ); } return this.createResponse( `Successfully created tag: ${JSON.stringify(response)}`, ); }
- Zod schema defining input parameters: optional baseUrl (Schema Registry endpoint) and non-empty array of tags with tagName and optional description.const createTagsArguments = z.object({ baseUrl: z .string() .describe("The base URL of the Schema Registry REST API.") .url() .default(() => env.SCHEMA_REGISTRY_ENDPOINT ?? "") .optional(), tags: z .array( z.object({ tagName: z.string().describe("Name of the tag to create").nonempty(), description: z .string() .describe("Description for the tag") .default("Tag created via API"), }), ) .nonempty() .describe("Array of tag definitions to create"), });
- src/confluent/tools/tool-factory.ts:55-55 (registration)Registration of the CreateTopicTagsHandler instance in the ToolFactory's static handlers Map, keyed by ToolName.CREATE_TOPIC_TAGS.[ToolName.CREATE_TOPIC_TAGS, new CreateTopicTagsHandler()],
- Enum constant defining the tool name string "create-topic-tags" used across the codebase for consistency.CREATE_TOPIC_TAGS = "create-topic-tags",
- Tool configuration including name, description, and inputSchema, returned by the handler for tool registration.getToolConfig(): ToolConfig { return { name: ToolName.CREATE_TOPIC_TAGS, description: "Create new tag definitions in Confluent Cloud.", inputSchema: createTagsArguments.shape, }; }