Commit 51a9eae
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: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent ccb78f2 commit 51a9eae
File tree
5 files changed
+350
-1
lines changed- .changeset
- packages
- client/src/client
- core
- server/src/server
5 files changed
+350
-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 | |
|---|---|---|---|
| |||
514 | 514 | | |
515 | 515 | | |
516 | 516 | | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
517 | 520 | | |
518 | 521 | | |
519 | 522 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
122 | 137 | | |
123 | 138 | | |
124 | 139 | | |
| |||
413 | 428 | | |
414 | 429 | | |
415 | 430 | | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
416 | 434 | | |
417 | 435 | | |
418 | 436 | | |
| |||
441 | 459 | | |
442 | 460 | | |
443 | 461 | | |
| 462 | + | |
444 | 463 | | |
445 | 464 | | |
446 | 465 | | |
| |||
724 | 743 | | |
725 | 744 | | |
726 | 745 | | |
| 746 | + | |
| 747 | + | |
727 | 748 | | |
728 | 749 | | |
729 | 750 | | |
| |||
992 | 1013 | | |
993 | 1014 | | |
994 | 1015 | | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
995 | 1061 | | |
996 | 1062 | | |
997 | 1063 | | |
998 | 1064 | | |
| 1065 | + | |
999 | 1066 | | |
1000 | 1067 | | |
1001 | 1068 | | |
| |||
0 commit comments