Commit 376a7d1
authored
Codebase audit: bug fixes and robustness improvements for the Remote SSH MCP server (#1)
* Fix remote_browse_dir schema: path is optional (defaults to /home)
The input schema declared 'path' as required while the handler defaulted
missing values to /home. The two were contradictory; the handler default
matches the documented behavior and is friendlier for the folder picker.
Drop the bogus required entry so a missing path no longer trips
client-side validation.
Co-authored-by: MD. Mehedi Hossain <MehediHossain95@users.noreply.github.com>
* Allow remote_select_workspace to persist env-only hosts
REMOTE_SSH_HOSTS is documented as a valid host source, but
selectWorkspaceInConfig threw 'does not exist' whenever the host was
loaded only from the environment (or any source other than the writable
config file). Pass the resolved host profile as a seed so the writable
config can be populated transparently when the alias is missing on disk.
The pre-existing 'does not exist' behavior is preserved when no seed is
supplied, which keeps the existing test contract intact.
Co-authored-by: MD. Mehedi Hossain <MehediHossain95@users.noreply.github.com>
* Harden remote_write_file overwrite handling
* Remove the dead 'operator' ternary that always evaluated to '>'.
* Replace the two-stage 'test ! -e PATH && >' guard with POSIX noclobber
('set -C'), which makes the no-overwrite case atomic with respect to
the redirection rather than racing between the existence probe and the
write.
* Reject non-string content with a clear error instead of letting
Buffer.from(undefined) bubble up as 'first argument must be ...'.
Co-authored-by: MD. Mehedi Hossain <MehediHossain95@users.noreply.github.com>
* Make audit() resilient to filesystem failures
Audit logging is a side-channel for operations teams; a missing parent
directory or unwritable path should not break the primary SSH tool call.
Create the parent directory before writing, and swallow append failures
to stderr instead of throwing into the JSON-RPC handler.
Co-authored-by: MD. Mehedi Hossain <MehediHossain95@users.noreply.github.com>
* Return proper JSON-RPC errors instead of silently succeeding
* Unknown methods now produce a -32601 'Method not found' error rather
than an empty success response, so clients can tell when a tool was
mistyped or removed.
* JSON parse failures emit a -32700 error with id: null per JSON-RPC
2.0, instead of being dropped on the floor when the original line
could not be parsed.
* Plumb error.code through writeError so handlers can attach meaningful
codes (parse, method-not-found, etc.) while preserving the existing
-32000 default for application errors.
* Treat any notifications/* method as a no-op so future MCP
notifications do not regress into 'Method not found'.
Co-authored-by: MD. Mehedi Hossain <MehediHossain95@users.noreply.github.com>
* Harden remote_search_text query handling
* Reject empty/non-string queries up front instead of running an
effectively-wildcard 'rg ""' that scans the whole tree.
* Pass the search pattern via -e and add a '--' separator before the
positional target, so queries that begin with '-' (e.g. searching for
a flag-like token) are no longer interpreted as ripgrep/grep options.
Co-authored-by: MD. Mehedi Hossain <MehediHossain95@users.noreply.github.com>
* Tighten input validation for remove_host / blocked patterns + tests
* remote_remove_host now rejects empty/blank names before consulting the
config, instead of producing 'Connection does not exist'.
* assertCommandAllowed now ignores malformed blockedCommandPatterns
entries rather than letting a bad user-supplied regex crash command
execution.
* Extend tests to cover:
- selectWorkspaceInConfig accepting a seed profile when the alias is
not yet in the writable config (the env-var path);
- remote_browse_dir input schema no longer marking 'path' as required;
- notifications/* still resolving to an empty result;
- unknown JSON-RPC methods rejecting with code -32601.
Co-authored-by: MD. Mehedi Hossain <MehediHossain95@users.noreply.github.com>
---------
Co-authored-by: MD. Mehedi Hossain <MehediHossain95@users.noreply.github.com>1 parent 452a055 commit 376a7d1
2 files changed
Lines changed: 89 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
192 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
193 | 200 | | |
194 | 201 | | |
195 | 202 | | |
| |||
261 | 268 | | |
262 | 269 | | |
263 | 270 | | |
264 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
265 | 276 | | |
266 | 277 | | |
267 | 278 | | |
| |||
403 | 414 | | |
404 | 415 | | |
405 | 416 | | |
406 | | - | |
407 | | - | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
408 | 421 | | |
409 | 422 | | |
410 | | - | |
411 | | - | |
412 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
413 | 426 | | |
414 | 427 | | |
415 | 428 | | |
416 | 429 | | |
417 | | - | |
| 430 | + | |
418 | 431 | | |
419 | 432 | | |
420 | 433 | | |
| |||
696 | 709 | | |
697 | 710 | | |
698 | 711 | | |
699 | | - | |
| 712 | + | |
700 | 713 | | |
701 | 714 | | |
702 | 715 | | |
| |||
911 | 924 | | |
912 | 925 | | |
913 | 926 | | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
914 | 930 | | |
915 | 931 | | |
916 | 932 | | |
| |||
981 | 997 | | |
982 | 998 | | |
983 | 999 | | |
984 | | - | |
| 1000 | + | |
985 | 1001 | | |
986 | 1002 | | |
987 | 1003 | | |
| |||
1016 | 1032 | | |
1017 | 1033 | | |
1018 | 1034 | | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
1019 | 1038 | | |
1020 | 1039 | | |
1021 | | - | |
| 1040 | + | |
1022 | 1041 | | |
| 1042 | + | |
| 1043 | + | |
1023 | 1044 | | |
1024 | 1045 | | |
1025 | | - | |
| 1046 | + | |
1026 | 1047 | | |
1027 | | - | |
| 1048 | + | |
1028 | 1049 | | |
1029 | 1050 | | |
1030 | 1051 | | |
| |||
1076 | 1097 | | |
1077 | 1098 | | |
1078 | 1099 | | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
1079 | 1103 | | |
1080 | 1104 | | |
1081 | | - | |
1082 | | - | |
1083 | | - | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
1084 | 1109 | | |
1085 | 1110 | | |
1086 | 1111 | | |
| |||
1127 | 1152 | | |
1128 | 1153 | | |
1129 | 1154 | | |
1130 | | - | |
| 1155 | + | |
1131 | 1156 | | |
1132 | 1157 | | |
1133 | | - | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
1134 | 1161 | | |
1135 | 1162 | | |
1136 | 1163 | | |
| |||
1139 | 1166 | | |
1140 | 1167 | | |
1141 | 1168 | | |
1142 | | - | |
| 1169 | + | |
| 1170 | + | |
1143 | 1171 | | |
1144 | 1172 | | |
1145 | 1173 | | |
1146 | | - | |
1147 | | - | |
| 1174 | + | |
| 1175 | + | |
1148 | 1176 | | |
1149 | 1177 | | |
1150 | 1178 | | |
| |||
1157 | 1185 | | |
1158 | 1186 | | |
1159 | 1187 | | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
1160 | 1195 | | |
1161 | 1196 | | |
1162 | 1197 | | |
1163 | | - | |
| 1198 | + | |
1164 | 1199 | | |
1165 | 1200 | | |
1166 | 1201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
144 | 163 | | |
145 | 164 | | |
146 | 165 | | |
147 | 166 | | |
148 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
149 | 181 | | |
150 | 182 | | |
0 commit comments