Skip to content

Conversation

pusewicz
Copy link
Contributor

The positional argument and naming is a bit awkward, and feels unnatural. Let's instead follow the Ruby style and add an error: keyword argument.

Before

response = Response.new(content, true) # What is true?

After

response = Response.new(content, error: true)

Motivation and Context

How Has This Been Tested?

Unit tests

Breaking Changes

For anyone using the positional argument, this is a breaking change.

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

I'm happy to remove the second commit that introduces the ErrorResponse class. I do find it's usage a nicer approach that moves the decision to the caller, but also I can see how it adds some unnecessary boilerplate. Let me know what you think!

@pusewicz pusewicz force-pushed the response-keyword-boolean branch from e26451d to 10aa055 Compare August 18, 2025 10:23
@pusewicz pusewicz requested review from koic and atesgoral August 18, 2025 10:24

response = Response.new(content)
assert_equal content, response.content
refute response.error?
Copy link
Member

Choose a reason for hiding this comment

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

Can you split it into three tests, each independently executable per assertion group?

actual = response.to_h
assert_equal [:content, :isError].sort, actual.keys.sort
assert_equal content, actual[:content]
assert actual[:isError]
Copy link
Member

Choose a reason for hiding this comment

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

Can you split it into two tests, each independently executable per assertion group?

assert response.error?

response = Response.new(nil, error: false)
refute response.error?
Copy link
Member

Choose a reason for hiding this comment

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

Can you split it into two tests, each independently executable per assertion?


response = Response.new(nil, error: false)
refute response.error?
end
Copy link
Member

Choose a reason for hiding this comment

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

Can you move this test "#error?" do (L46-L52) before test "#to_h" do (L27) ?

@koic
Copy link
Member

koic commented Aug 18, 2025

Since the purpose of these changes is singular, please squash them into a single commit.

Both the combination of positional argument and naming does not feel
like Ruby.

This change makes `is_error` argument a keyword argument called `error`.

Thanks to this, the usage is more self-explanatory:

```ruby
response = Response.new([], error: true)
```
@pusewicz pusewicz force-pushed the response-keyword-boolean branch from 10aa055 to 6689db2 Compare August 18, 2025 14:50
@pusewicz
Copy link
Contributor Author

@koic Addressed your feedback.

@pusewicz pusewicz changed the title Response keyword boolean Response error keyword argument Aug 19, 2025
@koic koic merged commit 002df2c into modelcontextprotocol:main Aug 20, 2025
5 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.

5 participants