Elicitation results are not checked against `requested_schema`, but the docs say they match it
維護者通常 1 天內回覆
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- ruby
研究方向
Start with lib/mcp/server_session.rb at create_form_elicitation, create_url_elicitation, and fulfill_input_request, then read docs/_server/elicitation.md for the documented contract. Check how the SDK represents validation errors and test these methods with the supplied invalid action and schema values. Done means invalid actions and invalid accepted content are rejected, with tests covering the stated cases.
由索引模型根據 Issue 內容生成。
描述
docs/_server/elicitation.md says: "Per the MCP specification, the client validates the user's input against this schema before returning it, so the content of an accept response matches the requested shape." The server does not check this.
ServerSession#create_form_elicitation (server_session.rb:209-224), #create_url_elicitation (:231-246) and #fulfill_input_request (:253-255, used by the legacy input_required shim) return the client's result as received. action is not limited to accept, decline and cancel, and content is not checked against requested_schema (types, required, enum). A buggy or non-compliant client can return wrong types or values outside an enum, and handlers that follow the docs use them as-is.
Repro
Run from the repository root with bundle exec ruby -I lib repro.rb. The stub transport plays the client's reply.
require "mcp"
class ClientReply
def initialize(reply)
@reply = reply
end
def send_request(_method, _params = nil, **)
@reply
end
def send_notification(*, **)
true
end
end
reply = { action: "accept", content: { replicas: "lots", environment: "unlisted" } }
server = MCP::Server.new(name: "example")
session = MCP::ServerSession.new(server: server, transport: ClientReply.new(reply), session_id: "A")
session.store_client_info(client: { name: "client", version: "1" }, capabilities: { elicitation: {} })
result = session.create_form_elicitation(
message: "Deploy settings",
requested_schema: {
type: "object",
properties: {
replicas: { type: "integer" },
environment: { type: "string", enum: ["staging", "production"] },
},
required: ["replicas", "environment"],
},
related_request_id: 1,
)
p result
Expected: an error (or at least not an accept result), because replicas is not an integer and environment is not in the enum.
Actual: {action: "accept", content: {replicas: "lots", environment: "unlisted"}}
The same happens with an unknown action such as {action: "approve-everything"}.
Suggested fix
Check action and, for accept, check content against the flat requested_schema before returning it from these methods, and raise a validation error on a mismatch. The elicitation schema subset is small (flat object, primitive types, enum, required). If validation is out of scope, change the docs to say that handlers must validate content themselves.
- 主要語言
- Ruby
- 星號
- 940
- 分支
- 143
- 平均合併
- 1 天 3 小時
- 30 天內合併 PR
- 47
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
modelcontextprotocol/ruby-sdk 的其他 Issue
-
Invalid UTF-8 in `MCP-Protocol-Version`, `Mcp-Method` or `Mcp-Name` gives 500 instead of 400可能已有人在做 @atesgoral 今天認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 78/100
modelcontextprotocol/ruby-sdk#663 ·
維護者通常 1 天內回覆
-
`Client::Stdio` passes the whole parent environment to the server process可能已有人在做 @atesgoral 今天認領。 未關閉bug
難度 4/5 3-5 天 新手友好度 55/100
modelcontextprotocol/ruby-sdk#662 ·
維護者通常 1 天內回覆
-
HTTP client sends handler exception messages back to the server可能已有人在做 @atesgoral 今天認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 35/100
modelcontextprotocol/ruby-sdk#660 ·
維護者通常 1 天內回覆
-
`JWTVerifier` answers 500 instead of 401 for a PS256 token when it verifies with an EC key (jwt < 3.3.0)可能已有人在做 @atesgoral 今天認領。 未關閉bug
難度 3/5 1-2 天 新手友好度 35/100
modelcontextprotocol/ruby-sdk#659 ·
維護者通常 1 天內回覆
-
`logging/setLevel` from one session changes the log level of other sessions可能已有人在做 @atesgoral 今天認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 35/100
modelcontextprotocol/ruby-sdk#658 ·
維護者通常 1 天內回覆
查看 modelcontextprotocol/ruby-sdk 的全部 Issue
相似的 Issue
-
bug javascript
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 88/100
yegor256/netbout.rb#69 ·
-
難度 2/5 1-3 小時 新手友好度 84/100
yegor256/iccq.github.io#161 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
palladius/rails8-app-on-gcp#198 ·
-
bug
難度 1/5 1 小時以內 新手友好度 95/100
WikiEducationFoundation/WikiEduDashboard#7258 ·
維護者通常 1 天內回覆