Repository navigation
Commit 499f6e2
fix(mcp): the startup chip's per-server counts must reflect EXPOSED tools
PR #31 review (Copilot). The chip built its per-server counts from
handles[i].tools.length — the raw tools/list payload — while the run actually
exposes built.tools, which is smaller after the per-server cap
(MAX_TOOLS_PER_SERVER) and after junk specs are skipped. So a server listing 100
tools rendered "server (100)" even though only 64 were callable, and worse, that
per-server number sat right next to an "allowed/total" denominator computed from
built.tools.length — the chip contradicted itself.
Per-server counts now derive from built.routes (the tools actually exposed) via a
new pure helper, toolCountsByServer, so they reflect what the agent can call and
SUM to the denominator. A server that exposed nothing shows "(0)" — honest, and a
useful signal that it connected but contributed no usable tools.
Verified: 41 tests (2 new). The key test reproduces the reviewer's scenario — a
server 5 over the cap plus a server listing junk — and asserts the counts are the
capped/filtered numbers AND that they sum to built.tools.length. Mutation-checked:
a wrong per-tool increment fails, and dropping the malformed-entry guard fails.
The agent.js consumption is one line reading the tested helper, covered by that
test + reading (agent.js requires vscode). Full gate: 18 suites, 0 failures.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 8acbe42 commit 499f6e2
3 files changed
Lines changed: 55 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
552 | | - | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
553 | 558 | | |
554 | 559 | | |
555 | 560 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
337 | 357 | | |
338 | 358 | | |
339 | 359 | | |
| |||
391 | 411 | | |
392 | 412 | | |
393 | 413 | | |
394 | | - | |
| 414 | + | |
395 | 415 | | |
396 | 416 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
407 | 434 | | |
408 | 435 | | |
409 | 436 | | |
| |||
0 commit comments