Conversation
e5l
left a comment
There was a problem hiding this comment.
The only thing I'm not sure about is having DSL functions on the top level. Users will receive the top-level functions buildListResourcesResult for the whole application. While it is fine for stdlib, doing this in other library will bloat top-level scope.
Should we think about scoping the DSL to specific use-sites or anchor classes?
@devcrocod, what do you think?
Agree What if we try addressing it in the follow up PR, after #515? |
|
Actually, I'm not sure we should be very restrictive in letting users to build data classes |
That’s true. Even in the stdlib this pattern is used rarely. Given that we already have quite a few objects, relying on a shared prefix would indeed make the api awkward to use
I’ve thought about that as well, but introducing contextual scoping would require a more detailed design |
d77e186 to
a149698
Compare
…dation - Introduced `ToolsResultDslTest` and `PromptsResultDslTest` to test result builders for tool and prompt operations. - Added `buildCompleteResult` and `buildInitializeResult` for server-side result creation. - Updated API surface to include result DSL functionality.
…SL across integration tests - Updated integration tests to use the `buildCallToolResult` DSL for constructing results, improving clarity and reducing boilerplate. - Added `@OptIn(ExperimentalMcpApi::class)` annotations to test files requiring experimental API. - Refactored delay handling in tests to streamline coroutine usage.
- Added new test cases for `CallToolResult`, `ListResourcesResult`, and `ReadResourceResult` to validate error handling, structured content, and metadata processing. - Improved coverage for resource and template handling with additional edge cases for mixed-field resources and pagination.
- Added `.toList()` defensive copying in `build()` methods to ensure immutability of returned collections. - Enhanced documentation for CallToolResult, metadata, and field nullability to align with MCP serialization conventions.
a149698 to
7d3908d
Compare
Add result DSL builders and tests
ToolsResultDslTestandPromptsResultDslTestto test result builders for tool and prompt operations.buildCompleteResultandbuildInitializeResultfor server-side result creation.CallToolResult,ListResourcesResult, andReadResourceResultto validate error handling, structured content, and metadata processing.buildCallToolResultDSL for constructing results, improving clarity and reducing boilerplate. Added@OptIn(ExperimentalMcpApi::class)annotations to test files requiring experimental API.Motivation and Context
Build also results with DSL
How Has This Been Tested?
Unit test
Breaking Changes
No
Types of changes
Checklist
Additional context