Skip to content

fix: clear() wiping dynamically registered tools by tracking discovered state on references#251

Open
soyuka wants to merge 1 commit intomodelcontextprotocol:mainfrom
soyuka:fix/clear
Open

fix: clear() wiping dynamically registered tools by tracking discovered state on references#251
soyuka wants to merge 1 commit intomodelcontextprotocol:mainfrom
soyuka:fix/clear

Conversation

@soyuka
Copy link
Contributor

@soyuka soyuka commented Mar 4, 2026

clear() previously removed all non-manual elements, which destroyed dynamically registered tools when setDiscoveryState() was called on the next request cycle. Add isDiscovered flag to ElementReference so clear() only removes elements that were imported via setDiscoveryState(), preserving both manual and dynamic registrations.

@soyuka soyuka force-pushed the fix/clear branch 2 times, most recently from 01d2107 to 8e7853b Compare March 4, 2026 19:39
…ed state on references

clear() previously removed all non-manual elements, which destroyed
dynamically registered tools when setDiscoveryState() was called on
the next request cycle. Add isDiscovered flag to ElementReference so
clear() only removes elements that were imported via setDiscoveryState(),
preserving both manual and dynamic registrations.
Copy link
Member

Choose a reason for hiding this comment

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

was it on purpose to add a new test class here instead of extending the existing one? a bit confusing to me

@chr-hertel chr-hertel added this to the 0.5.0 milestone Mar 9, 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