Implement SEP-1577 - Sampling With Tools by ochafik · Pull Request #1101 · modelcontextprotocol/typescript-sdk
changed the title
Implement SEP 1577 (Sampling w/ Tools)
Implement SEP-1577: Sampling With Tools)
ochafik
changed the title
Implement SEP-1577: Sampling With Tools)
Implement SEP-1577 - Sampling With Tools)
This was referenced
Nov 11, 2025
ochafik
changed the title
Implement SEP-1577 - Sampling With Tools)
Implement SEP-1577 - Sampling With Tools
ochafik
marked this pull request as ready for review
- Use structuredContent instead of content for plain object results in ToolResultContent tests - Use camelCase toolChoice instead of snake_case tool_choice in CreateMessageRequest test 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add type checks for ToolChoice, ToolUseContent, ToolResultContent, SamplingMessageContentBlock - Update expected spec types count from 119 to 123 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Changes:
- Remove `disable_parallel_tool_use` from ToolChoiceSchema (not in MCP spec)
- Remove unnecessary `.passthrough()` from ToolChoiceSchema
- Change CreateMessageResultSchema.role from z.literal("assistant") to
z.enum(["user", "assistant"]) to match spec's SamplingMessage.role
- Update spec type count from 123 to 127 (4 new sampling tool types)
- Fix test accessing .type on content union (could be array)
- Add test for CreateMessageResult with array content
- Remove test expecting user role to fail (spec allows both roles)
Note: 7 type compatibility errors remain due to upstream spec issue
where ToolUseContent.input and ToolResultContent.structuredContent use
`object` type instead of `{ [key: string]: unknown }`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced
Nov 21, 2025This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters