Commit e78679b
committed
Refactor debug MCP tools: shared projections, registry helpers, doc updates
Tier 1 cleanup based on PR review feedback (patricksullivansf, yhsieh1)
and self-review.
DRY:
- Extract shared projection helpers to SDK (projections.ts):
truncateValue, isPrimitiveType, projectFrame, projectVariable,
projectBreakpoint, projectThreadLocation, plus exported types
MappedFrame/MappedVariable/MappedBreakpoint/MappedLocation. Used by
both MCP debug tools and CLI RPC mode — eliminates 5+ copies of the
same projection code and the MAX_VALUE_LENGTH/PRIMITIVE_TYPES
constants.
- Add getSessionEntry/getRegistry helpers to session-registry. Replace
the 4-line "registry not available" + getSessionOrThrow boilerplate
in 11 tools.
- Move halt-waiter promise pattern into DebugSessionRegistry.waitForHalt.
Used by debug_wait_for_stop and debug_capture_at_breakpoint instead
of duplicating the promise/timer/cleanup logic.
- Replace step-action switch with a lookup map.
API:
- DebugSessionRegistry.registerSession now takes an options object
(yhsieh1 nit) instead of 5 positional parameters.
Docs:
- Add "Recovery from broken or orphaned sessions" section to
docs/mcp/tools/diagnostics.md (patricksullivansf concern).
- Link to main authentication and configuration guides.
- Add JSDoc to ServerContext explaining stdio-per-client isolation
vs shared transport caveats (patricksullivansf concern).
Tool descriptions (yhsieh1 audit):
- Drop user-facing prose, sharpen for agent consumption.
- debug_start_session: explicitly mention SFRA controllers, custom API
scripts, hooks, jobs as use cases.
- debug_end_session: IMPORTANT call-out to always end sessions.
Coverage stays at 99.81% statements/lines, 94.81% branches,
98.93% functions — all above thresholds.1 parent b1276e4 commit e78679b
19 files changed
Lines changed: 730 additions & 503 deletions
File tree
- docs/mcp/tools
- packages
- b2c-cli/src/utils/debug
- b2c-dx-mcp
- src
- tools/diagnostics
- test/tools/diagnostics
- b2c-tooling-sdk/src/operations/debug
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
14 | 26 | | |
15 | 27 | | |
16 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
63 | 67 | | |
64 | 68 | | |
65 | 69 | | |
66 | | - | |
67 | | - | |
68 | 70 | | |
69 | 71 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 72 | + | |
78 | 73 | | |
79 | 74 | | |
80 | 75 | | |
| |||
113 | 108 | | |
114 | 109 | | |
115 | 110 | | |
116 | | - | |
| 111 | + | |
117 | 112 | | |
118 | 113 | | |
119 | 114 | | |
120 | 115 | | |
121 | 116 | | |
122 | | - | |
| 117 | + | |
123 | 118 | | |
124 | 119 | | |
125 | 120 | | |
| |||
128 | 123 | | |
129 | 124 | | |
130 | 125 | | |
131 | | - | |
| 126 | + | |
132 | 127 | | |
133 | 128 | | |
134 | 129 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
| 130 | + | |
142 | 131 | | |
143 | 132 | | |
144 | 133 | | |
145 | 134 | | |
146 | | - | |
| 135 | + | |
147 | 136 | | |
148 | 137 | | |
149 | 138 | | |
150 | 139 | | |
151 | 140 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
| 141 | + | |
160 | 142 | | |
161 | 143 | | |
162 | 144 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
176 | 149 | | |
177 | 150 | | |
178 | 151 | | |
179 | 152 | | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
| 153 | + | |
189 | 154 | | |
190 | 155 | | |
191 | 156 | | |
192 | 157 | | |
193 | 158 | | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
211 | 165 | | |
212 | 166 | | |
213 | 167 | | |
| |||
237 | 191 | | |
238 | 192 | | |
239 | 193 | | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
| 194 | + | |
249 | 195 | | |
250 | 196 | | |
251 | 197 | | |
252 | | - | |
| 198 | + | |
253 | 199 | | |
254 | 200 | | |
255 | 201 | | |
256 | 202 | | |
257 | 203 | | |
258 | | - | |
| 204 | + | |
259 | 205 | | |
260 | 206 | | |
261 | 207 | | |
262 | 208 | | |
263 | 209 | | |
264 | | - | |
| 210 | + | |
265 | 211 | | |
266 | 212 | | |
267 | 213 | | |
| |||
295 | 241 | | |
296 | 242 | | |
297 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
298 | 249 | | |
299 | 250 | | |
300 | 251 | | |
301 | 252 | | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
9 | 30 | | |
10 | 31 | | |
11 | 32 | | |
| |||
0 commit comments