Skip to content

Proposal: make maxTokenSize of client transport SSE event handling configurable #726

@dingliang88526-dev

Description

@dingliang88526-dev

mcp/event.go

func scanEvents(r io.Reader) iter.Seq2[Event, error] {
scanner := bufio.NewScanner(r)
const maxTokenSize = 1 * 1024 * 1024 // 1 MiB max line size
scanner.Buffer(nil, maxTokenSize)
...
if err := scanner.Err(); err != nil {
if errors.Is(err, bufio.ErrTooLong) {
err = fmt.Errorf("event exceeded max line length of %d", maxTokenSize)
}
if !yield(Event{}, err) {
return
}
}

}

why set a small and no-configurable limit?

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or requestproposalA proposal for an a new API or behavior. See CONTRIBUTING.md.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions