Commit 9e1b5da
feat(core): add opt-in periodic ping for connection health monitoring
Implements the missing periodic ping functionality specified in issue #1000.
Per the MCP specification, implementations SHOULD periodically issue pings
to detect connection health, with configurable frequency.
Changes:
- Add `pingIntervalMs` option to `ProtocolOptions` (disabled by default)
- Implement `startPeriodicPing()` and `stopPeriodicPing()` in Protocol
- Client starts periodic ping after successful initialization
- Server starts periodic ping after receiving initialized notification
- Timer uses `unref()` so it does not prevent clean process exit
- Ping failures are reported via `onerror` without stopping the timer
- Timer is automatically cleaned up on close or unexpected disconnect
Fixes #1000
Co-authored-by: Br1an67 <932039080@qq.com>1 parent 40174d2 commit 9e1b5da
File tree
5 files changed
+351
-1
lines changed- .changeset
- packages
- client/src/client
- core
- server/src/server
5 files changed
+351
-1
lines changed| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
541 | 541 | | |
542 | 542 | | |
543 | 543 | | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
544 | 547 | | |
545 | 548 | | |
546 | 549 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
96 | 112 | | |
97 | 113 | | |
98 | 114 | | |
| |||
309 | 325 | | |
310 | 326 | | |
311 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
312 | 331 | | |
313 | 332 | | |
314 | 333 | | |
| |||
337 | 356 | | |
338 | 357 | | |
339 | 358 | | |
| 359 | + | |
340 | 360 | | |
341 | 361 | | |
342 | 362 | | |
| |||
488 | 508 | | |
489 | 509 | | |
490 | 510 | | |
| 511 | + | |
| 512 | + | |
491 | 513 | | |
492 | 514 | | |
493 | 515 | | |
| |||
709 | 731 | | |
710 | 732 | | |
711 | 733 | | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
712 | 779 | | |
713 | 780 | | |
714 | 781 | | |
715 | 782 | | |
| 783 | + | |
716 | 784 | | |
717 | 785 | | |
718 | 786 | | |
| |||
0 commit comments