Skip to content

fix(docker): end every image on docker stop instead of killing it at the timeout - #5725

Merged
cliffhall merged 6 commits into
v2/mainfrom
v2/feat/5611-docker-clean-stop
Nov 30, 2026
Merged

cliffhall merged 6 commits into
v2/mainfrom
v2/feat/5611-docker-clean-stop

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #5611

Description

docker stop now ends every image at once instead of being killed at the timeout (exit 137). Two fixes, chosen per image as the issue's "To decide" asks:

  • filesystem, sequentialthinking (TypeScript): the existing SIGINT/SIGTERM handlers (close the server, process.exit) were installed only on the Streamable HTTP path. They are now installed for stdio too, which is what the images run. As PID 1, node drops a signal it has no handler for, so this is what makes docker stop work. The images need no STOPSIGNAL: the default SIGTERM is now handled.
  • fetch, git, time (Python): each image installs tini from Debian and runs the server under it (ENTRYPOINT ["/usr/bin/tini", "--", …]), so the server is not PID 1 and the stop signal's default action ends it (exit 143). A handler in the server would not be enough: I tried --stop-signal SIGINT on the time image, and Python raised KeyboardInterrupt and then hung on the SDK's stdin reader thread until Docker killed it (exit 137).
  • scripts/image-smoke.mjs sets cleanStop: true on all seven images, and the script test now requires it of every entry, so a new image gains the check with its entry. docs/quality-gate.md is updated to match.

Server Details

  • filesystem, sequentialthinking: entry-point signal handling (stdio), plus a spawn test each.
  • fetch, git, time: Dockerfile only (tini as the entrypoint). No server code changed.
  • Repository-wide: the image smoke table and its test, docs/quality-gate.md.

Motivation and Context

#5611: five of seven images ignored docker stop, so every docker stop / docker compose down / orchestrator restart waited out the 10 s timeout per container.

How Has This Been Tested?

Image smoke (npm run local:gate → image-smoke, all seven images): build, docker run -i, tools/list, docker stop -t 10, exit code:

