* Assert a test fixture matches the MCP SDK's ContentBlock schema. This * guards against fixtures that drift from the real protocol shape — exactly * the failure mode that previously hid the EmbeddedResource bug.
(block: T)
| 20 | * the failure mode that previously hid the EmbeddedResource bug. |
| 21 | */ |
| 22 | function assertValidMcpBlock<T extends MCPContentBlock>(block: T): T { |
| 23 | const parsed = ContentBlockSchema.safeParse(block); |
| 24 | if (!parsed.success) { |
| 25 | throw new Error(`fixture is not a valid MCP ContentBlock: ${parsed.error.message}`); |
| 26 | } |
| 27 | return block; |
| 28 | } |
| 29 | |
| 30 | describe('convertMCPContentBlock', () => { |
| 31 | test('converts text block to TextPart', () => { |