# convertkit/3.4.4/includes/mcp/abilities/content/class-convertkit-mcp-ability-content-list.php

Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages, version 3.4.4. 189 lines.

- Page: https://pluginprobe.com/plugins/convertkit/3.4.4/code/includes/mcp/abilities/content/class-convertkit-mcp-ability-content-list.php
- Raw: https://pluginprobe.com/plugins/convertkit/3.4.4/raw/includes/mcp/abilities/content/class-convertkit-mcp-ability-content-list.php
- Modified: 2026-08-28T10:49:42+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/convertkit/3.4.4/code/includes/mcp/abilities/content/class-convertkit-mcp-ability-content-list.php#L10-L20`.

```php
<?php
/**
 * Kit MCP Ability: List Kit Elements in a post.
 *
 * @package ConvertKit
 * @author ConvertKit
 */

/**
 * Ability that lists all occurrences of a given Kit element
 * (Broadcast, Form, Form Trigger, Product) within a WordPress Post's content.
 *
 * Registered by an element opting in via the `convertkit_abilities` filter and
 * produces an ability named `kit/<element>-list` (e.g. `kit/form-list`).
 *
 * @package ConvertKit
 * @author  ConvertKit
 */
class ConvertKit_MCP_Ability_Content_List extends ConvertKit_MCP_Ability_Content {

	/**
	 * Sets whether the ability is readonly.
	 *
	 * @since   3.4.0
	 *
	 * @var     bool
	 */
	private $readonly = true; // @phpstan-ignore-line

	/**
	 * Sets whether the ability is idempotent.
	 *
	 * @since   3.4.0
	 *
	 * @var     bool
	 */
	private $idempotent = true; // @phpstan-ignore-line

	/**
	 * Returns the verb this ability represents.
	 *
	 * @since   3.4.0
	 *
	 * @return  string
	 */
	public function get_verb() {

		return 'list';

	}

	/**
	 * Returns the ability's human-readable label.
	 *
	 * @since   3.4.0
	 *
	 * @return  string
	 */
	public function get_label() {

		return sprintf(
			/* translators: %s: block title */
			__( 'List %s in a Post, Page or Custom Post', 'convertkit' ),
			$this->block->get_title_plural()
		);

	}

	/**
	 * Returns the ability's human-readable description.
	 *
	 * @since   3.4.0
	 *
	 * @return  string
	 */
	public function get_description() {

		return sprintf(
			/* translators: Block Name */
			__( 'Lists every %s in the given Post, Page or Custom Post, including each occurrence\'s zero-based index and current attribute values.', 'convertkit' ),
			$this->block->get_title_plural()
		);

	}

	/**
	 * Returns the ability's input JSON Schema.
	 *
	 * @since   3.4.0
	 *
	 * @return  array
	 */
	public function get_input_schema() {

		return array(
			'type'       => 'object',
			'required'   => array( 'post_id' ),
			'properties' => array(
				'post_id' => array(
					'type'        => 'integer',
					'minimum'     => 1,
					'description' => __( 'ID of the post to inspect.', 'convertkit' ),
				),
			),
		);

	}

	/**
	 * Returns the ability's output JSON Schema.
	 *
	 * @since   3.4.0
	 *
	 * @return  array
	 */
	public function get_output_schema() {

		return array(
			'type'       => 'object',
			'required'   => array( 'post_id', 'count', 'occurrences' ),
			'properties' => array(
				'post_id'     => array(
					'type' => 'integer',
				),
				'count'       => array(
					'type'    => 'integer',
					'minimum' => 0,
				),
				'occurrences' => array(
					'type'  => 'array',
					'items' => array(
						'type'       => 'object',
						'required'   => array( 'occurrence_index', 'attrs' ),
						'properties' => array(
							'occurrence_index' => array(
								'type'        => 'integer',
								'minimum'     => 0,
								'description' => __( 'Zero-based occurrence index among this element\'s appearances in the post.', 'convertkit' ),
							),
							'attrs'            => array(
								'type'        => 'object',
								'description' => __( 'Element attributes for this occurrence.', 'convertkit' ),
							),
						),
					),
				),
			),
		);

	}

	/**
	 * Executes the ability.
	 *
	 * @since   3.4.0
	 *
	 * @param   array $input   Ability input.
	 * @return  array|WP_Error
	 */
	public function execute_callback( $input ) {

		// Get Post ID.
		$post_id = isset( $input['post_id'] ) ? absint( $input['post_id'] ) : 0;

		// Bail if no Post ID is provided.
		if ( ! $post_id ) {
			return new WP_Error(
				'convertkit_mcp_missing_post_id',
				__( 'A post_id is required.', 'convertkit' )
			);
		}

		// Find element occurrences in post.
		$occurrences = ConvertKit_Content_Post_Helper::find( $post_id, $this->block->get_name() );
		if ( is_wp_error( $occurrences ) ) {
			return $occurrences;
		}

		// Return result.
		return array(
			'post_id'     => $post_id,
			'count'       => count( $occurrences ),
			'occurrences' => $occurrences,
		);

	}

}

```
