1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00

vscode: add mcp module integration

This commit is contained in:
Thierry Delafontaine 2025-10-27 12:15:04 +01:00 committed by Austin Horstman
parent c740351870
commit 9ff9a94fd4
7 changed files with 278 additions and 4 deletions

View file

@ -24,6 +24,8 @@ let
keybindings = import ./keybindings.nix;
tasks = import ./tasks.nix;
mcp = import ./mcp.nix;
mcp-integration = import ./mcp-integration.nix;
mcp-integration-with-override = import ./mcp-integration-with-override.nix;
update-checks = import ./update-checks.nix;
snippets = import ./snippets.nix;
};

View file

@ -0,0 +1,26 @@
{
"servers": {
"context7": {
"enabled": true,
"headers": {
"CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}"
},
"type": "http",
"url": "https://mcp.context7.com/mcp"
},
"disabled-server": {
"command": "echo",
"enabled": false,
"type": "stdio"
},
"everything": {
"args": [
"-y",
"@modelcontextprotocol/server-everything"
],
"command": "npx",
"enabled": true,
"type": "stdio"
}
}
}

View file

@ -0,0 +1,7 @@
{
"servers": {
"Github": {
"url": "https://api.githubcopilot.com/mcp/"
}
}
}

View file

@ -0,0 +1,25 @@
{
"servers": {
"CustomServer": {
"type": "http",
"url": "https://example.com/mcp"
},
"context7": {
"enabled": true,
"headers": {
"CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}"
},
"type": "http",
"url": "https://mcp.context7.com/mcp"
},
"everything": {
"args": [
"-y",
"@modelcontextprotocol/server-everything"
],
"command": "custom-npx",
"enabled": false,
"type": "stdio"
}
}
}

View file

@ -0,0 +1,79 @@
package:
{
config,
pkgs,
lib,
...
}:
let
cfg = config.programs.vscode;
willUseIfd = package.pname != "vscode";
mcpFilePath =
name:
if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support/${cfg.nameShort}/User/${
lib.optionalString (name != "default") "profiles/${name}/"
}mcp.json"
else
".config/${cfg.nameShort}/User/${
lib.optionalString (name != "default") "profiles/${name}/"
}mcp.json";
in
lib.mkIf (willUseIfd -> config.test.enableLegacyIfd) {
programs.mcp = {
enable = true;
servers = {
everything = {
command = "npx";
args = [
"-y"
"@modelcontextprotocol/server-everything"
];
};
context7 = {
url = "https://mcp.context7.com/mcp";
headers = {
CONTEXT7_API_KEY = "{env:CONTEXT7_API_KEY}";
};
};
};
};
programs.vscode = {
enable = true;
inherit package;
profiles = {
default = {
enableMcpIntegration = true;
# User MCP settings should override generated ones
userMcp = {
servers = {
everything = {
command = "custom-npx";
args = [
"-y"
"@modelcontextprotocol/server-everything"
];
enabled = false;
type = "stdio";
};
CustomServer = {
type = "http";
url = "https://example.com/mcp";
};
};
};
};
};
};
nmt.script = ''
assertFileExists "home-files/${mcpFilePath "default"}"
assertFileContent "home-files/${mcpFilePath "default"}" ${./mcp-integration-with-override.json}
'';
}

View file

@ -0,0 +1,73 @@
package:
{
config,
pkgs,
lib,
...
}:
let
cfg = config.programs.vscode;
willUseIfd = package.pname != "vscode";
mcpFilePath =
name:
if pkgs.stdenv.hostPlatform.isDarwin then
"Library/Application Support/${cfg.nameShort}/User/${
lib.optionalString (name != "default") "profiles/${name}/"
}mcp.json"
else
".config/${cfg.nameShort}/User/${
lib.optionalString (name != "default") "profiles/${name}/"
}mcp.json";
in
lib.mkIf (willUseIfd -> config.test.enableLegacyIfd) {
programs.mcp = {
enable = true;
servers = {
everything = {
command = "npx";
args = [
"-y"
"@modelcontextprotocol/server-everything"
];
};
context7 = {
url = "https://mcp.context7.com/mcp";
headers = {
CONTEXT7_API_KEY = "{env:CONTEXT7_API_KEY}";
};
};
disabled-server = {
command = "echo";
disabled = true;
};
};
};
programs.vscode = {
enable = true;
inherit package;
profiles = {
default.enableMcpIntegration = true;
test.userMcp = {
servers = {
Github = {
url = "https://api.githubcopilot.com/mcp/";
};
};
};
};
};
nmt.script = ''
assertFileExists "home-files/${mcpFilePath "default"}"
assertFileContent "home-files/${mcpFilePath "default"}" ${./mcp-integration-default.json}
assertFileExists "home-files/${mcpFilePath "test"}"
assertFileContent "home-files/${mcpFilePath "test"}" ${./mcp-integration-test.json}
'';
}