mcpix:模型上下文协议服务器和.md文件的Nix配置
Home manager和薄片零件模块,用于通用配置AI集成编辑器
______________________________________________________________________
您可能想使用mcpix的原因
- 你是一个使用不同编辑器的开发团队的一员,
但希望使用相同的工具。
- 您自己使用多个编辑器,不想重复AI配置。
- 您厌倦了将.md文件符号链接。
- 你喜欢nix,并希望尽可能多地使用它进行配置。
- 您使用的是NixOS,不想手动打包MCP服务器(使用
mcp-servers-nix). - 支持的编辑器:gemini-cli、claude代码、opencode、zed、游标。
如何使用mcpix
- 家庭经理
如果你想在用户级别配置自己的编辑器, 您可以使用家庭管理器模块。 由于一些编辑器主管理器程序仅处于不稳定状态, 你也必须使用unstable或使用覆盖层。 Zed和游标当前不支持用户级.md文件。
将mcpix添加到薄片输入中,如下所示:
# flake.nix
{
inputs = {
nixpkgs = {
url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
mcpix = {
url = "github:PieterPel/mcpix/main";
inputs.nixpkgs.follows = "nixpkgs";
};
};
}
现在,在家庭管理器模块的某个地方,例如。 home.nix:
{
mcpix, # Or use `inputs`, you know how this works
...
}
:
{
imports = [
mcpix.homeManagerModules.mcpix
];
programs = {
mcpix = {
enable = true;
# Configure rules for all your editors
rules = "I can be a very long .md file here";
# Configure mcp servers for all your editors
servers = {
programs.git.enable = true;
};
# And configuration per target
targets.gemini-cli = {
rules = "Never mention google in your output";
servers = {
programs.filesystem.enable = true;
};
};
};
# You still need to enable the programs for your editors
# (Except for cursor as it does not have a home-manager module)
gemini-cli.enable = true;
};
}
注意:有关服务器配置的详细文档, 我建议你去上游 mcp服务器nix 回购。 您可以创建自定义服务器并使用预定义的服务器。
- 片状零件
如果要为项目配置编辑器, 您可以将flake部分模块用于您的dev-flack。
# flake.nix
{
inputs = {
nixpkgs = {
url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
mcpix = {
url = "github:PieterPel/mcpix/main";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
};
};
outputs = {
inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.mcpix.flakeModules.mcpix
];
systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
"x86_64-darwin"
];
perSystem =
{
pkgs,
config,
...
}:
{
mcpix.settings = {
# Here are the global MCP servers
servers = {
programs = {
git.enable = true;
};
};
targets = {
gemini-cli.enable = true;
zed = {
enable = true;
# You also have per client server cofiguration here
servers = {
programs.filesystem.enable = true;
}
extraSettings = {
# Here you can pass extra JSON settings
};
};
opencode.enable = true;
cursor.enable = false;
claude-code.enable = true;
};
# But rules are only global
rules = ''
You are an expert on nix programming.
'';
};
# This devshell automatically symlinks the configuration files
# to the correct place
devShells.mcpix = config.mcpix.devShell;
devShells.default = config.mcpix.devShell
};
}
贡献
非常欢迎捐款!
- 想要新功能吗?打开一个问题
- 发现bug了吗?打开一个问题
- 想修点东西吗?打开问题和/或打开拉取请求
更多信息可以在CONTRIBUTING.md中找到
许可证
请参阅许可文件(BSD-3条款)
______________________________________________________________________
