Skip to content

Commit ef03975

Browse files
authored
feat(glyph): Use MCPJungle as gateway (#305)
1 parent f2a9231 commit ef03975

7 files changed

Lines changed: 108 additions & 0 deletions

File tree

‎hosts/glyph/services/default.nix‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,6 @@
5959
enable = true;
6060
extraUpFlags = ["--ssh"];
6161
};
62+
63+
services.mcpjungle.enable = true;
6264
}

‎modules/home/development.nix‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ in {
5656
"Bash(git show *)"
5757
"Bash(git add *)"
5858
"Bash(git branch *)"
59+
"Bash(gh api:*)"
5960
"Bash(mkdir *)"
6061
"Bash(* --version)"
6162
"Bash(* --help *)"

‎modules/nixos/default.nix‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# NixOS-specific configuration modules
22
{
33
imports = [
4+
./llm
45
./web
56
./filebrowser-quantum.nix
67
./users.nix

‎modules/nixos/llm/default.nix‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
imports = [
3+
./mcpjungle.nix
4+
];
5+
}

‎modules/nixos/llm/mcpjungle.nix‎

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
config,
3+
pkgs,
4+
lib,
5+
...
6+
}: let
7+
cfg = config.services.mcpjungle;
8+
in {
9+
options.services.mcpjungle = {
10+
enable = lib.mkEnableOption "MCPJungle MCP Gateway";
11+
12+
package = lib.mkPackageOption pkgs "mcpjungle" {};
13+
14+
port = lib.mkOption {
15+
type = lib.types.port;
16+
default = 8090;
17+
description = "Port for the HTTP server to listen on.";
18+
};
19+
20+
openFirewall = lib.mkEnableOption "opening firewall ports for MCPJungle";
21+
};
22+
23+
config = lib.mkIf cfg.enable {
24+
users.users.mcpjungle = {
25+
isSystemUser = true;
26+
group = "mcpjungle";
27+
};
28+
users.groups.mcpjungle = {};
29+
30+
systemd.services.mcpjungle = {
31+
description = "MCPJungle MCP Gateway";
32+
after = ["network.target"];
33+
wantedBy = ["multi-user.target"];
34+
35+
serviceConfig = {
36+
ExecStart = "${lib.getExe cfg.package} start --port ${toString cfg.port}";
37+
User = "mcpjungle";
38+
Group = "mcpjungle";
39+
WorkingDirectory = "/var/lib/mcpjungle";
40+
StateDirectory = "mcpjungle";
41+
Restart = "on-failure";
42+
RestartSec = 5;
43+
44+
# Hardening
45+
NoNewPrivileges = true;
46+
PrivateDevices = true;
47+
PrivateTmp = true;
48+
ProtectHome = true;
49+
ProtectSystem = "strict";
50+
ReadWritePaths = ["/var/lib/mcpjungle"];
51+
ProtectKernelTunables = true;
52+
ProtectKernelModules = true;
53+
ProtectControlGroups = true;
54+
RestrictSUIDSGID = true;
55+
};
56+
};
57+
58+
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [cfg.port];
59+
};
60+
}

‎overlays/custom-packages.nix‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ self: super: {
1313
# FileBrowser quantum fork
1414
filebrowser-quantum = super.callPackage ./../packages/filebrowser-quantum/package.nix {};
1515

16+
# MCP Gateway
17+
mcpjungle = super.callPackage ./../packages/mcpjungle/package.nix {};
18+
1619
# Mochi spaced repetition software
1720
mochi = super.callPackage ./../packages/mochi/package.nix {};
1821

‎packages/mcpjungle/package.nix‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
lib,
3+
fetchFromGitHub,
4+
buildGoModule,
5+
}:
6+
buildGoModule rec {
7+
pname = "mcpjungle";
8+
version = "0.3.5";
9+
10+
src = fetchFromGitHub {
11+
owner = "mcpjungle";
12+
repo = "mcpjungle";
13+
rev = version;
14+
hash = "sha256-Q/ASyI6DygmYa284wk2pmYgVtPKRummnyh60v+Ri7bU=";
15+
};
16+
17+
vendorHash = "sha256-pvCDf7Y+LiIOiZ0O/bJMzkf75o7HQbYpF01yFY4J9Yg=";
18+
19+
# Tests require HOME to exist (tilde expansion); skip in sandbox
20+
doCheck = false;
21+
22+
env.CGO_ENABLED = 0;
23+
24+
ldflags = [
25+
"-s"
26+
"-w"
27+
"-X github.com/mcpjungle/mcpjungle/pkg/version.Version=${version}"
28+
];
29+
30+
meta = with lib; {
31+
description = "Self-hosted MCP Gateway";
32+
homepage = "https://github.com/mcpjungle/mcpjungle";
33+
license = licenses.mit;
34+
mainProgram = "mcpjungle";
35+
};
36+
}

0 commit comments

Comments
 (0)