Commit eb86473
committed
fix(rmcp): flatten Resource variant of PromptMessageContent
The Resource variant of PromptMessageContent was missing #[serde(flatten)],
causing the embedded resource content block to serialize as a double-nested
shape `{ "type": "resource", "resource": { "resource": {...} } }` instead of
the spec-compliant flat shape `{ "type": "resource", "resource": {uri, mimeType, text} }`.
This caused Zod-based MCP clients (e.g. Claude Code) to reject prompts/get
responses containing embedded resource messages with InvalidUnion errors.
The Image and ResourceLink variants already use #[serde(flatten)] correctly;
only Resource was missing it.
Fix: add #[serde(flatten)] so EmbeddedResource (=Annotated<RawEmbeddedResource>)
fields _meta / annotations / resource are flattened to the content-block level,
matching the MCP spec for prompts embedded resources.
Regression test: test_prompt_message_resource_serialization_is_flat verifies
content.resource.uri is reachable and content.resource.resource is absent.
Schema snapshots regenerated via UPDATE_SCHEMA=1.1 parent 014fb2e commit eb86473
3 files changed
Lines changed: 99 additions & 67 deletions
File tree
- crates/rmcp
- src/model
- tests/test_message_schema
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
162 | 165 | | |
163 | 166 | | |
164 | 167 | | |
| |||
321 | 324 | | |
322 | 325 | | |
323 | 326 | | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
324 | 378 | | |
325 | 379 | | |
326 | 380 | | |
| |||
Lines changed: 22 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | 143 | | |
173 | 144 | | |
174 | 145 | | |
| |||
244 | 215 | | |
245 | 216 | | |
246 | 217 | | |
247 | | - | |
| 218 | + | |
248 | 219 | | |
249 | 220 | | |
250 | 221 | | |
| |||
1475 | 1446 | | |
1476 | 1447 | | |
1477 | 1448 | | |
1478 | | - | |
| 1449 | + | |
1479 | 1450 | | |
1480 | 1451 | | |
1481 | 1452 | | |
| |||
1502 | 1473 | | |
1503 | 1474 | | |
1504 | 1475 | | |
1505 | | - | |
| 1476 | + | |
1506 | 1477 | | |
1507 | 1478 | | |
1508 | 1479 | | |
| |||
2142 | 2113 | | |
2143 | 2114 | | |
2144 | 2115 | | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
2145 | 2134 | | |
2146 | | - | |
| 2135 | + | |
2147 | 2136 | | |
2148 | 2137 | | |
2149 | 2138 | | |
| |||
Lines changed: 22 additions & 33 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | 143 | | |
173 | 144 | | |
174 | 145 | | |
| |||
244 | 215 | | |
245 | 216 | | |
246 | 217 | | |
247 | | - | |
| 218 | + | |
248 | 219 | | |
249 | 220 | | |
250 | 221 | | |
| |||
1475 | 1446 | | |
1476 | 1447 | | |
1477 | 1448 | | |
1478 | | - | |
| 1449 | + | |
1479 | 1450 | | |
1480 | 1451 | | |
1481 | 1452 | | |
| |||
1502 | 1473 | | |
1503 | 1474 | | |
1504 | 1475 | | |
1505 | | - | |
| 1476 | + | |
1506 | 1477 | | |
1507 | 1478 | | |
1508 | 1479 | | |
| |||
2142 | 2113 | | |
2143 | 2114 | | |
2144 | 2115 | | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
2145 | 2134 | | |
2146 | | - | |
| 2135 | + | |
2147 | 2136 | | |
2148 | 2137 | | |
2149 | 2138 | | |
| |||
0 commit comments