Files
home-manager/tests/modules/programs/zed-editor/mcp-integration.nix
Edontin 5b6f573372 zed-editor: fix programs.mcp.servers compatibility
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)
2026-06-13 10:42:15 -05:00

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}"
'';
}