-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtools.nix
More file actions
149 lines (124 loc) · 3.55 KB
/
Copy pathtools.nix
File metadata and controls
149 lines (124 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
{
pkgs,
lib,
inputs,
extraTools ? { },
}:
let
wrapWithCredentialFiles = pkgs.callPackage ./nix/lib/wrapWithCredentialFiles.nix { };
mkTool =
{ package, binary }:
{
inherit package binary;
path = "${lib.getBin package}/bin/${binary}";
};
toolsFunctions = {
# Helper to map credential environment variables to files containing credentials
inherit wrapWithCredentialFiles;
# Helper for creating new tool entries (exposed for extension)
inherit mkTool;
# Function to get a tool by name, with error checking
getTool =
name:
let
tool = builtins.getAttr name tools;
in
if tool.package == null then
throw "Tool ${name} is not available in your mcp tools configuration"
else
tool.package;
# Function to get a tool's command path
getToolPath =
name:
let
tool = builtins.getAttr name tools;
in
if tool.package == null then
throw "Tool ${name} is not available in your mcp tools configuration"
else
tool.path;
# Function to create a new tools set with additional tools
extend =
newExtraTools:
import ./tools.nix {
inherit pkgs lib inputs;
extraTools = extraTools // newExtraTools;
};
};
baseTools = {
asana = mkTool {
# Override vanilla mpc-server-asana with script that allow us to read credentials from
# a file and populate it on the ASANA_ACCESS_TOKEN.
package = wrapWithCredentialFiles {
package = pkgs.mcp-server-asana;
credentialEnvs = [ "ASANA_ACCESS_TOKEN" ];
};
binary = "mcp-server-asana";
};
github = mkTool {
# Override vanilla github-mpc-server with script that allow us to read credentials
# from a file and populate it on the GITHUB_PERSONAL_ACCESS_TOKEN.
package = wrapWithCredentialFiles {
package = pkgs.github-mcp-server;
credentialEnvs = [ "GITHUB_PERSONAL_ACCESS_TOKEN" ];
};
binary = "github-mcp-server";
};
grafana = mkTool {
package = wrapWithCredentialFiles {
package = pkgs.mcp-grafana;
credentialEnvs = [ "GRAFANA_API_KEY" ];
};
binary = "mcp-grafana";
};
filesystem = mkTool {
package = pkgs.mcp-servers;
binary = "mcp-server-filesystem";
};
git = mkTool {
package = pkgs.mcp-servers;
binary = "mcp-server-git";
};
fetch = mkTool {
package = pkgs.mcp-servers;
binary = "mcp-server-fetch";
};
sequential-thinking = mkTool {
package = pkgs.mcp-servers;
binary = "mcp-server-sequentialthinking";
};
time = mkTool {
package = pkgs.mcp-servers;
binary = "mcp-server-time";
};
buildkite = mkTool {
package = wrapWithCredentialFiles {
package = pkgs.buildkite-mcp-server;
credentialEnvs = [ "BUILDKITE_API_TOKEN" ];
};
binary = "buildkite-mcp-server";
};
lsp = mkTool {
package = pkgs.mcp-language-server;
binary = "mcp-language-server";
};
obsidian = mkTool {
package = wrapWithCredentialFiles {
package = pkgs.mcp-obsidian;
credentialEnvs = [ "OBSIDIAN_API_KEY" ];
};
binary = "mcp-obsidian";
};
ast-grep = mkTool {
package = pkgs.ast-grep-mcp;
binary = "ast-grep-server";
};
nixos = mkTool {
package = inputs.mcp-nixos.packages.${pkgs.system}.default;
binary = "mcp-nixos";
};
};
# Combined tools (base + extra)
tools = baseTools // extraTools;
in
tools // toolsFunctions