Commit 3b643d6
Replace CallToolResult<T> with OutputSchemaType on McpServerToolAttribute
Remove CallToolResult<T> and ICallToolResultTyped - they conflated the success
type with the error type, making it impossible to provide meaningful error
messages when IsError is true and T is not string.
Add OutputSchemaType (Type?) property to McpServerToolAttribute, which
decouples the output schema type from the return type. Methods can return T
directly (throw for errors) or CallToolResult for full control over error
messages, while OutputSchemaType independently specifies the schema.
Also update CallToolAsync<T> to concatenate all TextContentBlock texts
(with newline separator) for error messages instead of using only the first.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 76ccbec commit 3b643d6
File tree
7 files changed
+72
-353
lines changed- src/ModelContextProtocol.Core
- Client
- Protocol
- Server
- tests/ModelContextProtocol.Tests/Server
7 files changed
+72
-353
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
950 | 950 | | |
951 | 951 | | |
952 | 952 | | |
953 | | - | |
954 | | - | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
955 | 957 | | |
956 | 958 | | |
957 | 959 | | |
| |||
Lines changed: 0 additions & 78 deletions
This file was deleted.
Lines changed: 5 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| 177 | + | |
177 | 178 | | |
178 | 179 | | |
179 | 180 | | |
| |||
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
| 218 | + | |
| 219 | + | |
217 | 220 | | |
218 | 221 | | |
219 | 222 | | |
| |||
224 | 227 | | |
225 | 228 | | |
226 | 229 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
| 230 | + | |
| 231 | + | |
231 | 232 | | |
232 | 233 | | |
233 | 234 | | |
| |||
323 | 324 | | |
324 | 325 | | |
325 | 326 | | |
326 | | - | |
327 | | - | |
328 | 327 | | |
329 | 328 | | |
330 | 329 | | |
| |||
381 | 380 | | |
382 | 381 | | |
383 | 382 | | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | 383 | | |
407 | 384 | | |
408 | 385 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | 145 | | |
155 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
156 | 149 | | |
157 | 150 | | |
158 | 151 | | |
| |||
Lines changed: 34 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | 141 | | |
151 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
152 | 145 | | |
153 | 146 | | |
154 | 147 | | |
| |||
269 | 262 | | |
270 | 263 | | |
271 | 264 | | |
| 265 | + | |
272 | 266 | | |
273 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
274 | 272 | | |
275 | 273 | | |
276 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
277 | 301 | | |
278 | 302 | | |
279 | 303 | | |
| |||
0 commit comments