Skip to content

fix: accept JSON string inputs in update_assets_tool (AICHAT-595)#213

Closed
mothership-ai[bot] wants to merge 1 commit intomainfrom
fix/AICHAT-595-update-assets-string-input
Closed

fix: accept JSON string inputs in update_assets_tool (AICHAT-595)#213
mothership-ai[bot] wants to merge 1 commit intomainfrom
fix/AICHAT-595-update-assets-string-input

Conversation

@mothership-ai
Copy link
Copy Markdown

@mothership-ai mothership-ai Bot commented Mar 9, 2026

Summary

  • Add explicit Union[..., str] type annotations to update_assets_tool parameters (assets and attribute_values) so FastMCP/Pydantic validation accepts JSON string inputs from MCP clients
  • The existing parse_json_parameter/parse_list_parameter utilities already handle string→dict/list conversion in the function body; this change ensures strings pass Pydantic validation before reaching that code
  • Add 19 regression tests covering string input parsing, native dict passthrough, and error handling

Context

MCP clients (ChatGPT, remote MCP proxies) may serialize tool parameters as JSON strings rather than native JSON objects. This causes Pydantic validation errors like:

  • updates.dict[any,any]: Input should be a valid dictionary (got input_type=str)
  • updates.list[any]: Input should be a valid list (got input_type=str)

Applies the same defensive parsing pattern established in PR #87.

Linked: AICHAT-595 | ZD #120072

Test plan

  • Unit tests for parse_json_parameter — dict passthrough, list passthrough, string→dict, string→list, None, invalid JSON
  • Unit tests for parse_list_parameter — list passthrough, string→list, single value wrap, None, string→dict wrap
  • Integration tests for update_assets_tool — assets as JSON string, attribute_values as JSON string, both as strings, list of assets as string, invalid JSON error, native dict passthrough, readme update with string params
  • All 19 tests passing

🤖 Generated with Claude Code

MCP clients (e.g. ChatGPT, remote MCP proxies) may serialize tool
parameters as JSON strings rather than native dicts/lists. When
FastMCP/Pydantic validates these inputs, string values are rejected
with "Input should be a valid dictionary (got input_type=str)".

Add explicit Union[..., str] type annotations to the assets and
attribute_values parameters so Pydantic accepts string inputs. The
existing parse_json_parameter/parse_list_parameter utilities in the
function body already handle string-to-dict/list conversion.

Closes AICHAT-595

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mothership-ai mothership-ai Bot requested review from Hk669 and firecast as code owners March 9, 2026 08:59
@mothership-ai
Copy link
Copy Markdown
Author

mothership-ai Bot commented Mar 9, 2026

Closing - fix needs to go in agent-toolkit-internal (the hosted version customers use), not the OSS repo.

@mothership-ai mothership-ai Bot closed this Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant