Skip to content

Conversation

@IAmSurajBobade
Copy link
Contributor

Address TODOs in code requiring go 1.24 as minimum version

mcp/logging.go: use slog.DiscardHandler, over local implementation
mcp/util.go: use rand.Text, over local implementation

Fixes #772

Copy link
Contributor

@maciej-kisiel maciej-kisiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution, I have one comment.

mcp/util.go Outdated
// TODO: once 1.24 is assured, just use crypto/rand.
const base32alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"

func randText() string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we replace calls to this function with rand.Text() and remove it altogether?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, @maciej-kisiel. Addressed your review comment.

I did not remove randText method earlier, to minimize code change and also as ServerOptions.GetSessionID expects a func, and so anyway need to create anon func. And mcp/streamable.go, uses math/rand/v2, causing a conflict.

@IAmSurajBobade
Copy link
Contributor Author

I did not remove randText method earlier, to minimize code change and ServerOptions.GetSessionID expects a func, and so anyway need to create anon func. Also mcp/streamable.go, uses math/rand/v2, causing a conflict and impacting readability.

mcp/server.go Outdated

if opts.GetSessionID == nil {
opts.GetSessionID = randText
opts.GetSessionID = func() string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just assigning rand.Text won't work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it won't. SessionId expects func()string. I mentioned this in the response to your earlier review comment on why I reused the existing randText method earlier.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rand.Text is func() string. Please do:

opts.GetSessionID = rand.Text

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahaa, my bad. resolved.

@maciej-kisiel
Copy link
Contributor

Thanks for the contribution!

@maciej-kisiel maciej-kisiel merged commit df4f0d5 into modelcontextprotocol:main Feb 3, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update code for minimum go version 1.24

2 participants