You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 60ef6fe
Browse filesBrowse the repository at this point in the historyBrowse files
fix(docker): run every server image as its non-root user
The fetch, git and time images created an app user and chowned the
virtualenv to it but never switched to it, and the filesystem, memory and
sequentialthinking images never used the node user their base image ships,
so all six ran their server as root.
Each now ends on USER app or USER node. The Python images install the
uv-managed interpreter under /python instead of /root/.local, which the app
user cannot read, and give app a home directory. The git image trusts every
mounted repository (safe.directory '*'), since a bind mount is rarely owned
by app. The memory image gives /app/dist, where its default graph lives, to
node. The READMEs cover the gitconfig path, --user on Linux hosts, and the
one-time chown of a memory volume an older image created.
Closesmodelcontextprotocol#4741
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
Copy file name to clipboardExpand all lines: src/filesystem/README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -365,6 +365,8 @@ Note: you can provide sandboxed directories to the server by mounting them to `/
365
365
### Docker
366
366
Note: all directories must be mounted to `/projects` by default.
367
367
368
+
Note: the image runs as the unprivileged `node` user (UID 1000), not root. On a Linux host, where a bind mount keeps the host's file ownership, the server can write only where UID 1000 may, and files it creates are owned by UID 1000. If your own UID differs, add `"--user", "<uid>:<gid>"` (your `id -u` and `id -g`) before `mcp/filesystem` so it reads and writes as you. Docker Desktop on macOS and Windows maps ownership to your user and needs neither.
Copy file name to clipboardExpand all lines: src/git/README.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -182,7 +182,7 @@ A tool call's `repo_path` must be inside that repository, and so must the direct
182
182
1. The server process's environment: `GIT_AUTHOR_NAME` and `GIT_AUTHOR_EMAIL` for the author, `GIT_COMMITTER_NAME` and `GIT_COMMITTER_EMAIL` for the committer. The author and the committer are resolved separately, so set all four (usually to the same name and email).
183
183
2.`user.name` and `user.email` from Git config: the repository's `.git/config`, then `~/.gitconfig`, then `$XDG_CONFIG_HOME/git/config` (by default `~/.config/git/config`), then `/etc/gitconfig`.
184
184
185
-
Unlike `git commit`, the server does not refuse to commit when neither is set. It falls back to the operating-system user and host name, so a commit made in a container is recorded as something like `root <root@3f2a1b9c8d7e>`. A local install usually finds your own `~/.gitconfig`; a Docker container has none, so give it an identity explicitly.
185
+
Unlike `git commit`, the server does not refuse to commit when neither is set. It falls back to the operating-system user and host name, so a commit made in a container is recorded as something like `app <app@3f2a1b9c8d7e>`. A local install usually finds your own `~/.gitconfig`; a Docker container has none, so give it an identity explicitly.
186
186
187
187
For a local command (`uvx`, `python -m mcp_server_git`), add an `env` block to the server's entry in your client configuration:
188
188
@@ -201,12 +201,12 @@ For a local command (`uvx`, `python -m mcp_server_git`), add an `env` block to t
201
201
}
202
202
```
203
203
204
-
For Docker, pass the variables to `docker run` with `-e`, as the Docker examples below do. Alternatively, mount your gitconfig read-only in place of the four `-e` pairs. The image runs as `root`, so it goes at `/root/.gitconfig`:
204
+
For Docker, pass the variables to `docker run` with `-e`, as the Docker examples below do. Alternatively, mount your gitconfig read-only in place of the four `-e` pairs. The image runs as the unprivileged `app` user, whose home is `/home/app`, so it goes at `/home/app/.gitconfig`:
@@ -234,6 +234,7 @@ Add this to your `claude_desktop_config.json`:
234
234
235
235
* Note: replace '/Users/username' with a path that you want to be accessible by this tool
236
236
* Note: the `-e` lines set the identity `git_commit` records; see [Commit identity](#commit-identity)
237
+
* Note: the image runs as the unprivileged `app` user, not root, and trusts every repository mounted into it (`safe.directory '*'`), since a bind mount rarely shows up owned by that user. On a Linux host, where a bind mount keeps the host's file ownership, add `"--user", "1000:1000"` (your own `id -u` and `id -g`) before `mcp/git` so the server can write to the repository and its commits leave files you own; with `--user`, mount a gitconfig at `/.gitconfig` rather than `/home/app/.gitconfig`, or use the `-e` lines. Docker Desktop on macOS and Windows needs neither.
The image runs as the unprivileged `node` user, not root. A new named volume mounted at `/app/dist` takes its ownership from the image, but a volume created by an older image, which ran as root, is owned by root, and the server fails to save with `EACCES`. Give such a volume to `node` once (the graph in it is kept):
For Awareness: a prior mcp/memory volume contains an index.js file that could be overwritten by the new container. If you are using a docker volume for storage, delete the old docker volume's `index.js` file before starting the new container.
0 commit comments