mcp: validation only for accept action (#766)

Fix: #758

- validate schema only for accept action
- add unit test
This commit is contained in:
FanOne 2026-01-29 00:06:06 +08:00 • committed by GitHub
commit b29ab52878
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -590,7 +590,7 @@ func (c *Client) elicit(ctx context.Context, req *ElicitRequest) (*ElicitResult,
return nil, err
}
// Validate elicitation result content against requested schema.
if schema != nil && res.Content != nil {
if res.Action == "accept" && schema != nil && res.Content != nil {
resolved, err := schema.Resolve(nil)
if err != nil {
return nil, &jsonrpc.Error{Code: jsonrpc.CodeInvalidParams, Message: fmt.Sprintf("failed to resolve requested schema: %v", err)}