Repository navigation
Commit 8ccb47d
fix(mcp): cap the fallback tool description too (PR #31 review)
describeTool capped the server's own description but returned the no-description
fallback uncapped. That fallback embeds `tool` — the server-chosen, untrusted
tool name — so a server could ship a giant name with a blank description and
sail past MAX_TOOL_DESC, re-bloating every turn's prompt and widening the G4
injection surface the cap exists to bound.
Fix applies the cap to the final string, so the server's text and the fallback
obey the same bound through one exit — which also drops the duplicated slice
logic. (The namespaced name is separately truncated to 64; untouched.)
Verified: 39 tests (1 new — a 6000-char tool name with no description must still
yield a description within MAX_TOOL_DESC). Mutation-checked: restoring the
uncapped-fallback branch fails the new test. Full gate: 18 suites, 0 failures.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 95014cc commit 8ccb47d
2 files changed
Lines changed: 20 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
272 | 278 | | |
273 | 279 | | |
274 | | - | |
275 | | - | |
| 280 | + | |
| 281 | + | |
276 | 282 | | |
277 | 283 | | |
278 | 284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
389 | 400 | | |
390 | 401 | | |
391 | 402 | | |
| |||
0 commit comments