Skip to content

ElicitParams serializes an unset Mode as "mode": "" #1072

Description

@cclabadmin

Describe the bug

When a server returns an InputRequiredResult containing a form-mode ElicitRequest with an unset ElicitParams.Mode, the Go SDK serializes the field as "mode": "".

The draft schema permits form-mode elicitation to either omit mode or set it to "form". An empty string matches neither the form nor the URL branch of ElicitRequestParams, so the nested ElicitRequest does not validate against the schema.

Omitting mode when it is unset would preserve the specification's backward-compatible form-mode default.

Environment tested:

  • v1.7.0-pre.2 (b426fbf)
  • Server used: conformance/everything-server
  • Transport: stdio (2026-07-28 draft)

To Reproduce

  1. Start the Go SDK conformance server over stdio using the 2026-07-28 draft protocol revision.
  2. Send a prompts/get request for the test_input_required_result_prompt prompt:
{
  "jsonrpc": "2.0",
  "id": 1001,
  "method": "prompts/get",
  "params": {
    "name": "test_input_required_result_prompt",
    "_meta": {
      "io.modelcontextprotocol/protocolVersion": "2026-07-28",
      "io.modelcontextprotocol/clientInfo": {"name": "test-client", "version": "1.0.0"},
      "io.modelcontextprotocol/clientCapabilities": {}
    }
  }
}
  1. Observe that the response contains "mode": "" in the nested ElicitRequest params:
{
  "jsonrpc": "2.0",
  "id": 1001,
  "result": {
    "messages": null,
    "resultType": "input_required",
    "inputRequests": {
      "user_context": {
        "method": "elicitation/create",
        "params": {
          "mode": "",
          "message": "Please provide context for the prompt",
          "requestedSchema": {
            "type": "object",
            "properties": {"context": {"type": "string"}},
            "required": ["context"]
          }
        }
      }
    }
  }
}

Expected behavior

The mode field should be omitted when Mode is unset. Per the specification, clients treat an omitted mode as form mode. Explicitly serializing "mode": "form" would also be schema-valid.

Expected params:

{
  "message": "Please provide context for the prompt",
  "requestedSchema": {
    "type": "object",
    "properties": {
      "context": {
        "type": "string"
      }
    },
    "required": ["context"]
  }
}

ElicitRequestParams is defined as either ElicitRequestFormParams or ElicitRequestURLParams.

  • In the form branch, mode is optional, but when present its value must be "form".
  • In the URL branch, mode is required and its value must be "url".

Therefore, "mode": "" matches neither branch, while omitting mode matches the form branch.

Additional context

ElicitParams.Mode in mcp/protocol.go is declared as:

Mode string `json:"mode"`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions