Commit 4ee1411
committed
Fix MCP stdio protocol violation during startup
The MCP protocol requires the client to send the first message. Writing
to stdout before the client's initialization request breaks the protocol
handshake, causing 'BrokenResourceError' in clients like langchain-mcp-adapters.
Root cause: Transport was created AFTER config/feature flags initialization,
so logger.* calls during startup wrote directly to stdout (bypassing buffering)
or called sendLog() which also wrote to stdout without checking isInitialized.
Fixes:
1. Move FilteredStdioServerTransport creation before config loading
2. Buffer sendLog() messages when isInitialized is false
3. Guard sendProgress/sendCustomNotification when not initialized
Fixes #issue-reported-by-ever10221 parent d3f5824 commit 4ee1411
2 files changed
+29
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
| 280 | + | |
280 | 281 | | |
281 | 282 | | |
282 | 283 | | |
283 | 284 | | |
284 | 285 | | |
285 | 286 | | |
286 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
287 | 299 | | |
288 | 300 | | |
289 | 301 | | |
| |||
315 | 327 | | |
316 | 328 | | |
317 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
318 | 335 | | |
319 | 336 | | |
320 | 337 | | |
| |||
346 | 363 | | |
347 | 364 | | |
348 | 365 | | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
349 | 371 | | |
350 | 372 | | |
351 | 373 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
42 | 49 | | |
43 | 50 | | |
44 | 51 | | |
| |||
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
| |||
0 commit comments