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

Labels

proposalA proposal for an a new API or behavior. See CONTRIBUTING.md.proposal-acceptedProposals that have been accepted.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions