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

オープン
#3,975 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
Python
スター
25k
フォーク
4.2k
平均マージ
10分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelcontextprotocol/python-sdk のほかの issue

modelcontextprotocol/python-sdk の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。