Skip to content

Commit f5eeb83

Browse files
cliffhallclaude
andcommitted
fix(everything): build the Docker image from the workspace lockfile, with a Streamable HTTP mode
The Dockerfile copied src/everything alone and ran a lockfile-less npm install, so the image ignored the root package-lock.json and the overrides that pin transitive dependencies, and `--omit-dev` was not an npm flag. Its CMD also took the whole command, so `docker run mcp/everything streamableHttp` failed with "Cannot find module '/app/streamableHttp'". Build from the repository root with npm ci against the workspace lockfile, keep the context to what the build reads with a Dockerfile.dockerignore, run as the node user, expose PORT 3001, stop on SIGINT, and split ENTRYPOINT from a `stdio` CMD so the transport name is the run argument. Document building and running both modes in the README. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 446be48 commit f5eeb83

3 files changed

Lines changed: 94 additions & 11 deletions

File tree

‎src/everything/Dockerfile‎

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,64 @@
1+
# The `everything` server's container image (#3309). Build it from the
2+
# repository root, which is the build context:
3+
#
4+
# docker build -f src/everything/Dockerfile -t mcp/everything .
5+
#
6+
# `everything` is an npm workspace, so its lockfile and the `overrides` that pin
7+
# its transitive dependencies live in the root package.json and
8+
# package-lock.json, not in src/everything. Both stages install from them with
9+
# `npm ci`, so the image gets exactly the versions this repository tested,
10+
# rather than whatever a lockfile-less `npm install` resolves on the day.
11+
# Dockerfile.dockerignore (next to this file) keeps the context to what the
12+
# build reads.
13+
#
14+
# The image runs the server over stdio by default (`docker run -i`); give the
15+
# transport name as the argument to run another, e.g. `streamableHttp`, which
16+
# listens on PORT (3001) on every interface so a published port reaches it.
17+
# The README's "Running with Docker" section has both commands. This repository
18+
# publishes no image: `mcp/everything` on Docker Hub is built by Docker.
19+
120
FROM node:24-alpine AS builder
221

3-
COPY src/everything /app
4-
COPY tsconfig.json /tsconfig.json
22+
WORKDIR /repo
523

6-
WORKDIR /app
24+
# Manifests first, so the dependency layer is reused until one of them changes.
25+
COPY package.json package-lock.json .npmrc tsconfig.json ./
26+
COPY src/everything/package.json src/everything/
727

8-
RUN --mount=type=cache,target=/root/.npm npm install
28+
# `--ignore-scripts` skips the workspace's `prepare` build, which needs the
29+
# source; the build runs explicitly below.
30+
RUN --mount=type=cache,target=/root/.npm \
31+
npm ci --workspace src/everything --ignore-scripts
932

10-
FROM node:24-alpine AS release
33+
COPY src/everything src/everything
34+
RUN npm run build --workspace src/everything
1135

12-
WORKDIR /app
1336

14-
COPY --from=builder /app/dist /app/dist
15-
COPY --from=builder /app/package.json /app/package.json
16-
COPY --from=builder /app/package-lock.json /app/package-lock.json
37+
FROM node:24-alpine AS release
1738

1839
ENV NODE_ENV=production
1940

20-
RUN npm ci --ignore-scripts --omit-dev
41+
WORKDIR /repo
42+
43+
COPY package.json package-lock.json .npmrc ./
44+
COPY src/everything/package.json src/everything/
45+
46+
RUN --mount=type=cache,target=/root/.npm \
47+
npm ci --workspace src/everything --omit=dev --ignore-scripts
48+
49+
COPY --from=builder /repo/src/everything/dist src/everything/dist
50+
51+
WORKDIR /repo/src/everything
52+
53+
USER node
54+
55+
# The Streamable HTTP (and deprecated HTTP+SSE) transports' default port.
56+
ENV PORT=3001
57+
EXPOSE 3001
58+
59+
# Both transports close cleanly on SIGINT; node running as PID 1 would ignore
60+
# the default SIGTERM, leaving `docker stop` to wait out its timeout.
61+
STOPSIGNAL SIGINT
2162

22-
CMD ["node", "dist/index.js"]
63+
ENTRYPOINT ["node", "dist/index.js"]
64+
CMD ["stdio"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# The build context for src/everything/Dockerfile (#3309). BuildKit reads a
2+
# `<Dockerfile>.dockerignore` beside the Dockerfile in place of a root
3+
# .dockerignore, so this allow-list applies to this image only. The context is
4+
# the repository root, so start from nothing and admit only what the build
5+
# copies: the root manifests and lockfile, and the server's source without
6+
# its build output or test artifacts.
7+
*
8+
!package.json
9+
!package-lock.json
10+
!.npmrc
11+
!tsconfig.json
12+
!src/everything
13+
src/everything/node_modules
14+
src/everything/dist
15+
src/everything/coverage

‎src/everything/README.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,32 @@ npx @modelcontextprotocol/server-everything streamableHttp
167167
npx @modelcontextprotocol/server-everything sse
168168
```
169169

170+
## Running with Docker
171+
172+
This repository publishes no image; build one from the repository root (the build context):
173+
174+
```shell
175+
docker build -f src/everything/Dockerfile -t mcp/everything .
176+
```
177+
178+
The `mcp/everything` image on Docker Hub is built by Docker, not by this repository, and can lag behind it.
179+
180+
### Run over stdio (the default)
181+
182+
```shell
183+
docker run -i --rm mcp/everything
184+
```
185+
186+
`-i` keeps stdin open, which the stdio transport reads. This is the command an MCP client configuration launches.
187+
188+
### Run the Streamable HTTP server
189+
190+
```shell
191+
docker run --rm -p 127.0.0.1:3001:3001 mcp/everything streamableHttp
192+
```
193+
194+
The endpoint is `http://localhost:3001/mcp`. The server listens on port 3001 on every interface inside the container; `127.0.0.1:` publishes it on the host's loopback only. To use another port, set `PORT` and publish that one (`-e PORT=8080 -p 127.0.0.1:8080:8080`). The localhost-only `Origin` check described above applies inside the container too. `docker stop` ends the server cleanly.
195+
170196
## License
171197

172198
This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

0 commit comments

Comments
 (0)