add_topic_partitions
Increase the partition count of an existing Kafka topic to handle higher message throughput or improve parallel processing.
Instructions
Add partitions to an existing topic.
Args: environment: The environment name. topic_name: Name of the topic. partitions: New total number of partitions.
Returns: Updated partition count.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| environment | Yes | ||
| topic_name | Yes | ||
| partitions | Yes |
Implementation Reference
- src/lenses_mcp/tools/topics.py:192-211 (handler)The main handler function for the 'add_topic_partitions' tool. It constructs a payload with the new partition count and sends a PUT request to the API endpoint to increase the number of partitions on the specified Kafka topic.@mcp.tool() async def add_topic_partitions( environment: str, topic_name: str, partitions: int ) -> Dict[str, Any]: """ Add partitions to an existing topic. Args: environment: The environment name. topic_name: Name of the topic. partitions: New total number of partitions. Returns: Updated partition count. """ payload = {"partitions": partitions} endpoint = f"/api/v1/environments/{environment}/proxy/api/v1/kafka/topics/{topic_name}/partitions" return await api_client._make_request("PUT", endpoint, payload)
- src/lenses_mcp/server.py:33-33 (registration)The call to register_topics(mcp) which defines and registers the 'add_topic_partitions' tool (and other topic tools) with the MCP server.register_topics(mcp)