Skip to content

mcp: client panics on elicitation/create or notifications/elicitation/complete without params #1314

Closed

Description

@fadiroot

Describe the bug

A Client crashes with a nil pointer dereference when a server sends elicitation/create or notifications/elicitation/complete without params (or with "params": null).

clientMethodInfos marks both methods missingParamsOK, so checkRequest accepts the message and the handler receives a typed-nil Params:

  • (*Client).elicit reads req.Params.Mode (client.go:874);
  • (*Client).callElicitationCompleteHandler reads req.Params.ElicitationID.

notifications/resources/updated has the same flag. Its built-in handler guards with req.Params != nil, but a user's ResourceUpdatedHandler still receives nil params.

The schema requires params for all three (ElicitRequest, ElicitationCompleteNotification and ResourceUpdatedNotification list it in required). The comment above clientMethodInfos says the flags are extracted from the schema, and the sibling sampling/createMessage is already registered with 0.

To Reproduce

cs.handle(ctx, &jsonrpc.Request{ID: jsonrpc2.Int64ID(1), Method: "elicitation/create"})
// panic: runtime error: invalid memory address or nil pointer dereference
// mcp.(*Client).elicit  client.go:874

The same happens on the wire with {"jsonrpc":"2.0","id":1,"method":"elicitation/create"} from a non-conforming server or proxy. A notification needs no client option at all to reach callElicitationCompleteHandler. No recover in the SDK, so the client process dies.

Expected behavior

The message is rejected as an invalid request, as it is for sampling/createMessage. Handlers never see nil params for these methods.

I have a fix with a regression test and can send a PR.

Activity

  1. added a commit that references this issue on Sep 29, 2026
    bab4bf1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions