Repository navigation
Commit a8d0114
committed
fix(blocked-tools): close startup tool-count gap, hoist auth ctx, harden retrieve_tools test
Address review feedback on PR smart-mcp-proxy#447:
1. handleListUpstreams previously fell back to live ListTools only when
p.mainServer == nil (test/standalone). In production the
getVisibleToolCount path uses the supervisor's StateView snapshot,
which is empty during startup before the supervisor hydrates - so the
UI would show "0 tools" for a freshly-connected server with healthy
tools. Restored the live ListTools fallback in production too,
filtered by isToolCallable so disabled tools still don't inflate the
count.
2. handleRetrieveTools called auth.AuthContextFromContext(ctx) inside
the per-result loop. Hoisted it (and the IsAdmin check) above the
loop - it's a per-request value and the lookup is repeated work for
every search result.
3. TestRetrieveTools_ExcludesDisabledToolsPreRanking previously
silent-passed if the response had no "tools" field. The query
("context7 resolve library id") only matched the disabled context7
tool, so the enabled github tool wasn't a positive control - the
test verified nothing once the disabled tool was filtered out.
Rewrote both tools to share the same description so BM25 returns
both, then asserted:
- the enabled tool MUST appear (positive control catches an over-
eager filter regression),
- the disabled tool MUST NOT appear (negative control).
Also dropped the silent early-return in favor of require.True on the
tools field.
Verification:
- go test ./internal/server -count=1 -timeout 10m PASS (434s)
- go vet ./... clean
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>1 parent 1f864f6 commit a8d0114
4 files changed
Lines changed: 45 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1038 | 1038 | | |
1039 | 1039 | | |
1040 | 1040 | | |
1041 | | - | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
1042 | 1047 | | |
1043 | 1048 | | |
1044 | 1049 | | |
| |||
1051 | 1056 | | |
1052 | 1057 | | |
1053 | 1058 | | |
1054 | | - | |
1055 | | - | |
1056 | | - | |
1057 | | - | |
| 1059 | + | |
| 1060 | + | |
1058 | 1061 | | |
1059 | 1062 | | |
1060 | 1063 | | |
| |||
2581 | 2584 | | |
2582 | 2585 | | |
2583 | 2586 | | |
2584 | | - | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
2585 | 2591 | | |
2586 | | - | |
2587 | | - | |
| 2592 | + | |
2588 | 2593 | | |
2589 | | - | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
2590 | 2599 | | |
2591 | 2600 | | |
2592 | 2601 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | | - | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
51 | | - | |
| 55 | + | |
52 | 56 | | |
53 | | - | |
| 57 | + | |
54 | 58 | | |
55 | 59 | | |
56 | 60 | | |
57 | | - | |
| 61 | + | |
58 | 62 | | |
59 | | - | |
| 63 | + | |
60 | 64 | | |
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
65 | | - | |
| 69 | + | |
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| |||
76 | 80 | | |
77 | 81 | | |
78 | 82 | | |
79 | | - | |
80 | | - | |
81 | | - | |
| 83 | + | |
| 84 | + | |
82 | 85 | | |
83 | 86 | | |
84 | | - | |
| 87 | + | |
85 | 88 | | |
| 89 | + | |
86 | 90 | | |
87 | 91 | | |
88 | | - | |
89 | | - | |
| 92 | + | |
90 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
91 | 102 | | |
92 | 103 | | |
93 | 104 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1324 | 1324 | | |
1325 | 1325 | | |
1326 | 1326 | | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
1327 | 1330 | | |
1328 | 1331 | | |
1329 | 1332 | | |
| |||
0 commit comments