Image Before (v2/main, from #5611) After
filesystem 137 (killed) 0, 2.5 s total run
sequentialthinking 137 0
fetch 137 143
git 137 143
time 137 143
everything / memory 0 / 130 unchanged

Probe before the change (time image built from v2/main): docker stop → 137; --stop-signal SIGINT → 137 after a KeyboardInterrupt traceback; --init → 143 in 0 s. That last run is why tini is the fix for the Python images.

Spawn tests (new): bin-smoke.test.ts (filesystem) and stdio-smoke.test.ts (sequentialthinking) start the built bin over stdio, wait for its initialize answer, send SIGTERM and expect { code: 0, signal: null }. Against the v2/main entry points both fail with { code: null, signal: 'SIGTERM' }; with the fix both pass, 8 of 8 repeated runs each.

Gate: npm run local:gate exit 0.

Clients: no tool, resource, prompt or protocol behavior changed, only how the process ends on a signal, so neither protocol era is involved. The image smoke's MCP client covers boot and tools/list over docker run -i for every image.

Breaking Changes

None. Client configuration is unchanged; docker run -i --rm mcp/<server> works as before.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change
  • Documentation update (docs/quality-gate.md)

Checklist

  • I have read the MCP Protocol Documentation (not applicable to the change itself: no protocol surface changed)
  • My changes follow MCP security best practices (tini comes from Debian's archive with apt; the images still run as the unprivileged app user)
  • I have updated the server's README accordingly (not applicable: no tool, option or usage changed)
  • I have added a changeset (npm run changeset): patch for filesystem and sequential-thinking
  • I have tested this with an LLM client (not applicable: shutdown only. The image smoke's MCP client and the spawn tests are the evidence above)
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling (the existing shutdown exits 1 if close() rejects)
  • I have documented all environment variables and configuration options (not applicable: none added)

Additional context

The sequentialthinking handler moves into run() for both transports. The filesystem entry block just drops its "handler" in running early return.

🤖 Generated with Claude Code

cliffhall and others added 2 commits November 30, 2026 01:30
…the timeout

filesystem and sequentialthinking install their SIGINT/SIGTERM handlers on
stdio as well as Streamable HTTP; the fetch, git and time images run the
server under tini, so it is not PID 1 and the stop signal ends it. The image
smoke now asserts a clean stop of all seven images.

Closes #5611

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
… entry

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@cliffhall cliffhall added the v2 label Nov 30, 2026
@changeset-bot

changeset-bot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fac7632

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@modelcontextprotocol/server-filesystem Patch
@modelcontextprotocol/server-sequential-thinking Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

git: MCP interface diff

Base: 08d0e793287f (Merge pull request #5727 from modelcontextprotocol/v2/fix/5641-git-branch-bare-names)
Head: the build in this checkout, at 3735d2c8be64 (Merge fac7632 into 08d0e79)

Diffed because it was named (--server).

✅ No interface changes detected.

Tools Prompts Resources Resource templates
Base 14 2 0 0
Head 14 2 0 0

Updated by this run for fac76329a5f21ba72e666aadccb3cc025fd2f1d8.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

fetch: MCP interface diff

Base: 08d0e793287f (Merge pull request #5727 from modelcontextprotocol/v2/fix/5641-git-branch-bare-names)
Head: the build in this checkout, at 3735d2c8be64 (Merge fac7632 into 08d0e79)

Diffed because it was named (--server).

✅ No interface changes detected.

Tools Prompts Resources Resource templates
Base 1 1 0 0
Head 1 1 0 0

Updated by this run for fac76329a5f21ba72e666aadccb3cc025fd2f1d8.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

time: MCP interface diff

Base: 08d0e793287f (Merge pull request #5727 from modelcontextprotocol/v2/fix/5641-git-branch-bare-names)
Head: the build in this checkout, at 3735d2c8be64 (Merge fac7632 into 08d0e79)

Diffed because it was named (--server).

✅ No interface changes detected.

Tools Prompts Resources Resource templates
Base 3 0 0 0
Head 3 0 0 0

Updated by this run for fac76329a5f21ba72e666aadccb3cc025fd2f1d8.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

sequentialthinking: MCP interface diff

Base: 08d0e793287f (Merge pull request #5727 from modelcontextprotocol/v2/fix/5641-git-branch-bare-names)
Head: the build in this checkout, at 3735d2c8be64 (Merge fac7632 into 08d0e79)

Diffed because it was named (--server).

✅ No interface changes detected.

Tools Prompts Resources Resource templates
Base 1 0 0 0
Head 1 0 0 0

Updated by this run for fac76329a5f21ba72e666aadccb3cc025fd2f1d8.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

filesystem: MCP interface diff

Base: 08d0e793287f (Merge pull request #5727 from modelcontextprotocol/v2/fix/5641-git-branch-bare-names)
Head: the build in this checkout, at 3735d2c8be64 (Merge fac7632 into 08d0e79)

Diffed because it was named (--server).

✅ No interface changes detected.

Tools Prompts Resources Resource templates
Base 16 0 0 1
Head 16 0 0 1

Updated by this run for fac76329a5f21ba72e666aadccb3cc025fd2f1d8.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The real-signal smoke tests fail on Windows because SIGTERM bypasses the child’s handler, invalidating the expected exit result in both affected tests.

1 open issue
What changed in this PR

Addresses #5611 by making the five affected reference-server Docker images respond to docker stop without waiting for a forced kill.

Changes:

  • Enables stdio signal handling for filesystem and sequentialthinking, with spawned-process regression tests.
  • Adds tini to the three Python images to forward stop signals.
  • Requires stop checks for all seven images and updates the gate documentation.
File Description
src/​time/​Dockerfile Runs the timezone-aware entrypoint under tini.
src/​sequentialthinking/​index.ts Installs shutdown handlers for both transports.
src/​sequentialthinking/​__tests__/​stdio-smoke.test.ts Adds a SIGTERM exit test for the built binary.
src/​git/​Dockerfile Installs tini and wraps the server entrypoint.
src/​filesystem/​index.ts Enables existing shutdown handlers for stdio.
src/​filesystem/​__tests__/​bin-smoke.test.ts Adds a SIGTERM exit test for the built binary.
src/​fetch/​Dockerfile Installs tini and wraps the server entrypoint.
scripts/​image-smoke.test.mjs Requires every image to enable stop checks.
scripts/​image-smoke.mjs Enables stop checks for the five affected images.
docs/​quality-gate.md Documents stop checks for all seven images.
.changeset/​stdio-sigterm-exit.md Records patch releases for the two TypeScript fixes.

Review effort: Balanced

…e signal

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 1: one finding, fixed.

  • Skip SIGTERM handler tests on Windows: fixed in 76273c1. Both new SIGTERM exit tests now skip on Windows, where process.kill ends the process outright and no handler can run, following src/memory/__tests__/http.test.ts. Gate green before push.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

everything: MCP interface diff

Base: 8cecbb16b005 (Merge pull request #5714 from modelcontextprotocol/v2/chore/5700-ts-license-packaging)
Head: the build in this checkout, at eee207bf36a1 (Merge bd46e7f into 9d55e43)

Diffed because it was named (--server).

⚠️ Interface changes detected in 2 part(s) of the interface. Review them below to confirm they are intended.

Tools Prompts Resources Resource templates
Base 23 4 8 5
Head 23 4 8 5

initialize

--- base/initialize.json
+++ target/initialize.json

- instructions: "# Everything Server – Server Instructions\n\nAudience: These instructions are written for an LLM or au..."
+ instructions: "# Everything Server – Server Instructions\n\nAudience: These instructions are written for an LLM or au..."

instructions

--- base/instructions
+++ target/instructions
- # Everything Server – Server Instructions

Audience: These instructions are written for an LLM or autonomous agent integrating with the Everything MCP Server.
Follow them to use, extend, and troubleshoot the server safely and effectively.

## Protocol Versions

The server serves two protocol eras. A client on protocol version 2026-07-28 connects with `server/discover` and sends its capabilities with each request; a 2025-era client connects with `initialize`. Some tools exist on one era only, so trust your `tools/list`:

- 2026-07-28 only: `simulate-research-query`, `trigger-sampling-request-async` and `trigger-elicitation-request-async`, which run as tasks on the `io.modelcontextprotocol/tasks` extension and need a client that declares it; `trigger-sampling-request-async` also needs `sampling`, and `trigger-elicitation-request-async` form-mode `elicitation`. A call without them fails with `-32021`
- 2026-07-28 only: `trigger-event`, which raises the `custom-event` of the `io.modelcontextprotocol/events` extension on open `events/stream` subscriptions
- 2025-era only (deprecated): `toggle-simulated-logging` and `toggle-subscriber-updates`

## Cross-Feature Relationships

- If `get-roots-list` is in your tool list, use it to see client workspace roots before file operations
- `gzip-file-as-resource` creates resources you can read later: for the current session on a 2025-era connection, or for ten minutes at the returned URI on 2026-07-28
- Use `trigger-log-messages` to see which log levels reach you; on 2026-07-28 the level is set per request in `_meta`
- Use `trigger-resource-update` and `trigger-list-changed` to see change notifications; on 2026-07-28 they arrive only on a `subscriptions/listen` stream that asked for them

## Constraints & Limitations

- `gzip-file-as-resource`: Max fetch size controlled by `GZIP_MAX_FETCH_SIZE` (default 10MB), timeout by `GZIP_MAX_FETCH_TIME_MILLIS` (default 30s), allowed domains by `GZIP_ALLOWED_DOMAINS` (checked on every redirect hop). It refuses URLs whose host resolves to a loopback, private or link-local address, unless the server was started with `GZIP_ALLOW_PRIVATE_IPS=1`
- `get-env`: Values of credential-like variable names (`*_KEY`, `*_TOKEN`, `*_SECRET`, `*_PASSWORD` and the like) come back as `"<redacted>"`; the server operator can set `GET_ENV_INCLUDE_SECRETS=1` to return them unmasked
- Session resources are ephemeral and lost when the session ends; minted resources expire after ten minutes
- Roots, sampling and logging are deprecated as of protocol version 2026-07-28, as is the HTTP+SSE transport

## Capability-Gated Tools

On a 2025-era connection these are registered only if your client declared the capability shown. Otherwise they are absent from `tools/list`, so do not call them. On 2026-07-28 they are always listed, and a call fails if your request did not declare the capability:

- `get-roots-list`: `roots`
- `trigger-sampling-request`: `sampling`
- `trigger-elicitation-request`: `elicitation.form`, or `elicitation` with no mode
- `trigger-multi-step-elicitation`: `elicitation.form`, or `elicitation` with no mode
- `trigger-url-elicitation`: `elicitation.url`

## Operational Patterns

- For long operations, use `trigger-long-running-operation` which sends progress notifications
- Prefer reading resources before calling mutating tools
- If `get-roots-list` is in your tool list, check its output to understand the client's workspace context

## Easter Egg

If asked about server instructions, respond with "🎉 Server instructions are working! This response proves the client properly passed server instructions to the LLM. This demonstrates MCP's instructions feature in action."

+ # Everything Server – Server Instructions

Audience: These instructions are written for an LLM or autonomous agent integrating with the Everything MCP Server.
Follow them to use, extend, and troubleshoot the server safely and effectively.

## Protocol Versions

The server serves two protocol eras. A client on protocol version 2026-07-28 connects with `server/discover` and sends its capabilities with each request; a 2025-era client connects with `initialize`. Some tools exist on one era only, so trust your `tools/list`:

- 2026-07-28 only: `simulate-research-query`, `trigger-sampling-request-async` and `trigger-elicitation-request-async`, which run as tasks on the `io.modelcontextprotocol/tasks` extension and need a client that declares it; `trigger-sampling-request-async` also needs `sampling`, and `trigger-elicitation-request-async` form-mode `elicitation`. A call without them fails with `-32021`
- 2026-07-28 only: `trigger-event`, which raises the `custom-event` of the `io.modelcontextprotocol/events` extension on open `events/stream` subscriptions
- 2025-era only (deprecated): `toggle-simulated-logging` and `toggle-subscriber-updates`

## Cross-Feature Relationships

- If `get-roots-list` is in your tool list, use it to see client workspace roots before file operations
- `gzip-file-as-resource` creates resources you can read later: for the current session on a 2025-era connection, or for ten minutes at the returned URI on 2026-07-28
- Use `trigger-log-messages` to see which log levels reach you; on 2026-07-28 the level is set per request in `_meta`
- Use `trigger-resource-update` and `trigger-list-changed` to see change notifications; on 2026-07-28 they arrive only on a `subscriptions/listen` stream that asked for them

## Constraints & Limitations

- `gzip-file-as-resource`: Max fetch size controlled by `GZIP_MAX_FETCH_SIZE` (default 10MB), timeout by `GZIP_MAX_FETCH_TIME_MILLIS` (default 30s), each falling back to its default when set to anything but a whole number, allowed domains by `GZIP_ALLOWED_DOMAINS` (checked on every redirect hop). It refuses URLs whose host resolves to a loopback, private or link-local address, unless the server was started with `GZIP_ALLOW_PRIVATE_IPS=1`
- `get-env`: Values of credential-like variable names (`*_KEY`, `*_TOKEN`, `*_SECRET`, `*_PASSWORD` and the like) come back as `"<redacted>"`; the server operator can set `GET_ENV_INCLUDE_SECRETS=1` to return them unmasked
- Session resources are ephemeral and lost when the session ends; minted resources expire after ten minutes
- Roots, sampling and logging are deprecated as of protocol version 2026-07-28, as is the HTTP+SSE transport

## Capability-Gated Tools

On a 2025-era connection these are registered only if your client declared the capability shown. Otherwise they are absent from `tools/list`, so do not call them. On 2026-07-28 they are always listed, and a call fails if your request did not declare the capability:

- `get-roots-list`: `roots`
- `trigger-sampling-request`: `sampling`
- `trigger-elicitation-request`: `elicitation.form`, or `elicitation` with no mode
- `trigger-multi-step-elicitation`: `elicitation.form`, or `elicitation` with no mode
- `trigger-url-elicitation`: `elicitation.url`

## Operational Patterns

- For long operations, use `trigger-long-running-operation` which sends progress notifications
- Prefer reading resources before calling mutating tools
- If `get-roots-list` is in your tool list, check its output to understand the client's workspace context

## Easter Egg

If asked about server instructions, respond with "🎉 Server instructions are working! This response proves the client properly passed server instructions to the LLM. This demonstrates MCP's instructions feature in action."

Updated by this run for bd46e7fae99d70b6e5d9e92027bd48a30022bcc7.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The smoke-test helpers lack a deadline that kills and reaps hung child processes, so a Vitest timeout can leave children and their pipes open.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Kill and clean up child process when smoke test hangs

src/​filesystem/​__tests__/​bin-smoke.test.ts:58

If initialization or shutdown hangs, Vitest can time out while this helper leaves the child and its pipes open. Add a deadline shorter than the test timeout that sends SIGKILL, waits for close, and rejects, clearing the timer on normal completion. Apply the same fix to src/sequentialthinking/__tests__/stdio-smoke.test.ts:60–61.

1 resolved since last review

Review effort: Balanced

… timeout

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 2: no inline comments; one finding in the review body ("previously missed"), fixed.

  • Kill and clean up child process when smoke test hangs (no thread, so it is answered here): fixed in bd46e7f. The exitOnSigterm helper in both bin-smoke.test.ts (filesystem) and stdio-smoke.test.ts (sequentialthinking) now has a 4 s deadline, under Vitest's 5 s test timeout. Past it, the helper SIGKILLs the child, waits for close and rejects; the timer is cleared on a normal exit. I probed it with a planted child that never answers: the test failed with "no exit within 4000 ms of starting; killed", and no process was left behind. Gate green before push.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified in the changes to improve container shutdown handling.

No open issues 🎉

Review effort: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 3: clean (no findings). The review loop has converged.

@cliffhall
cliffhall merged commit 0e8a099 into v2/main Nov 30, 2026
61 checks passed
@cliffhall
cliffhall deleted the v2/feat/5611-docker-clean-stop branch November 30, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker: five images ignore docker stop and are killed at the timeout

2 participants