From 208067766a493a2513b3672dc8dda811615385ba Mon Sep 17 00:00:00 2001 From: Michael Roll <44135113+Mikei386@users.noreply.github.com> Date: Mon, 23 Nov 2026 21:01:16 +0100 Subject: [PATCH] =?UTF-8?q?0.10.1:=20erlaubte=20HTTP-Hosts=20per=20MCP=5FA?= =?UTF-8?q?LLOWED=5FHOSTS=20statt=20fester=20LAN-Adresse;=20LICENSE=20erg?= =?UTF-8?q?=C3=A4nzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 7 +++++++ LICENSE | 22 ++++++++++++++++++++++ README.md | 6 ++++++ pyproject.toml | 2 +- src/syncthing_mcp/__init__.py | 2 +- src/syncthing_mcp/models.py | 2 +- src/syncthing_mcp/server.py | 16 +++++++++++++++- stallari-plugin.yaml | 2 +- tests/test_tools_maintenance.py | 9 +++++++++ uv.lock | 2 +- 10 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 LICENSE diff --git a/CHANGELOG.md b/CHANGELOG.md index 35cebac..60ac6db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ All notable changes to `syncthing-blade-mcp` will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +## [0.10.1] - 2026-11-23 + +### Changed + +- Allowed HTTP hosts are configurable via `MCP_ALLOWED_HOSTS` instead of a + hard-coded LAN address; LICENSE file added (MIT, as stated in the README). + ## [0.10.0] - 2026-11-23 ### Fixed diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a25005d --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2026 Piers Dawson-Damer / Groupthink (original syncthing-blade-mcp) +Copyright (c) 2026 Michael Roll (fork additions) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index a0d7a16..ab19a70 100644 --- a/README.md +++ b/README.md @@ -310,6 +310,12 @@ Bearer token auth (`MCP_AUTH_TOKEN`) secures the endpoint; `/health` is unauthen } ``` +## Allowed hosts (HTTP transport) + +The Streamable HTTP transport only accepts requests whose `Host` header is +`localhost`, `127.0.0.1` or `[::1]`. Add LAN names or addresses with +`MCP_ALLOWED_HOSTS`, a comma-separated list such as `192.168.1.10:*,nas.lan:*`. + ## Running Tests ```bash diff --git a/pyproject.toml b/pyproject.toml index 13ba2f6..4aa89d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "syncthing-blade-mcp" -version = "0.10.0" +version = "0.10.1" description = "MCP server for Syncthing — token-efficient replication management, multi-instance, safe disk-space reclamation." requires-python = ">=3.11" dependencies = [ diff --git a/src/syncthing_mcp/__init__.py b/src/syncthing_mcp/__init__.py index be45a48..dad600b 100644 --- a/src/syncthing_mcp/__init__.py +++ b/src/syncthing_mcp/__init__.py @@ -1,3 +1,3 @@ """Syncthing MCP Server — manage Syncthing instances via MCP tools.""" -__version__ = "0.10.0" +__version__ = "0.10.1" diff --git a/src/syncthing_mcp/models.py b/src/syncthing_mcp/models.py index ee45204..30b2b73 100644 --- a/src/syncthing_mcp/models.py +++ b/src/syncthing_mcp/models.py @@ -337,7 +337,7 @@ class AddDeviceInput(WriteParams): device_id: str = Field(..., description=_DEVICE_ID_HELP, min_length=1) name: str = Field(..., description="Friendly device name", min_length=1) addresses: list[str] | None = Field( - None, description="Optional addresses, e.g. ['tcp://192.168.1.20:22000']. Default: dynamic." + None, description="Optional addresses, e.g. ['tcp://192.0.2.20:22000']. Default: dynamic." ) confirm: bool = Field(False, description=_CONFIRM_DESCRIPTION) diff --git a/src/syncthing_mcp/server.py b/src/syncthing_mcp/server.py index 3d7a03f..3e8cfd1 100644 --- a/src/syncthing_mcp/server.py +++ b/src/syncthing_mcp/server.py @@ -130,6 +130,20 @@ def compute_domain_hints_for_records( return out +def _allowed_hosts() -> list[str]: + """Host headers accepted by the HTTP transport (DNS-rebinding protection). + + Always localhost; extra hosts come from ``MCP_ALLOWED_HOSTS`` as a comma list, + e.g. ``MCP_ALLOWED_HOSTS=192.168.1.10:*,nas.lan:*``. + """ + hosts = ["localhost:*", "127.0.0.1:*", "[::1]:*"] + for item in os.environ.get("MCP_ALLOWED_HOSTS", "").split(","): + item = item.strip() + if item and item not in hosts: + hosts.append(item) + return hosts + + @asynccontextmanager async def app_lifespan(app): import sys @@ -162,7 +176,7 @@ mcp = FastMCP( json_response=True, transport_security=TransportSecuritySettings( enable_dns_rebinding_protection=True, - allowed_hosts=["192.168.1.2:*", "localhost:*", "127.0.0.1:*", "[::1]:*"], + allowed_hosts=_allowed_hosts(), ), ) diff --git a/stallari-plugin.yaml b/stallari-plugin.yaml index 1478399..266cae7 100644 --- a/stallari-plugin.yaml +++ b/stallari-plugin.yaml @@ -1,5 +1,5 @@ name: syncthing-blade-mcp -version: "0.10.0" +version: "0.10.1" description: "Syncthing replication management MCP — multi-instance, token-efficient output, safe disk-space reclamation" author: groupthink-dev license: MIT diff --git a/tests/test_tools_maintenance.py b/tests/test_tools_maintenance.py index a8529da..f129d18 100644 --- a/tests/test_tools_maintenance.py +++ b/tests/test_tools_maintenance.py @@ -214,3 +214,12 @@ class TestJsonSafeTruncate: data = json.loads(out) assert isinstance(data["items"], list) assert "truncated" in data + + +def test_allowed_hosts_from_env(monkeypatch): + from syncthing_mcp import server + + monkeypatch.delenv("MCP_ALLOWED_HOSTS", raising=False) + assert server._allowed_hosts() == ["localhost:*", "127.0.0.1:*", "[::1]:*"] + monkeypatch.setenv("MCP_ALLOWED_HOSTS", " 192.168.1.10:*, nas.lan:* ,,localhost:*") + assert server._allowed_hosts()[-2:] == ["192.168.1.10:*", "nas.lan:*"] diff --git a/uv.lock b/uv.lock index 3627aba..dc46e73 100644 --- a/uv.lock +++ b/uv.lock @@ -837,7 +837,7 @@ wheels = [ [[package]] name = "syncthing-blade-mcp" -version = "0.10.0" +version = "0.10.1" source = { editable = "." } dependencies = [ { name = "httpx" },