mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
mcp: init module
This commit is contained in:
parent
1f34c2c855
commit
083b20c1a0
5 changed files with 119 additions and 0 deletions
64
modules/programs/mcp.nix
Normal file
64
modules/programs/mcp.nix
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
literalExpression
|
||||
mkEnableOption
|
||||
mkIf
|
||||
mkOption
|
||||
;
|
||||
|
||||
cfg = config.programs.mcp;
|
||||
|
||||
jsonFormat = pkgs.formats.json { };
|
||||
in
|
||||
{
|
||||
meta.maintainers = with lib.maintainers; [ delafthi ];
|
||||
|
||||
options.programs.mcp = {
|
||||
enable = mkEnableOption "mcp";
|
||||
|
||||
servers = mkOption {
|
||||
inherit (jsonFormat) type;
|
||||
default = { };
|
||||
example = literalExpression ''
|
||||
{
|
||||
everything = {
|
||||
command = "npx";
|
||||
args = [
|
||||
"-y"
|
||||
"@modelcontextprotocol/server-everything"
|
||||
];
|
||||
};
|
||||
context7 = {
|
||||
url = "https://mcp.context7.com/mcp";
|
||||
headers = {
|
||||
CONTEXT7_API_KEY = "{env:CONTEXT7_API_KEY}";
|
||||
};
|
||||
};
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
MCP server configurations written to
|
||||
{file}`XDG_CONFIG_HOME/.config/mcp/mcp.json`
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
xdg.configFile = mkIf (cfg.servers != { }) (
|
||||
let
|
||||
mcp-config = {
|
||||
mcpServers = cfg.servers;
|
||||
};
|
||||
in
|
||||
{
|
||||
"mcp/mcp.json".source = jsonFormat.generate "mcp.json" mcp-config;
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue