mirror of
https://github.com/nix-community/home-manager.git
synced 2026-10-03 12:09:19 +00:00
Default args to an empty list on stdio servers as it's a Vec<String>, and loading the configuration fails if it's missing. This cannot be done in extraTransforms due to the final filterAttrs. Remove addType call as ContextServerSettings doesn't use type to differentiate server types. Link:601ecb3ee5/crates/settings_content/src/project.rs (L484)Link:601ecb3ee5/crates/project/src/project_settings.rs (L182)
93 lines
2.1 KiB
Nix
93 lines
2.1 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
{
|
|
programs.mcp = {
|
|
enable = true;
|
|
servers = {
|
|
everything = {
|
|
command = "npx";
|
|
args = [
|
|
"-y"
|
|
"@modelcontextprotocol/server-everything"
|
|
];
|
|
};
|
|
server-no-args = {
|
|
command = "echo";
|
|
};
|
|
context7 = {
|
|
url = "https://mcp.context7.com/mcp";
|
|
headers = {
|
|
CONTEXT7_API_KEY = "{env:CONTEXT7_API_KEY}";
|
|
};
|
|
};
|
|
disabled-server = {
|
|
command = "echo";
|
|
args = [ "test" ];
|
|
disabled = true;
|
|
};
|
|
};
|
|
};
|
|
|
|
programs.zed-editor = {
|
|
enable = true;
|
|
package = config.lib.test.mkStubPackage { };
|
|
enableMcpIntegration = true;
|
|
};
|
|
|
|
home.homeDirectory = lib.mkForce "/@TMPDIR@/hm-user";
|
|
|
|
nmt.script =
|
|
let
|
|
expectedContent = builtins.toFile "expected.json" ''
|
|
{
|
|
"context_servers": {
|
|
"context7": {
|
|
"headers": {
|
|
"CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}"
|
|
},
|
|
"url": "https://mcp.context7.com/mcp"
|
|
},
|
|
"disabled-server": {
|
|
"args": [
|
|
"test"
|
|
],
|
|
"command": "echo",
|
|
"enabled": false
|
|
},
|
|
"everything": {
|
|
"args": [
|
|
"-y",
|
|
"@modelcontextprotocol/server-everything"
|
|
],
|
|
"command": "npx"
|
|
},
|
|
"server-no-args": {
|
|
"args": [],
|
|
"command": "echo"
|
|
}
|
|
}
|
|
}
|
|
'';
|
|
|
|
settingsPath = ".config/zed/settings.json";
|
|
activationScript = pkgs.writeScript "activation" config.home.activation.zedSettingsActivation.data;
|
|
in
|
|
''
|
|
export HOME=$TMPDIR/hm-user
|
|
|
|
# Run the activation script
|
|
substitute ${activationScript} $TMPDIR/activate --subst-var TMPDIR
|
|
chmod +x $TMPDIR/activate
|
|
$TMPDIR/activate
|
|
|
|
# Validate the settings file exists and contains MCP servers
|
|
assertFileExists "$HOME/${settingsPath}"
|
|
assertFileContent "$HOME/${settingsPath}" "${expectedContent}"
|
|
'';
|
|
}
|