Skip to content

refactor: unify IntoCallToolResult Result impls#787

Open
DaleSeo wants to merge 1 commit intomainfrom
fix/relax-into-call-tool-result-error-bounds
Open

refactor: unify IntoCallToolResult Result impls#787
DaleSeo wants to merge 1 commit intomainfrom
fix/relax-into-call-tool-result-error-bounds

Conversation

@DaleSeo
Copy link
Copy Markdown
Member

@DaleSeo DaleSeo commented Apr 3, 2026

Closes #440.

Motivation and Context

This PR replaces the three separate Result impls and one Result<Json<T>, E> impl with a single unified impl<T: IntoCallToolResult, E: IntoCallToolResult> IntoCallToolResult for Result<T, E>. It also adds direct impls for CallToolResult and ErrorData so they can appear in either position of a Result. The Err branch forces is_error = Some(true) on any Ok(CallToolResult) produced by the error side, which maintains backward compatibility and prevents errors from accidentally producing success results.

How Has This Been Tested?

All existing tests pass.

Breaking Changes

No. All previously valid return types continue to compile and behave identically. The change only widens the set of accepted error types.

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

@DaleSeo DaleSeo self-assigned this Apr 3, 2026
@github-actions github-actions bot added T-core Core library changes T-handler Handler implementation changes labels Apr 3, 2026
@DaleSeo DaleSeo marked this pull request as ready for review April 3, 2026 02:01
@DaleSeo DaleSeo requested a review from a team as a code owner April 3, 2026 02:01
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-handler Handler implementation changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IntoCallToolResult implementations over constrain error conversion

1 participant