list_topics
Lists Kafka cluster topics with partition counts, replication factors, and self-set configs, using an optional JavaScript predicate to filter by name, partitions, replicas, or cleanup policy.
Instructions
List the topics on the endpoint's cluster, sorted by name, each with its partition count, replication factor and the configs it sets for itself.
Filter with an optional JavaScript predicate. A name match is return topic.indexOf('orders') >= 0, and the predicate can also read partitions, replication_factor, internal and configs — questions a substring filter cannot express, such as which topics have more than six partitions, only one replica, or a compacted cleanup policy.
Only configs a topic sets for itself are reported, because inherited cluster defaults would make every topic look configured. Topics whose predicate throws are counted in script_errors rather than listed, so a broken filter is never mistaken for an empty cluster.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | No | Optional JavaScript that decides whether a topic is listed. Return true to keep it. In scope: topic (the name), partitions (number), replication_factor (number), internal (true for Kafka's own topics such as __consumer_offsets) configs (an object of the values this topic sets for itself, such as configs['retention.ms']; inherited cluster defaults are not included) and size_bytes (one copy of the topic's log segments on disk, -1 when the brokers did not report it). Examples: return topic.indexOf('orders') >= 0; return partitions > 6; return configs['cleanup.policy'] === 'compact'; return replication_factor === 1 && !internal. Omit to list every topic. | |
| timeout_seconds | No | Optional wall-clock limit in seconds for evaluating the script. Defaults to 30, at most 3600. A topic whose evaluation is cut short is counted in script_errors rather than listed. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | Yes | ||
| topics | Yes | ||
| warnings | No | ||
| script_errors | No |