McpPropertyType.FLOAT emits invalid JSON Schema type "float" in MCP tool inputSchema
Évaluation
- Difficulté
- 1/5
- Temps estimé
- Moins d'une heure
- Accessibilité débutants
- 88/100
Piste de recherche
Commencez dans azure/functions/decorators/core.py à la définition de McpPropertyType.FLOAT, puis comparez-la avec _TYPE_MAPPING et le flux de build_property_metadata dans azure/functions/decorators/mcp.py. Mettez à jour l’enum afin que l’entrée toolProperties reproduite utilise un type JSON Schema valide, et vérifiez que l’exemple d’outil MCP fourni produit "number" plutôt que "float".
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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.
- Langage dominant
- Python
- Étoiles
- 179
- Forks
- 80
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de Azure/azure-functions-python-library
-
area:python-functions
Difficulté 1/5 Moins d'une heure Accessibilité débutants 10/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 30/100
-
area:python-functions
Difficulté 3/5 1-2 jours Accessibilité débutants 25/100
Azure/azure-functions-python-library#226 · 1 commentaire · 2 réactions ·
-
area:python-functions
Difficulté 4/5 3-5 jours Accessibilité débutants 20/100
Toutes les issues de Azure/azure-functions-python-library
Issues similaires
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 75/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 85/100
data-umbrella/du-event-board#225 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100