{ lib, stdenv, fetchFromGitHub, makeWrapper, python3, }: let python = python3.withPackages ( ps: with ps; [ fastapi fastmcp httpx python-dotenv ] ); in stdenv.mkDerivation { pname = "sabnzbd-mcp"; version = "0.1.0-unstable"; src = fetchFromGitHub { owner = "jmagar"; repo = "sabnzbd-mcp"; rev = "refs/heads/main"; hash = "sha256-1sEnHH40cDVT5oiZD2Xywl7S9vJThii/ce+6r+XmpSw="; }; nativeBuildInputs = [ makeWrapper ]; postPatch = '' # The upstream client hardcodes /sabnzbd/api as the API path. # Change to just /api so SABNZBD_URL can optionally include the path prefix # (e.g. http://host:9092/sabnzbd or just http://host:9092). substituteInPlace client.py \ --replace-fail '"{self.base_url}/sabnzbd/api"' '"{self.base_url}/api"' ''; installPhase = '' mkdir -p $out/lib/sabnzbd-mcp cp sabnzbd-mcp-server.py client.py $out/lib/sabnzbd-mcp/ makeWrapper ${python}/bin/python $out/bin/sabnzbd-mcp \ --add-flags "$out/lib/sabnzbd-mcp/sabnzbd-mcp-server.py" \ --set-default SABNZBD_MCP_TRANSPORT stdio ''; meta = with lib; { description = "MCP server for SABnzbd Usenet client"; homepage = "https://github.com/jmagar/sabnzbd-mcp"; license = licenses.mit; mainProgram = "sabnzbd-mcp"; platforms = platforms.all; }; }