Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions includes/mcp/class-convertkit-mcp.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public function __construct() {
// Register MCP resources (live-state lists, account, settings and reference docs).
add_filter( 'convertkit_resources', array( $this, 'register_mcp_resources' ) );

// Register MCP prompts (guided workflows).
add_filter( 'convertkit_prompts', array( $this, 'register_mcp_prompts' ) );

// Register settings get / update abilities for each Plugin settings
// These are owned by the Plugin (not by any single feature),
// so they're added here rather than via a per-class register_abilities().
Expand Down Expand Up @@ -243,6 +246,34 @@ public function register_mcp_resources( $resources ) {

}

/**
* Appends the MCP prompts (guided workflows) to the convertkit_prompts
* filter, so they are registered with the Abilities API and exposed as
* MCP Prompts.
*
* @since 3.5.0
*
* @param array $prompts Prompts to register.
* @return array
*/
public function register_mcp_prompts( $prompts ) {

$mcp_prompts = array(
new ConvertKit_MCP_Prompt_Setup(),
new ConvertKit_MCP_Prompt_Add_Form(),
new ConvertKit_MCP_Prompt_Restrict_Content(),
new ConvertKit_MCP_Prompt_Configure_Broadcasts_Import(),
new ConvertKit_MCP_Prompt_Audit(),
);

foreach ( $mcp_prompts as $prompt ) {
$prompts[ $prompt->get_name() ] = $prompt;
}

return $prompts;

}

/**
* Register the 'kit' ability category.
*
Expand Down
122 changes: 122 additions & 0 deletions includes/mcp/prompts/class-convertkit-mcp-prompt-add-form.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php
/**
* Kit MCP Prompt: Add Form.
*
* @package ConvertKit
* @author ConvertKit
*/

/**
* Guided workflow to show a Kit Form as a default, on a post or category, or
* inline in content. Produces a prompt named `kit/add-form`.
*
* @package ConvertKit
* @author ConvertKit
*/
class ConvertKit_MCP_Prompt_Add_Form extends ConvertKit_MCP_Prompt {

/**
* Returns the prompt's short name.
*
* @since 3.5.0
*
* @return string
*/
protected function get_prompt_name() {

return 'add-form';

}

/**
* Returns the prompt's label.
*
* @since 3.5.0
*
* @return string
*/
public function get_label() {

return __( 'Add a Kit Form', 'convertkit' );

}

/**
* Returns the prompt's description.
*
* @since 3.5.0
*
* @return string
*/
public function get_description() {

return __( 'Show a Kit Form as a site default, on a single post or page, on a category, or inline in content.', 'convertkit' );

}

/**
* Returns the prompt's arguments.
*
* @since 3.5.0
*
* @return array
*/
protected function get_arguments() {

return array(
'form' => array(
'description' => __( 'The Kit Form to add, by name or numeric ID.', 'convertkit' ),
),
'scope' => array(
'description' => __( 'Where to add it: default, post, category or inline.', 'convertkit' ),
),
);

}

/**
* Returns the prompt text.
*
* @since 3.5.0
*
* @param array $input Prompt arguments.
* @return array|WP_Error
*/
public function execute_callback( $input ) {

$form = isset( $input['form'] ) ? trim( (string) $input['form'] ) : '';
$scope = isset( $input['scope'] ) ? trim( (string) $input['scope'] ) : '';

$provided = array();
if ( '' !== $form ) {
/* translators: %s: Form name or ID. */
$provided[] = sprintf( __( '- Requested Form: %s', 'convertkit' ), $form );
}
if ( '' !== $scope ) {
/* translators: %s: scope. */
$provided[] = sprintf( __( '- Requested scope: %s', 'convertkit' ), $scope );
}

return $this->render(
array(
'# ' . __( 'Add a Kit Form', 'convertkit' ),
__( 'Goal: show a Kit Form as a site default, on a single post or page, on a category, or inline in content.', 'convertkit' ),
count( $provided ) ? implode( "\n", $provided ) : '',
'## ' . __( 'Preflight', 'convertkit' ),
__( '- Read `kit://forms` and map the requested Form to its numeric ID. If nothing matches, list the available Forms and ask the user.', 'convertkit' ),
__( '- See `kit://reference/forms` for how the Form shown on a post is resolved (post overrides category overrides the default).', 'convertkit' ),
'## ' . __( 'Choose the scope', 'convertkit' ),
__( '- **Default for a post type** — `kit/settings-general-update`.', 'convertkit' ),
__( '- **A single Page or Post** — `kit/post-settings-update`, setting `form` (needs `post_id`).', 'convertkit' ),
__( '- **A category** — `kit/category-settings-update`.', 'convertkit' ),
__( '- **Inline at a chosen position in the content** — `kit/form-insert`.', 'convertkit' ),
'## ' . __( 'Steps', 'convertkit' ),
__( '1. Confirm the Form and the scope with the user.', 'convertkit' ),
__( '2. Apply it with the matching tool above. Confirm before writing.', 'convertkit' ),
__( '3. Verify with the matching read tool (e.g. `kit/post-settings-get`).', 'convertkit' ),
)
);

}

}
87 changes: 87 additions & 0 deletions includes/mcp/prompts/class-convertkit-mcp-prompt-audit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php
/**
* Kit MCP Prompt: Audit.
*
* @package ConvertKit
* @author ConvertKit
*/

/**
* Guided, read-only workflow to review the Kit configuration and report gaps.
* Produces a prompt named `kit/audit`.
*
* @package ConvertKit
* @author ConvertKit
*/
class ConvertKit_MCP_Prompt_Audit extends ConvertKit_MCP_Prompt {

/**
* Returns the prompt's short name.
*
* @since 3.5.0
*
* @return string
*/
protected function get_prompt_name() {

return 'audit';

}

/**
* Returns the prompt's label.
*
* @since 3.5.0
*
* @return string
*/
public function get_label() {

return __( 'Audit Kit configuration', 'convertkit' );

}

/**
* Returns the prompt's description.
*
* @since 3.5.0
*
* @return string
*/
public function get_description() {

return __( 'Review the Kit connection, default Forms and per-post settings, and report gaps and misconfigurations. Read only — makes no changes.', 'convertkit' );

}

/**
* Returns the prompt text.
*
* @since 3.5.0
*
* @param array $input Prompt arguments (unused).
* @return array|WP_Error
*/
public function execute_callback( $input ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found

return $this->render(
array(
'# ' . __( 'Audit Kit configuration', 'convertkit' ),
__( 'Goal: review the current Kit setup and report gaps. This is read only — do not change any settings; if the user wants a fix, point them to the relevant prompt (setup, add-form, restrict-content).', 'convertkit' ),
'## ' . __( 'Gather', 'convertkit' ),
__( '- `kit://account` — is the site connected?', 'convertkit' ),
__( '- `kit://settings` — default Forms, broadcasts and restrict-content configuration.', 'convertkit' ),
__( '- `kit://forms`, `kit://tags`, `kit://products` — what exists on the account.', 'convertkit' ),
__( '- For a sample of published Pages and Posts, `kit/post-settings-get` to see their Form / Landing Page / Tag / Restrict Content settings.', 'convertkit' ),
'## ' . __( 'Report', 'convertkit' ),
__( '- Whether the account is connected and which account it is.', 'convertkit' ),
__( '- Whether a default Form is set per post type, and which.', 'convertkit' ),
__( '- Content that references a Form, Tag or Product ID that no longer exists on the account.', 'convertkit' ),
__( '- Where Restrict Content is in use, and any content that looks like it should be gated but is not.', 'convertkit' ),
__( 'Summarise findings as a short list, most important first, with the suggested fix for each.', 'convertkit' ),
)
);

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
/**
* Kit MCP Prompt: Configure Broadcasts Import.
*
* @package ConvertKit
* @author ConvertKit
*/

/**
* Guided workflow to set up importing Kit Broadcasts into WordPress as posts.
* Produces a prompt named `kit/configure-broadcasts-import`.
*
* @package ConvertKit
* @author ConvertKit
*/
class ConvertKit_MCP_Prompt_Configure_Broadcasts_Import extends ConvertKit_MCP_Prompt {

/**
* Returns the prompt's short name.
*
* @since 3.5.0
*
* @return string
*/
protected function get_prompt_name() {

return 'configure-broadcasts-import';

}

/**
* Returns the prompt's label.
*
* @since 3.5.0
*
* @return string
*/
public function get_label() {

return __( 'Import Kit Broadcasts as posts', 'convertkit' );

}

/**
* Returns the prompt's description.
*
* @since 3.5.0
*
* @return string
*/
public function get_description() {

return __( 'Set up importing Kit Broadcasts (emails) into WordPress as posts, and how the imported posts are assigned.', 'convertkit' );

}

/**
* Returns the prompt text.
*
* @since 3.5.0
*
* @param array $input Prompt arguments (unused).
* @return array|WP_Error
*/
public function execute_callback( $input ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found

return $this->render(
array(
'# ' . __( 'Import Kit Broadcasts as posts', 'convertkit' ),
__( 'Goal: turn Kit Broadcasts (emails) into WordPress posts automatically, and control how those posts are assigned.', 'convertkit' ),
'## ' . __( 'Preflight', 'convertkit' ),
__( '- Read `kit://account` to confirm the site is connected, and `kit://settings` for the current broadcasts settings.', 'convertkit' ),
'## ' . __( 'Steps', 'convertkit' ),
__( '1. Ask the user whether to enable importing, and which author, category and post status imported posts should use (and whether to import the email thumbnail as the featured image).', 'convertkit' ),
__( '2. Apply with `kit/settings-broadcasts-update`. Confirm before writing.', 'convertkit' ),
__( '3. Verify with `kit/settings-broadcasts-get`.', 'convertkit' ),
__( 'Note: once enabled, importing runs automatically on a schedule — there is no manual "import now" step to call here.', 'convertkit' ),
)
);

}

}
Loading