Skip to content

Commit 5a5aa85

Browse files
authored
Merge pull request #5294 from modelcontextprotocol/v2/fix/5182-time-docker-timezone
fix(time): expand LOCAL_TIMEZONE in the Docker image at run time
2 parents fad555f + 11dfdef commit 5a5aa85

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎src/time/Dockerfile‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ COPY --from=uv --chown=app:app /app/.venv /app/.venv
3535
# Place executables in the environment at the front of the path
3636
ENV PATH="/app/.venv/bin:$PATH"
3737

38-
# Set the LOCAL_TIMEZONE environment variable
39-
ENV LOCAL_TIMEZONE=${LOCAL_TIMEZONE:-"UTC"}
40-
41-
# when running the container, add --local-timezone and a bind mount to the host's db file
42-
ENTRYPOINT ["mcp-server-time", "--local-timezone", "${LOCAL_TIMEZONE}"]
38+
# The local timezone, overridable at run time with `docker run -e LOCAL_TIMEZONE=…`
39+
ENV LOCAL_TIMEZONE=UTC
40+
41+
# Docker expands no variables in an exec-form ENTRYPOINT, so a shell reads
42+
# LOCAL_TIMEZONE when the container starts (UTC when it is set but empty).
43+
# `exec` keeps the server as PID 1, so it receives stop signals, and "$@"
44+
# passes any arguments given after the image name on to the server.
45+
ENTRYPOINT ["sh", "-c", "exec mcp-server-time --local-timezone \"${LOCAL_TIMEZONE:-UTC}\" \"$@\"", "--"]

‎src/time/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ Example:
218218
}
219219
```
220220

221+
The Docker image cannot see the host's timezone, so it reads the `LOCAL_TIMEZONE` environment variable when the container starts, and uses `UTC` when it is unset or empty. Pass it with `-e`: `"-e", "LOCAL_TIMEZONE"` forwards the client's own value, as in the Docker configuration above, and `"-e", "LOCAL_TIMEZONE=America/New_York"` sets one. A `--local-timezone` given after the image name takes precedence.
222+
221223
## Example Interactions
222224

223225
1. Get current time:

0 commit comments

Comments
 (0)