这是indexloc提供的服务,不要输入任何密码
Skip to content

Handle flattened input/output schemas from Abilities API #88

@galatanovidiu

Description

@galatanovidiu

The Abilities API supports both object-based and flattened (simple type) schemas for inputs and outputs. However, MCP requires input_schema.type to always be "object".

This means the MCP adapter needs to transform flattened schemas into object structures when converting Abilities to MCP tools.

Context

Related PR: WordPress/abilities-api#61 (review)

Current Behavior

The Abilities API allows schemas like:

'input_schema' => [
    'type' => 'string',
    'description' => 'Post type to count'
]

Required Behavior

The MCP adapter must transform these into:

{
    "type": "object",
    "properties": {
        "input": {
            "type": "string",
            "description": "Post type to count"
        }
    }
}

Implementation Notes

  1. Property naming: Based on discussion with @gziolo, use "input" for input schemas and "output" for output schemas
  2. When to transform: Apply transformation when type !== "object"
  3. Description: Copy the description from the original schema to the wrapper property if available
  4. Arrays: This should also handle type: "array" cases

Additional Considerations

  • Document this transformation behavior for future adapter implementations
  • Consider adding tests for various simple types (string, number, boolean, array)
  • Ensure the transformation preserves all schema properties (enum, format, etc.)

Acceptance Criteria

  • Adapter successfully transforms flattened input schemas to MCP-compatible object format
  • Adapter successfully transforms flattened output schemas to MCP-compatible object format
  • Tests cover string, number, boolean, and array types
  • Documentation updated to explain the transformation
  • Existing object-based schemas continue to work without modification

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions