Form elicitation fails when a multi-select field has only one string option

Ouverte
#3,975 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
72/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python

Piste de recherche

Start in mcp.server.elicitation.render_elicitation_schema and trace how Pydantic turns list[Literal["email"]] into the elicitation items schema. Compare the generated schema with the multi-option case and inspect the validation against PrimitiveSchemaDefinition. Add a regression test for the single-option case; done means the schema has "enum": ["email"] and the form returns the selected value.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Initial Checks
Release line

2.x (current stable)

Description

With list[Literal["email", "print"]], the SDK sends the form. With list[Literal["email"]], I reproduced a failure before the client received the form. Both [] and ["email"] are meaningful selections.

I expected the items schema to contain "enum": ["email"]. On 2.3.0 it contains "const": "email", and the SDK raises TypeError when validating the channels field against PrimitiveSchemaDefinition.

I ran the same in-memory client twice. On 2.3.0 the tool returned Error executing tool subscribe. With a local patch, the client received {"enum": ["email"], "type": "string"} and the tool returned email successfully.

Related issue #3883 covers $ref for Enum classes. This example uses typing.Literal.

Codex helped investigate, wrote the local patch and regression test, and drafted this report.

Example Code
from typing import Literal

from mcp.server.elicitation import render_elicitation_schema
from pydantic import BaseModel

class Delivery(BaseModel):
    channels: list[Literal["email"]]

print(render_elicitation_schema(Delivery)["properties"]["channels"])
Python & MCP Python SDK
Python 3.14.4, mcp 2.3.0, Pydantic 2.12.5. Also reproduced on main at 77001c96.
Langage dominant
Python
Étoiles
25k
Forks
4.2k
Merge moyen
10 min
PR mergées (30 j)
1

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de modelcontextprotocol/python-sdk

Toutes les issues de modelcontextprotocol/python-sdk

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.