Commit 4b1f5e2
authored
One contract entry produced three differently-advertised tools, and nothing could see it:
`diffToolSets` compares name sets, and `checkAdvertisedShape` only asks whether a description is
non-empty.
- The REMOTE server wrote a description literal at every `register(...)` call site -- 35 had drifted
from the contract's, which is the text `listToolDefinitions()` serves to the agent-spec builders
and the `.well-known` catalogs, so one tool was described two different ways depending on which
LoopOver surface you asked. It advertised no tool `title` and no `annotations` at all, so a client
that gates confirmation on `destructiveHint` saw nothing for the server that performs the writes.
The `register` wrapper now fills all three from `getToolDefinition(name)`, spread after the call
site's config so a stray literal cannot win, and throws on a name with no contract entry.
- The STDIO server passed `contract.annotations` raw. That field is a `Partial` stating only what
differs from the default posture, so the five tools declaring one field advertised it without a
`destructiveHint`, and the ~95 declaring none advertised no annotations -- both disagreeing with
what the registry publishes for the same tool.
- The MINER server passed neither, and passed every schema as `SomeSchema.shape`. The SDK re-wraps a
raw shape in a plain `z.object` that DISCARDS the catchall, and every miner output is a
`looseObject`: all 21 were advertised and enforced as `additionalProperties: false`, so any field a
payload carried beyond the modelled set came back as a -32602 the caller could do nothing about.
#9762 fixed this class elsewhere and added a guard, but its roots omitted
`packages/loopover-miner/bin` -- the guard reported none while the server it did not look at had 21.
A `registerMinerTool` helper replaces all of them, and the guard now proves its own roots cover
every file that registers a tool.
Also closes #9656 and #9657, which are the same registration path: the remote's descriptions come
from the contract now (its `MCP_TOOL_CATEGORIES` was already derived), and
`loopover_admin_rotate_secret` -- the one tool still registering from schemas declared in
`src/mcp/server.ts` -- reads its four siblings' contract entry instead. The reason it survived is
fixed too: every case booted a server without `LOOPOVER_MCP_ADMIN_ENABLED`, so the admin category was
never diffed, compiled, smoke-called or output-validated, and the validator's own "nothing is
registered without a contract entry" assertion was structurally unable to see the tool that violated
it. A second remote surface with the flag set now runs the full pass over all five.
`ToolContract` becomes generic in its input/output schemas so a server registering from an entry gets
that tool's real argument type in its handler rather than the erased `z.ZodObject`.
New invariant `checkAdvertisedMetadata` compares advertised title/description/posture against the
projection, and runs for all three surfaces. No tool's declared posture changed.
1 parent 9d7f567 commit 4b1f5e2
13 files changed
Lines changed: 371 additions & 432 deletions
File tree
- packages
- loopover-contract/src
- tools
- loopover-mcp/bin
- loopover-miner/bin
- scripts/lib/validate-mcp
- src/mcp
- test
- contract
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
| |||
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
136 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
137 | 151 | | |
138 | 152 | | |
139 | 153 | | |
| |||
144 | 158 | | |
145 | 159 | | |
146 | 160 | | |
147 | | - | |
| 161 | + | |
148 | 162 | | |
149 | 163 | | |
150 | 164 | | |
| |||
155 | 169 | | |
156 | 170 | | |
157 | 171 | | |
158 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
159 | 175 | | |
160 | 176 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
306 | 324 | | |
307 | 325 | | |
308 | 326 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
168 | 169 | | |
169 | 170 | | |
170 | 171 | | |
| |||
897 | 898 | | |
898 | 899 | | |
899 | 900 | | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
900 | 906 | | |
901 | 907 | | |
902 | 908 | | |
903 | 909 | | |
904 | | - | |
905 | | - | |
| 910 | + | |
| 911 | + | |
906 | 912 | | |
907 | 913 | | |
908 | 914 | | |
909 | 915 | | |
910 | 916 | | |
911 | 917 | | |
912 | 918 | | |
913 | | - | |
| 919 | + | |
914 | 920 | | |
915 | 921 | | |
916 | 922 | | |
| |||
0 commit comments