Skip to content

chore: add #[non_exhaustive] and mutation methods to improve compatibility - #715

Merged
alexhancock merged 4 commits into
mainfrom
jamadeo/v1.0-changes
Mar 3, 2026
Merged

chore: add #[non_exhaustive] and mutation methods to improve compatibility#715
alexhancock merged 4 commits into
mainfrom
jamadeo/v1.0-changes

Conversation

@jamadeo

@jamadeojamadeo commented Mar 2, 2026

Copy link
Copy Markdown
Contributor

In preparation for a 1.0 release, we should use #[non_exaustive] for most public structs/enums to help reduce backwards-incompatible changes.

While we don't foresee being strict with the semver guidelines, we should aim to keep backwards compatibility as much as possible between minor releases.

Motivation and Context

This will prevent clients from writing code that will break and require updates in future versions.

How Has This Been Tested?

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

@jamadeo
jamadeo requested a review from a team as a code ownerMarch 2, 2026 20:53
@github-actionsgithub-actionsBot added T-documentation Documentation improvements T-test Testing related changes T-core Core library changes T-examples Example code changes T-macros Macro changes T-model Model/data structure changes T-service Service layer changes T-transport Transport layer changes labels Mar 2, 2026
alexhancock
alexhancock previously approved these changes Mar 2, 2026
@github-actionsgithub-actionsBot added T-dependencies Dependencies related changes T-config Configuration file changes labels Mar 3, 2026
@jamadeojamadeo changed the title chore: add #[non_exhaustive] to most public structs/some public enumschore: bump to 1.0.0-alpha, add #[non_exhaustive] and mutation methods to improve compatibilityMar 3, 2026
@alexhancock
alexhancock self-requested a review March 3, 2026 15:17
alexhancock
alexhancock previously approved these changes Mar 3, 2026
@jamadeo
jamadeoforce-pushed the jamadeo/v1.0-changes branch from d447ed7 to 3cad234CompareMarch 3, 2026 15:30
@github-actionsgithub-actionsBot removed T-dependencies Dependencies related changes T-config Configuration file changes labels Mar 3, 2026
@jamadeojamadeo changed the title chore: bump to 1.0.0-alpha, add #[non_exhaustive] and mutation methods to improve compatibilitychore: add #[non_exhaustive] and mutation methods to improve compatibilityMar 3, 2026
@alexhancock
alexhancock self-requested a review March 3, 2026 15:32
@alexhancock
alexhancock merged commit f63718d into mainMar 3, 2026
16 checks passed
@alexhancock
alexhancock deleted the jamadeo/v1.0-changes branch March 3, 2026 15:38
Comment on lines +1459 to +1466
pub fn with_logger(level: LoggingLevel, logger: impl Into<String>, data: Value) -> Self {
Self {
level,
logger: Some(logger.into()),
data,
}
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The with_ prefix means "take ownership of self, set a fieThe with_ prefix means "take ownership of self, set a field, and return self." When callers look at the method list, they'll expect to see new().with_logger("name") chaining. I suggest we stick to the conventional build pattern here.

Suggested change
pubfn with_logger(level:LoggingLevel,logger:implInto<String>,data:Value) -> Self{
Self{
level,
logger:Some(logger.into()),
data,
}
}
}
pubfn with_logger(mutself,logger:implInto<String>) -> Self{
self.logger = Some(logger.into());
self
}

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@DaleSeo I agree. I think most of them follow this pattern you're suggesting, and we should keep it consistent

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jamadeo Quick follow-up: #720

This was referenced Mar 3, 2026
@DaleSeoDaleSeo mentioned this pull request Mar 3, 2026
9 tasks
@github-actionsgithub-actionsBot mentioned this pull request Mar 3, 2026
wpfleger96 added a commit to wpfleger96/rust-sdk that referenced this pull request Apr 10, 2026
AuthRequiredError, InsufficientScopeError, and DynamicTransportError
were marked #[non_exhaustive] in modelcontextprotocol#715/modelcontextprotocol#768 but don't have constructors
usable by external crates. Add new() for the error types and
from_parts() for DynamicTransportError (the existing new() requires a
Transport type parameter, making it unusable for test fixtures).
Fixesmodelcontextprotocol#805
wpfleger96 added a commit to wpfleger96/rust-sdk that referenced this pull request Apr 10, 2026
AuthRequiredError, InsufficientScopeError, and DynamicTransportError
were marked #[non_exhaustive] in modelcontextprotocol#715/modelcontextprotocol#768 but don't have constructors
usable by external crates. Add new() for the error types and
from_parts() for DynamicTransportError (the existing new() requires a
Transport type parameter, making it unusable for test fixtures).
Fixesmodelcontextprotocol#805
alexhancock pushed a commit that referenced this pull request Apr 13, 2026
AuthRequiredError, InsufficientScopeError, and DynamicTransportError
were marked #[non_exhaustive] in #715/#768 but don't have constructors
usable by external crates. Add new() for the error types and
from_parts() for DynamicTransportError (the existing new() requires a
Transport type parameter, making it unusable for test fixtures).
Fixes#805
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-coreCore library changesT-documentationDocumentation improvementsT-examplesExample code changesT-macrosMacro changesT-modelModel/data structure changesT-serviceService layer changesT-testTesting related changesT-transportTransport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@jamadeo@alexhancock@DaleSeo