Implement SEP-1577 - Sampling With Tools by ochafik · Pull Request #1101 · modelcontextprotocol/typescript-sdk

@ochafik changed the title Implement SEP 1577 (Sampling w/ Tools) Implement SEP-1577: Sampling With Tools)

Nov 11, 2025

@ochafik ochafik changed the title Implement SEP-1577: Sampling With Tools) Implement SEP-1577 - Sampling With Tools)

Nov 11, 2025

This was referenced

Nov 11, 2025

@ochafik ochafik changed the title Implement SEP-1577 - Sampling With Tools) Implement SEP-1577 - Sampling With Tools

Nov 17, 2025

@ochafik ochafik marked this pull request as ready for review

November 17, 2025 15:28

@ochafik @bhosmer-ant

@ochafik @bhosmer-ant

@ochafik @bhosmer-ant

- 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>

@ochafik @bhosmer-ant

@ochafik @bhosmer-ant

- 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>

@ochafik

@ochafik

@ochafik

bhosmer-ant

This was referenced

Nov 21, 2025