- Add flake structure with overlay and packages exports - Add manim-mcp-server as first packaged MCP server - Add README.org with usage instructions and package templates - Add packages/default.nix as package aggregator - Add overlays/default.nix for nixpkgs integration
6.3 KiB
6.3 KiB
MCP Server Packages for Nix
Overview
This repository provides Nix derivations for MCP (Model Context Protocol) servers that are not yet available in nixpkgs.
Available Packages
| Package | Description | Language |
|---|---|---|
| manim-mcp-server | Execute Manim animation code and return videos | Python |
Usage
Using the Overlay (Recommended)
Add this flake to your inputs and apply the overlay:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
mcp.url = "github:YOUR-USERNAME/mcp"; # Update with your repo
};
outputs = { nixpkgs, mcp, ... }: {
# Apply the overlay to get packages in pkgs
nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
{
nixpkgs.overlays = [ mcp.overlays.default ];
}
# Now you can use pkgs.manim-mcp-server
];
};
};
}
Using Packages Directly
Access packages without the overlay:
{
inputs.mcp.url = "github:YOUR-USERNAME/mcp";
outputs = { mcp, ... }: {
# Access directly
myPackage = mcp.packages.x86_64-linux.manim-mcp-server;
};
}
In a Development Shell
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
mcp.url = "github:YOUR-USERNAME/mcp";
};
outputs = { nixpkgs, mcp, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
overlays = [ mcp.overlays.default ];
};
in {
devShells.${system}.default = pkgs.mkShell {
packages = [
pkgs.manim-mcp-server
];
};
};
}
Adding New Packages
Directory Structure
packages/
├── default.nix # Package aggregator
└── <package-name>/
└── package.nix # Package derivation
Step-by-Step Guide
-
Create the package directory
mkdir -p packages/<package-name> -
Create
package.nixusing the appropriate builder for the language:- Python (with pyproject.toml):
python3Packages.buildPythonApplication - Python (script only): wrapper approach with
stdenv.mkDerivation - Go:
buildGoModule - Node.js:
buildNpmPackage - Rust:
rustPlatform.buildRustPackage
- Python (with pyproject.toml):
-
Register in
packages/default.nix{ pkgs }: { manim-mcp-server = pkgs.callPackage ./manim-mcp-server/package.nix { }; # Add your new package here: new-mcp-server = pkgs.callPackage ./new-mcp-server/package.nix { }; } -
Build and test
nix build .#<package-name> ./result/bin/<package-name>
Package Templates
Python (with pyproject.toml)
{ lib, python3Packages, fetchFromGitHub }:
python3Packages.buildPythonApplication rec {
pname = "example-mcp-server";
version = "1.0.0";
pyproject = true;
src = fetchFromGitHub {
owner = "owner";
repo = "repo";
rev = "v${version}";
hash = "sha256-AAAA..."; # Use lib.fakeHash first, then update
};
build-system = [ python3Packages.hatchling ];
dependencies = with python3Packages; [
mcp
fastmcp
];
meta = with lib; {
description = "Description of the MCP server";
homepage = "https://github.com/owner/repo";
license = licenses.mit;
mainProgram = "example-mcp-server";
};
}
Python (script only, like manim-mcp-server)
{ lib, stdenv, fetchFromGitHub, makeWrapper, python3 }:
let
python = python3.withPackages (ps: with ps; [
mcp
fastmcp
# other dependencies
]);
in
stdenv.mkDerivation rec {
pname = "example-mcp-server";
version = "0.0.1-unstable";
src = fetchFromGitHub {
owner = "owner";
repo = "repo";
rev = "commit-hash";
hash = "sha256-AAAA...";
};
nativeBuildInputs = [ makeWrapper ];
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out/bin $out/lib/${pname}
cp src/server.py $out/lib/${pname}/
makeWrapper ${python}/bin/python $out/bin/${pname} \
--add-flags "$out/lib/${pname}/server.py"
runHook postInstall
'';
meta = with lib; {
description = "Description";
homepage = "https://github.com/owner/repo";
license = licenses.mit;
mainProgram = pname;
};
}
Go
{ lib, buildGoModule, fetchFromGitHub }:
buildGoModule rec {
pname = "example-mcp-server";
version = "1.0.0";
src = fetchFromGitHub {
owner = "owner";
repo = "repo";
rev = "v${version}";
hash = "sha256-AAAA...";
};
vendorHash = "sha256-BBBB..."; # Use lib.fakeHash first
ldflags = [
"-s" "-w"
"-X main.version=${version}"
];
meta = with lib; {
description = "Description";
homepage = "https://github.com/owner/repo";
license = licenses.mit;
mainProgram = pname;
};
}
Node.js
{ lib, buildNpmPackage, fetchFromGitHub }:
buildNpmPackage rec {
pname = "example-mcp-server";
version = "1.0.0";
src = fetchFromGitHub {
owner = "owner";
repo = "repo";
rev = "v${version}";
hash = "sha256-AAAA...";
};
npmDepsHash = "sha256-BBBB..."; # Use lib.fakeHash first
dontNpmBuild = true; # If pre-built or no build step needed
meta = with lib; {
description = "Description";
homepage = "https://github.com/owner/repo";
license = licenses.mit;
mainProgram = pname;
};
}
Calculating Hashes
When adding a new package, use lib.fakeHash initially:
hash = lib.fakeHash;
Then run nix build and copy the correct hash from the error message.
Development
Enter Development Shell
nix develop
Build a Specific Package
nix build .#manim-mcp-server
Build All Packages
nix build .#default
List Available Packages
nix flake show
License
Each packaged MCP server retains its original license. The Nix expressions in this repository are provided as-is.