Skip to content

fix: preserve optional string tool arguments#2593

Open
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/fastmcp-preserve-str-union
Open

fix: preserve optional string tool arguments#2593
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/fastmcp-preserve-str-union

Conversation

@he-yufeng
Copy link
Copy Markdown

Summary

  • keep str | None and other simple scalar union parameters out of JSON pre-parsing
  • preserve JSON-looking strings for optional string tool arguments, matching existing plain str behavior
  • keep complex unions such as str | list[str] able to decode JSON array inputs

Closes #1873

To verify

  • .venv\Scripts\python.exe -m pytest tests\server\mcpserver\test_func_metadata.py -q --basetemp .tmp\pytest -p no:cacheprovider
  • .venv\Scripts\python.exe -m ruff check src\mcp\server\mcpserver\utilities\func_metadata.py tests\server\mcpserver\test_func_metadata.py
  • .venv\Scripts\python.exe -m ruff format --check src\mcp\server\mcpserver\utilities\func_metadata.py tests\server\mcpserver\test_func_metadata.py
  • .venv\Scripts\python.exe -m py_compile src\mcp\server\mcpserver\utilities\func_metadata.py tests\server\mcpserver\test_func_metadata.py
  • git diff --check

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.

Bug: String parameters starting with digits coerced to numbers, causing UUID data loss

1 participant