Skip to content

list-fields MCP output schema rejects string-keyed options and array default_value #3580

Closed

Description

@robin-the-going-merry

Requested by: Jonathan Martínez

Problem

formidable-forms/list-fields (MCP/Abilities API) returns the generic MCP error "An error occurred while executing the tool." for some forms while get-form, list-form-actions and list-entries work on the same form. Reported via Help Scout 3485505405/259478 (Formidable Lite/Pro 7.0, WordPress 7.1.3).

Root cause (from code, not yet reproduced on a live site)

FrmAbilitiesFieldsController::prepare_field_for_response() (classes/controllers/FrmAbilitiesFieldsController.php) returns options and default_value unmodified, but the list-fields output schema is stricter than what Formidable stores. WordPress validates ability output against that schema (WP_Ability::validate_output, ability_invalid_output), so one bad field fails the whole form.

  1. options is declared type => array. Choice fields can store options as an associative array keyed by option text (or other_<n> keys). That encodes as an object and fails the array check. Customer form 123 has 8 select/radio fields like this, e.g. {"1":{"label":"","value":""},"Asheville Sun Soo Martial Arts":{"label":"...","value":"..."}, ...} (73 keys).
  2. default_value is declared type => string. Array defaults are saved as JSON (FrmField::update) and decoded back to an array on read (FrmField.php, unserialize_or_decode( $results->default_value )). An Address field default (line1, line2, city, state, ...) fails the string check. Checkbox fields with several defaults likely do too.

Fixing only options will not fix form 123, because it also has an Address field with an object default.

Fix

Widen the output schema. Do NOT array_values() the options: the other_<n> keys are functional.

  • options: type => array( array, object ), with items / additionalProperties of array( string, object ). This is the same shape create-field already accepts for input in this file.
  • default_value: type => array( string, array, object ).
  • Apply the same change to the create-field and update-field output schemas in this file if they declare the same properties (they return prepare_field_for_response() too).
  • Add a PHPUnit test to tests/phpunit/fields/test_FrmAbilitiesFieldsController.php: a choice field with string-keyed options and a field with an array default_value must pass list-fields output validation. Confirm it fails on the current code first.
  • Check formidable-api/controllers/FrmAPIAbilitiesFieldsController.php (separate add-on repo, same schema properties at lines ~73-77, 167-177, 257-265) and file a matching issue there if it has the same strict types.

Notes

  • Non-sequential integer keys (0, 2, 3) probably pass the WordPress array check; only string keys fail. Not confirmed against WP core source.
  • The formidable-mcp-skill docs (references/forms-and-fields.md) already note an earlier fix that added object-form {label, value} items. This is the follow-on: string keys in options, and default_value.

Activity

  1. vivi-the-going-merry commented on Oct 16, 2026

    @vivi-the-going-merry
    Contributor

    Fix is up in #3581. The matching formidable-api follow-up is Strategy11/formidable-api#251.

  2. added this to the 7.1 milestone on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions