Skip to content

Use BTreeMap instead of HashMap for deterministic serialization#105

Closed
mbr wants to merge 1 commit into
rust-mcp-stack:mainfrom
mbr:marc/ordering-fix-0.7.5
Closed

Use BTreeMap instead of HashMap for deterministic serialization#105
mbr wants to merge 1 commit into
rust-mcp-stack:mainfrom
mbr:marc/ordering-fix-0.7.5

Conversation

@mbr

@mbr mbr commented Mar 10, 2026

Copy link
Copy Markdown

📌 Summary

Solves the problem of having non-deterministic tool definitions, the order changes around when getting large.

✨ Changes Made

Replaced all HashMaps with BTreeMaps

🛠️ Testing Steps

cargo test sufficient, I assume.

💡 Additional Notes

I did not dig too deep into how the code in this repo is generated and whether there's a better place to apply these changes. I am currently happily using my forked branch.

This PR is aimed at the latest release version, not main.

@hashemix

Copy link
Copy Markdown
Member

Hey @mbr , thanks for the suggestion ⭐ . this is a great improvement and something I didn’t initially think of.

I will update the schema generator accordingly, It may introduce a breaking change, so I’ll need to evaluate the impact before releasing this change. I may bundle it with the upcoming larger changes to the rust-mcp-sdk

@hashemix

Copy link
Copy Markdown
Member

This was addressed in in #108 and released in #109 .

Also available in rust-mcp-sdk-v0.9.0

@hashemix hashemix closed this Mar 13, 2026
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.

2 participants