Skip to main content
Glama

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

NameRequiredDescriptionDefault
scriptNoOptional 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_secondsNoOptional 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

NameRequiredDescriptionDefault
countYes
topicsYes
warningsNo
script_errorsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changedv0.2.7
    • changedInput schema / properties / script / description
      Previous value: -"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) and configs (an object of the values this topic sets for itself, such as configs['retention.ms']; inherited cluster defaults are not included). Examples: return topic.indexOf('orders') >= 0; return partitions > 6; return configs['cleanup.policy'] === 'compact'; return replication_factor === 1 && !internal. Omit to list every topic."New value: +"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."
    • changedInput schema / properties / timeout_seconds / description
      Previous value: -"Optional wall-clock limit in seconds for evaluating the script. Defaults to 30. A topic whose evaluation is cut short is counted in script_errors rather than listed."New value: +"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."
    • addedOutput schema / properties / topics / items / properties / size_bytes
      Added value: +{
      +  "type": "integer"
      +}
    • changedOutput schema / properties / topics / items / required
      Previous value: -[
      -  "topic",
      -  "partitions",
      -  "replication_factor"
      -]New value: +[
      +  "topic",
      +  "partitions",
      +  "replication_factor",
      +  "size_bytes"
      +]
    • addedOutput schema / properties / warnings
      Added value: +{
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": [
      +    "null",
      +    "array"
      +  ]
      +}
  2. First observedv0.2.0

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the burden and does well: it discloses that topics whose predicate throws are tallied in script_errors rather than silently dropped, and explains why only self-set configs appear (inherited defaults would make every topic look configured). It omits any statement about read-only nature, permissions, or result size limits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the action and result shape, then filter guidance, then the two edge-case guarantees. Every sentence carries information, though the config-scoping rationale is stated in the description while also being restated in the schema's parameter text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists so return values need no explanation; the description still covers the two things an agent could get wrong — filter expressiveness and silent-failure behavior via script_errors. No meaningful gap remains for a read-style listing tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3; the description goes further by explaining the predicate's purpose, naming the readable fields (partitions, replication_factor, internal, configs), and clarifying the error-routing semantics of a throwing script. The timeout parameter is left to the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('List the topics on the endpoint's cluster') plus the exact shape of each row: name sort order, partition count, replication factor, and self-set configs. That is clearly distinguishable from siblings like describe_topic (single topic detail) or list_clusters (cluster inventory).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete usage context by showing what the optional predicate is for and contrasting it with a substring filter ('questions a substring filter cannot express, such as which topics have more than six partitions'). It never explicitly excludes or routes to a sibling such as describe_topic, so it stops short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.