Commit e0a5627
committed
fix(mcp): resolve server names by own-property, not the prototype chain
getMcpConfigByName and the mcp remove handler look names up in plain
object maps built from JSON config with a bare servers[name] truthiness
check. Reserved names ('constructor', '__proto__', 'toString', …) resolve
to inherited Object.prototype members, which are truthy, so:
- `mcp get constructor` skips the not-found guard, prints a fabricated
record, and hands the Object constructor to the health check;
- `mcp remove constructor` reports the reserved name as present in
multiple scopes and prompts to pick one instead of "No MCP server found".
The same leak reaches runAgent and the print handlers, which all route
through getMcpConfigByName. Gate every lookup on Object.hasOwn so only
real, own-property server names resolve.1 parent 7ad96e9 commit e0a5627
3 files changed
Lines changed: 85 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
205 | 210 | | |
206 | 211 | | |
207 | 212 | | |
208 | | - | |
| 213 | + | |
209 | 214 | | |
210 | 215 | | |
211 | 216 | | |
212 | | - | |
| 217 | + | |
213 | 218 | | |
214 | | - | |
| 219 | + | |
215 | 220 | | |
216 | 221 | | |
217 | 222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1031 | 1031 | | |
1032 | 1032 | | |
1033 | 1033 | | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
1034 | 1039 | | |
1035 | 1040 | | |
1036 | 1041 | | |
1037 | 1042 | | |
1038 | 1043 | | |
1039 | | - | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
1040 | 1047 | | |
1041 | 1048 | | |
1042 | 1049 | | |
1043 | 1050 | | |
1044 | 1051 | | |
1045 | 1052 | | |
1046 | | - | |
1047 | | - | |
| 1053 | + | |
| 1054 | + | |
1048 | 1055 | | |
1049 | | - | |
1050 | | - | |
| 1056 | + | |
| 1057 | + | |
1051 | 1058 | | |
1052 | | - | |
1053 | | - | |
| 1059 | + | |
| 1060 | + | |
1054 | 1061 | | |
1055 | | - | |
1056 | | - | |
| 1062 | + | |
| 1063 | + | |
1057 | 1064 | | |
1058 | 1065 | | |
1059 | 1066 | | |
| |||
0 commit comments