Description
When calling an ability via MCP Adapter with an empty object {} as parameters, the InputValidator incorrectly rejects it with the error message "input er ikke av typen object" (Norwegian: "input is not of type object").
This happens despite {} being a valid JSON object that should pass validation for abilities with optional properties.
Steps to Reproduce
- Register an ability with optional properties in
input_schema:
wp_register_ability( 'example/get-info', array(
'input_schema' => array(
'type' => 'object',
'properties' => array(
'fields' => array(
'type' => 'array',
'items' => array( 'type' => 'string' ),
),
),
),
// ... other config
) );
- Call the ability with empty parameters:
{
"ability_name": "example/get-info",
"parameters": {}
}
- Expected: Ability executes successfully (no required properties)
- Actual: Error:
Ability "example/get-info" has invalid input. Reason: input is not of type object.
Workaround
Passing any property value (even empty) works:
{
"ability_name": "example/get-info",
"parameters": {"fields": []}
}
Environment
- MCP Adapter version: 0.4.1
- WordPress version: 6.9
- PHP version: 8.x
- MCP Client: Claude Desktop (via claude.ai MCP integration)
Analysis
The issue appears to be in the InputValidator logic that checks if the input is of type "object". An empty object {} should be considered a valid object, but the validator seems to be treating it as invalid (possibly checking for non-empty or using empty() which returns true for {}).
Related Issues
Suggested Fix
The InputValidator should accept empty objects {} as valid when:
- The schema type is "object"
- There are no required properties
- The input is actually an object (even if empty)
Description
When calling an ability via MCP Adapter with an empty object
{}as parameters, the InputValidator incorrectly rejects it with the error message "input er ikke av typen object" (Norwegian: "input is not of type object").This happens despite
{}being a valid JSON object that should pass validation for abilities with optional properties.Steps to Reproduce
input_schema:{ "ability_name": "example/get-info", "parameters": {} }Ability "example/get-info" has invalid input. Reason: input is not of type object.Workaround
Passing any property value (even empty) works:
{ "ability_name": "example/get-info", "parameters": {"fields": []} }Environment
Analysis
The issue appears to be in the InputValidator logic that checks if the input is of type "object". An empty object
{}should be considered a valid object, but the validator seems to be treating it as invalid (possibly checking for non-empty or usingempty()which returns true for{}).Related Issues
ExecuteAbilityAbility#76 - Fix parameter handling for abilities without input schemasSuggested Fix
The InputValidator should accept empty objects
{}as valid when: