Title: fix(http): wait for active requests during shutdown by jonxsong · Pull Request #3882 · github/github-mcp-server · GitHub
Open Graph Title: fix(http): wait for active requests during shutdown by jonxsong · Pull Request #3882 · github/github-mcp-server
X Title: fix(http): wait for active requests during shutdown by jonxsong · Pull Request #3882 · github/github-mcp-server
Description: Summary Wait for active Streamable HTTP requests to finish during CLI shutdown. If the five-second grace period expires, close the remaining connections and return the shutdown error. Why On SIGTERM or SIGINT, RunHTTPServer started http.Server.Shutdown in a goroutine. Go closes the listener before waiting for active handlers, so ListenAndServe returned http.ErrServerClosed while the drain was in progress. The CLI then logged server stopped gracefully and could exit before the SDK wrote the MCP response. A client could receive EOF even when its GitHub API request could have completed inside the grace period. Go Server.Shutdown documentation The reproduction used the Linux CLI from 4e6e6c053e48, a normal MCP get_me call, and a local GitHub API stub. The stub held /api/v3/user until after SIGTERM closed the listener. With the response still blocked, the original process logged graceful shutdown and exited with status 0. The caller received EOF. Under the same sequence, the fixed process waited for the stub, delivered JSON-RPC result ID 42, and then exited with status 0. With the stub held past the full grace period, the fixed CLI reported context deadline exceeded and exited with status 1 after approximately five seconds. The MCP client connection closed and the GitHub stub observed request cancellation. What changed Run the HTTP serve loop in a goroutine and wait for both the serve loop and graceful shutdown before returning to the CLI. Keep the five-second deadline independent of the signal context so in-flight HTTP requests can finish. After a shutdown error, force-close any remaining connections and surface the error. Exercise four paths using real net/http handlers, net.Pipe, and testing/synctest. The tests cover response delivery during drain, connection closure and request cancellation at the grace deadline, listener errors, and cancellation before serving. Restoring the old shutdown ordering in a temporary overlay made the drain and deadline regressions fail on their expected assertions. MCP impact No tool or API changes. The patch is limited to the lifecycle of the self-hosted HTTP CLI. The Go SDK continues to own Streamable HTTP request and session handling, and tool calls still use their request contexts. Prompts tested (tool changes only) The transport reproduction uses the existing get_me tool against a loopback API stub. Security / limits Auth / permissions considered. Requests continue to pass through the existing bearer-token middleware and tool authorization. Shutdown retains its five-second grace period. Tool renaming I am not renaming tools as part of this PR. Lint & tests Linted locally with ./script/lint on Linux using the pinned golangci-lint v2.14.0. Tested locally with ./script/test (go test -race ./...) on Linux. Windows, Go 1.27.4 — go test -run '^TestServeHTTP' -count=100 -timeout 60s ./pkg/http, go test -v ./..., and UPDATE_TOOLSNAPS=true go test ./.... The verbose run passed 32 packages, 1,207 top-level tests, and 7,825 subtests. The snapshot pass produced no tracked changes. Linux, Go 1.27.4 — go test -race -run '^TestServeHTTP' -count=100 -timeout 60s ./pkg/http, go mod tidy -diff, and a CLI build. The CLI also built on Windows. The signal-to-response reproduction ran on Linux. Docs Not needed. script/generate-docs reproduced all five checked-in documentation files it generates. Skills Confirmed no bundled skill applies to the HTTP CLI shutdown lifecycle. Streamable HTTP CLI mode was introduced in #1849. AI assistance was used to investigate and reproduce the defect, author the fix and tests, review the diff, and draft this description.
Open Graph Description: Summary Wait for active Streamable HTTP requests to finish during CLI shutdown. If the five-second grace period expires, close the remaining connections and return the shutdown error. Why On SIGTER...
X Description: Summary Wait for active Streamable HTTP requests to finish during CLI shutdown. If the five-second grace period expires, close the remaining connections and return the shutdown error. Why On SIGTER...
Opengraph URL: https://github.com/github/github-mcp-server/pull/3882
X: @github
Domain: github.com
IPv4 address: 140.82.112.3
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:4f3544d6-8d1a-92c6-c60e-1e3af0fc1d68 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8C58:144D14:28AE63:371067:6B0616EA |
| html-safe-nonce | 228edff2117ef6c29b6a7dc6e21e8a9beb289a03a69c3f166c0c661873def202 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzU4OjE0NEQxNDoyOEFFNjM6MzcxMDY3OjZCMDYxNkVBIiwidmlzaXRvcl9pZCI6IjQxNjE1MjE3NzQ4NTA2MTA5MjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 00d3f84a216c0e65379484cc3cba3e77f1fcf68a5af610d03710996eeccbc463 |
| hovercard-subject-tag | pull_request:5372499682 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/github/github-mcp-server/pull/3882/files |
| twitter:image | https://avatars.githubusercontent.com/u/45381472?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/45381472?s=400&v=4 |
| og:image:alt | Summary Wait for active Streamable HTTP requests to finish during CLI shutdown. If the five-second grace period expires, close the remaining connections and return the shutdown error. Why On SIGTER... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 97d4714e567728e1f85f88b0cf68c89f0f8a3dc41e8869af7aeb8195ad990374 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/github/github-mcp-server git https://github.com/github/github-mcp-server.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 942771284 |
| octolytics-dimension-repository_nwo | github/github-mcp-server |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 942771284 |
| octolytics-dimension-repository_network_root_nwo | github/github-mcp-server |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 866f202ebf7ac5aff8f633417d9fd8a53818a977 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | no-cache |
Viewport: width=device-width