HUB
Sign inSign up
synology-mcp logo

visibilityspots/synology-mcp

By visibilityspots

•Updated 3 days ago

Synology DSM MCP server (rafalr100/synology-mcp) over streamable HTTP, as a container image

Buildkit cacheImage
0

265

visibilityspots/synology-mcp repository overview

⁠Synology MCP

trivy docker-hub-description build status gitHub release docker image size docker pulls license

a container image of rafalr100/synology-mcp⁠, an MCP⁠ server for Synology DSM, served over streamable HTTP instead of stdio, plus two extra tools: get_docker_project and rebuild_docker_project.

⁠run

$ docker run -d --name synology-mcp -p 8080:8080 \
    -e SYNOLOGY_URL=https://<nas>:5001 \
    -e SYNOLOGY_USER=<dsm user> \
    -e SYNOLOGY_PASS=<dsm password> \
    -e SYNOLOGY_MCP_ALLOWED_HOSTS=<public host name> \
    visibilityspots/synology-mcp:latest
$ claude mcp add --transport http synology https://<public host name>/mcp

The /mcp endpoint has no authentication. Anyone who reaches the port can call every tool with the DSM account's rights. Only run it on a trusted network, behind a reverse proxy that restricts who gets through.

⁠What this image changes

  1. Transport. Upstream's python -m synology_mcp runs FastMCP over stdio, which suits a desktop client that spawns the process. http_server.py imports the same tools and runs the same FastMCP instance over streamable HTTP on :8080/mcp.
  2. mcp<2. Upstream asks for mcp[cli]>=1.0.0, which now resolves to mcp 2.x, where FastMCP was renamed to MCPServer. Built unpinned, the container dies at start with ModuleNotFoundError: No module named 'mcp.server.fastmcp'. The pin goes once upstream migrates.
  3. Host allowlist. The MCP SDK turns on DNS rebinding protection with allowed_hosts of 127.0.0.1/localhost only. Behind a reverse proxy every request then comes back 421 Misdirected Request, from the server, not from the proxy. SYNOLOGY_MCP_ALLOWED_HOSTS is the allowlist.
  4. Project rebuild. Upstream can restart a container but not move a Container Manager project onto a new image. project_tools.py adds get_docker_project and rebuild_docker_project. The latter is DSM's own "Build" (SYNO.Docker.Project build with force_pull): it pulls while the old container keeps running, then recreates only what changed. Edit the image tag in the project's compose file first; DSM reads that file from disk. Off unless SYNOLOGY_ENABLE_PROJECT_REBUILD=true, and limited to the projects in SYNOLOGY_REBUILD_PROJECTS.
  5. DSM 6 login (patches/0001-dsm6-auth-path.patch). Upstream always logs in on entry.cgi. DSM 6 serves SYNO.API.Auth only on auth.cgi and answers entry.cgi with error 102, which upstream reports as Synology authentication failed (code 102: unknown error): it looks like a credential problem and is not one. The patch asks SYNO.API.Info (no session needed) which CGI serves Auth, and falls back to entry.cgi. DSM 7 behaves as before. DSM 6 has a second trap that needs no patch: it answers an unknown session name (upstream default SynologyMCP) with code 400, the same code as a wrong password. Set SYNOLOGY_SESSION_NAME=FileStation against a DSM 6 box.

⁠Configuration

variabledefault
SYNOLOGY_URLhttp://localhost:5000DSM address
SYNOLOGY_USER / SYNOLOGY_PASSDSM account
SYNOLOGY_VERIFY_SSLfalseverify the DSM certificate
SYNOLOGY_ENABLE_POWER_CONTROLfalsereboot, shutdown and DSM update tools refuse unless true
SYNOLOGY_MCP_HOST0.0.0.0listen address
SYNOLOGY_MCP_PORT8080listen port
SYNOLOGY_MCP_ALLOWED_HOSTScomma-separated Host names to accept; name:* accepts any port, * alone turns the protection off
SYNOLOGY_ENABLE_PROJECT_REBUILDfalseallow rebuild_docker_project
SYNOLOGY_REBUILD_PROJECTSContainer Manager projects it may rebuild, exact names
SYNOLOGY_REBUILD_TIMEOUT900seconds a rebuild may take (the pull)

See upstream's README for the other variables (2FA, session and device names).

Most DSM system, storage and package APIs refuse a non-admin account with error 105, so a useful account usually ends up in the administrators group. Put the limits elsewhere: leave power control off, and give a read-only client an allowlist of read tools.

Credentials are not checked at start: the server logs in lazily on the first tool call. A clean start says nothing about the DSM login; call get_system_info to prove it.

⁠build

$ docker build -t visibilityspots/synology-mcp:latest .

The upstream commit is SYNOLOGY_MCP_REF in the Dockerfile. The image version follows the version in upstream's pyproject.toml at that commit: v<version>-<build>. The patches are applied with git apply, so a bump that breaks one fails the build.

⁠buildx
$ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
$ docker buildx build -t visibilityspots/synology-mcp:latest --platform linux/amd64,linux/arm64 --push .
⁠dgoss

The tests in goss.yaml run the real entrypoint without a NAS behind it. They do a real MCP round trip (initialize, tools/list) under an allowed Host name that must list 73 tools (71 upstream, 2 local), check that a foreign Host gets 421, and check that the DSM 6 patch is in the installed package. goss_wait.yaml waits until the port listens.

A test on 127.0.0.1 without a Host header would pass even with a broken allowlist, since localhost is what the SDK allows by default; the tests set the header on purpose.

$ dgoss run -e SYNOLOGY_MCP_ALLOWED_HOSTS=mcp.example.org visibilityspots/synology-mcp:dev
...
Count: 14, Failed: 0, Skipped: 0
INFO: Deleting container
⁠act

using act⁠ for local testing of the written github actions makes my life and commit history a lot easier;

Stage  Job ID  Job name  Workflow name           Workflow file               Events
0      update  update    docker-hub-description  docker-hub-description.yml  push
0      main    main      CI                      main.yml                    push,pull_request
0      scan    scan      trivy                   trivy.yml                   workflow_dispatch,push,schedule
⁠release

Images are built and pushed by the shared workflow in visibilityspots/github-workflows⁠ when a tag is pushed. Pushing to main builds nothing; a pull request only builds and runs dgoss.

⁠License

Distributed under the MIT license⁠. Upstream rafalr100/synology-mcp⁠ is MIT licensed as well.

Tag summary
Recent tags
Content type
Image
Digest
sha256:1df2b9efa…
Size
58.9 MB
Last updated
3 days ago
docker pull visibilityspots/synology-mcp:latest