McpPropertyType.FLOAT emits invalid JSON Schema type "float" in MCP tool inputSchema
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 88/100
Hướng nghiên cứu
Bắt đầu trong azure/functions/decorators/core.py tại định nghĩa McpPropertyType.FLOAT, sau đó so sánh nó với _TYPE_MAPPING và luồng build_property_metadata trong azure/functions/decorators/mcp.py. Cập nhật enum để mục toolProperties được tái tạo sử dụng một kiểu JSON Schema hợp lệ, và xác minh rằng ví dụ công cụ MCP được cung cấp tạo ra "number" thay vì "float".
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
McpPropertyType.FLOAT is defined as "float" in azure/functions/decorators/core.py. When a tool property is declared explicitly with this enum, the value is written as-is into toolProperties and the Functions host copies it into the MCP tool inputSchema.
"float" is not a valid JSON Schema type (valid types: null, boolean, object, array, number, string, integer), and the MCP spec defines inputSchema as a JSON Schema object. Strict MCP clients therefore reject the whole tool. For example, an OpenAI-backed client fails with:
400 Invalid schema for function '<server>-create_music_video': 'float' is not valid under any of the given schemas.
This is also inconsistent within the library itself: type-hint inference in azure/functions/decorators/mcp.py (_TYPE_MAPPING) correctly maps Python float to "number". However, build_property_metadata gives explicit @app.mcp_tool_property(property_type=...) overrides precedence, so declaring McpPropertyType.FLOAT overwrites the correct inferred "number" with "float".
Repro
@app.mcp_tool()
@app.mcp_tool_property(arg_name="a", property_type=func.McpPropertyType.FLOAT)
def tool(a: float) -> str:
...
The resulting toolProperties contains "propertyType": "float". The expected value is "number".
Libraries that generate properties from Pydantic models through the explicit enum path are always affected.
Proposed fix
Change the enum value to the JSON Schema type:
FLOAT = "number"
This follows the existing DATETIME = "string" pattern, where the member name describes the Python type and the value is the wire/JSON Schema type.
Version: azure-functions 2.3.0 (latest on PyPI). The bug is also present on dev.
- Ngôn ngữ chính
- Python
- Star
- 179
- Fork
- 80
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Azure/azure-functions-python-library
-
area:python-functions
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 10/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
-
area:python-functions
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
Azure/azure-functions-python-library#226 · 1 bình luận · 2 reaction ·
-
area:python-functions
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
Tất cả issue của Azure/azure-functions-python-library
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
QuantEcon/lecture-python-programming#642 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/config area/profiles comp/cli needs-decision P3 sweeper:risk-compatibility type/feature
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NousResearch/hermes-agent#133697 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement needs-triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
core
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
vectorize-io/hindsight#5279 ·
Maintainer thường phản hồi trong vòng 1 ngày