Skip to content

feat(auth): add StoredCredentials::new() constructor#778

Open
wpfleger96 wants to merge 1 commit intomodelcontextprotocol:mainfrom
wpfleger96:wpfleger/stored-credentials-constructor
Open

feat(auth): add StoredCredentials::new() constructor#778
wpfleger96 wants to merge 1 commit intomodelcontextprotocol:mainfrom
wpfleger96:wpfleger/stored-credentials-constructor

Conversation

@wpfleger96
Copy link
Contributor

Summary

  • Add a new() constructor to StoredCredentials

StoredCredentials was marked #[non_exhaustive] in #715 / #768, but unlike other types in that sweep (e.g. OAuthClientConfig), it didn't get a constructor. External crates implementing CredentialStore that need to construct StoredCredentials in their save() path currently have to resort to a serde JSON roundtrip, which turns compile-time field mismatches into silent runtime failures.

Fixes #777

Test plan

  • just check passes
  • just test passes — all existing tests unaffected (they construct StoredCredentials with struct literals inside the crate, which still works)

@wpfleger96 wpfleger96 requested a review from a team as a code owner March 26, 2026 23:33
@github-actions github-actions bot added T-dependencies Dependencies related changes T-test Testing related changes T-config Configuration file changes T-core Core library changes T-transport Transport layer changes labels Mar 26, 2026
StoredCredentials is #[non_exhaustive] but has no constructor, making
it impossible for external crates implementing CredentialStore to
construct instances without a serde roundtrip workaround. Add a new()
constructor matching the pattern used for other #[non_exhaustive]
types in this crate.

Fixes modelcontextprotocol#777
@wpfleger96 wpfleger96 force-pushed the wpfleger/stored-credentials-constructor branch from 7220060 to 50d1f99 Compare March 26, 2026 23:56
@github-actions github-actions bot removed T-dependencies Dependencies related changes T-test Testing related changes T-config Configuration file changes labels Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StoredCredentials needs a constructor — #[non_exhaustive] without new() makes it unconstructable from external crates

1 participant