Skip to content

[BUG] normalized tool property default type incorrect for objects and arrays #1190

@jrowen

Description

@jrowen

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

1.16.0

Python Version

3.11

Operating System

Linux

Installation Method

pip

Steps to Reproduce

When loading tools via the MCP client, the tool normalization steps cause tool use errors when the inputSchema includes more complex data types (e.g. List[str], List[Model], etc.).

  • The MCP server will describe this property using anyOf (e.g. for List[str] | None, one will see "anyOf": [{"items": {"type": "string"},"type": "array"},{"type": "null"}])
  • When the MCPClient normalizes the tools, in the _normalize_property function, it sets the default type to string
  • This causes the model to return string encoded json data to the tool (e.g. '["foo", "bar"]' leading to tool input validation errors

Looking at this line, to fix this issue, I would suggest checking not "anyOf" in prop_def before setting the default type. If anyOf is present, omit a default type value.

Expected Behavior

The tool inputSchema should not set type="string" for properties defined using anyOf.

Actual Behavior

The tool inputSchema is being setdefault to type="string" when it should be omitted.

Additional Context

No response

Possible Solution

No response

Related Issues

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions