Commit 076eb72
Empty mcp tool result error (#1142)
### Summary
Fixed `MCPUtil.invoke_mcp_tool()` to return `"[]"` instead of logging an
error when MCP tools return empty content. Empty results (`None, []`)
are valid outputs and should be treated consistently with
function tools. The `None -> "[]"` and `[] -> "[]"` behavior comes from
the MCP Python SDK's[ FastMCP implementation](
https://github.com/modelcontextprotocol/python-sdk/blob/6566c08446ad37b66f1457532c7f5a14f243ae10/src/mcp/server/fastmcp/utilities/func_metadata.py#L500).
### Test plan
- Added comprehensive test coverage in
`test_mcp_fastmcp_behavior_verification()` that verifies all FastMCP
edge cases
- Enhanced FakeMCPServer to support custom content testing scenarios
- Ran full test suite - all tests pass
- Verified the fix handles `None, [], {}, [{}], [[]]` cases correctly
### Issue number
Closes #1035
### Checks
- [x] I've added new tests (if relevant)
- [ ] I've added/updated the relevant documentation
- [x] I've run `make lint` and `make format`
- [x] I've made sure tests pass
Co-authored-by: thein <[email protected]>1 parent 00c87ea commit 076eb72
3 files changed
+70
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
213 | | - | |
| 212 | + | |
| 213 | + | |
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
8 | 15 | | |
9 | 16 | | |
10 | 17 | | |
| |||
67 | 74 | | |
68 | 75 | | |
69 | 76 | | |
| 77 | + | |
70 | 78 | | |
71 | 79 | | |
72 | 80 | | |
| |||
91 | 99 | | |
92 | 100 | | |
93 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
94 | 107 | | |
95 | 108 | | |
96 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
237 | 291 | | |
238 | 292 | | |
239 | 293 | | |
| |||
0 commit comments