diff --git a/home/common/programs/3d.nix b/home/common/programs/3d.nix index 40cef95..0012088 100644 --- a/home/common/programs/3d.nix +++ b/home/common/programs/3d.nix @@ -6,6 +6,8 @@ }: let cfg = config.custom.blender; + + blender-mcp = pkgs.callPackage ../../../pkgs/blender-mcp/package.nix { }; in { options.custom.blender = { @@ -28,6 +30,12 @@ in home.packages = [ (if cfg.cuda then pkgs.blender.override { cudaSupport = true; } else pkgs.blender) pkgs.prusa-slicer + + # Half of the Blender Lab MCP setup: the stdio server an LLM client + # launches. The other half is the "MCP" add-on, installed per host from + # Blender's extension repo (lab.blender.org) so it keeps its in-app + # update notifications — nothing works until it is enabled and started. + blender-mcp ]; fonts.fontconfig.enable = true; diff --git a/pkgs/blender-mcp/package.nix b/pkgs/blender-mcp/package.nix new file mode 100644 index 0000000..24eff55 --- /dev/null +++ b/pkgs/blender-mcp/package.nix @@ -0,0 +1,42 @@ +{ + lib, + python3Packages, + fetchgit, +}: + +python3Packages.buildPythonApplication rec { + pname = "blender-mcp"; + version = "1.0.2"; + pyproject = true; + + src = fetchgit { + url = "https://projects.blender.org/lab/blender_mcp.git"; + rev = "v${version}"; + hash = "sha256-PjZnKBSls6j6F4r3WK/doofdMDUZO3S573Y8SHCrDqg="; + }; + + # The repo holds the add-on, the chat client and the server; only mcp/ is a + # Python package. Gitea serves no usable release tarball (its archive + # endpoint 403s), hence fetchgit rather than fetchFromGitea. + sourceRoot = "${src.name}/mcp"; + + build-system = [ python3Packages.setuptools ]; + + # pyproject asks for mcp[cli], but nothing here imports mcp.cli — the extra + # would only add typer and python-dotenv. + dependencies = with python3Packages; [ + docutils + mcp + pyyaml + ]; + + pythonImportsCheck = [ "blmcp" ]; + + meta = { + description = "MCP server for Blender, talking to the Blender Lab add-on over TCP"; + homepage = "https://www.blender.org/lab/mcp-server/"; + license = lib.licenses.gpl3Plus; + platforms = lib.platforms.unix; + mainProgram = "blender-mcp"; + }; +}