Skip to content

feat(core-mcp-server): handle SIGTERM #805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Conversation

mrlikl
Copy link

@mrlikl mrlikl commented Jul 14, 2025

Summary

Changes

This PR adds signal handling for SIGTERM and SIGINT to the MCP core server, enabling graceful shutdown when the server receives termination signals.

User experience

Before: When the Q CLI exits, the MCP container server is left orphaned.

After: The server now handles termination signals properly, logging shutdown events and exiting cleanly. This ensures no lingering containers when the Q CLI exits.

Tested by building the container locally with a different tag, and adding this to q's mcp.json, when q exits, the core server container is shut down.

Checklist

If your change doesn't seem to apply, please leave them unchecked.

  • I have reviewed the contributing guidelines
  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented

Is this a breaking change? No

RFC issue number:

Checklist:

  • Migration process documented
  • Implement warnings (if it can live side by side)

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

@mrlikl mrlikl requested review from PaulVincent707 and a team as code owners July 14, 2025 09:19
Copy link
Member

@scottschreckengaust scottschreckengaust left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens without the SIGTERM or SIGINT?

@scottschreckengaust
Copy link
Member

What happens without the SIGTERM or SIGINT?

Forgive me, I see the PR comment

Copy link

codecov bot commented Jul 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.77%. Comparing base (f916a5e) to head (57254e5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #805      +/-   ##
==========================================
+ Coverage   88.76%   88.77%   +0.01%     
==========================================
  Files         560      566       +6     
  Lines       38754    38885     +131     
  Branches     5994     6013      +19     
==========================================
+ Hits        34399    34520     +121     
- Misses       2819     2826       +7     
- Partials     1536     1539       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@stevenshim
Copy link

@mrlikl Can we have signal.SIGHUP event? If user close terminal window(e.g. iTerm or Terminal app), the signal come with SIGHUP.
I guess some people experience when they just close a terminal window without /quit command or just interrupt by "ctrl+c".

@mrlikl
Copy link
Author

mrlikl commented Jul 24, 2025

@stevenshim I added the change, thank you for the suggestion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants