Skip to content

Use TryAddEnumerable for McpServerOptionsSetup #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 9, 2025

Conversation

halter73
Copy link
Contributor

@halter73 halter73 commented Apr 9, 2025

I considered adding a test for this, but as of right now, I don't think running McpServerOptionsSetup.Configure more than once has an observable impact since the things it does either no-ops (like McpServerPrimitiveCollection.TryAdd when attempting to re-add tools and prompts) or overwrites what was done by the last call with the exact same thing (like McpServerHandlers.OverwriteWithSetHandlers). Still, there's no reason to run McpServerOptionsSetup multiple times if we don't have to, and this is the conventional pattern we use for adding IConfigureOptions (see AddMvc).

I thought about this because of the discussion in #240.

@halter73 halter73 merged commit b3a5a82 into modelcontextprotocol:main Apr 9, 2025
8 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.

2 participants