Nixpkgs MCP服务器
动态MCP服务器,将所有80000多个nixpkgs包作为工具公开给AI代理。
特性
- 🚀 动态工具生成:按需访问任何nixpkgs软件包
- ⚡ 延迟加载:通过增量工具注册快速启动
- 🔍 智能搜索:按名称或描述查找包
- 💾 智能缓存:预先注册常用工具,根据需要加载其他工具
- 🛠️ 三级制:
- 元工具(搜索、执行、安装) - 预先注册的常用工具(ripgrep、jq、fd等) - 按需动态工具(8万多个软件包)
快速开始
单线安装
# Run from GitHub (once published)
nix run github:yourusername/nixpkgs-mcp
# Or run from local clone
nix run /path/to/nixpkgs-mcp添加到MCP配置
添加到 ~/.mcp.json 或者你的项目 .mcp.json:
{
"mcpServers": {
"nixpkgs": {
"command": "nix",
"args": ["run", "github:yourusername/nixpkgs-mcp"],
"env": {}
}
}
}或者为了当地发展:
{
"mcpServers": {
"nixpkgs": {
"command": "nix",
"args": ["run", "/path/to/nixpkgs-mcp"],
"env": {}
}
}
}重新启动MCP客户端并开始使用nixpkgs工具!
使用示例
搜索包裹
Agent: Use nixpkgs_search to find JSON processing tools执行一次包
Agent: Use nixpkgs_execute to run jq with args [".name", "-"]永久安装工具
Agent: Use nixpkgs_install_tool to register nushell现在 nixpkgs_nushell 可作为直接工具使用!
使用预先注册的工具
Agent: Use nixpkgs_ripgrep with args ["--json", "TODO", "."]建筑
┌─────────────────────────────────────────────┐
│ MCP Client (Claude, etc) │
└──────────────────┬──────────────────────────┘
│
┌──────────────────▼──────────────────────────┐
│ Nixpkgs MCP Server │
│ ┌────────────┐ ┌────────────┐ ┌──────────┐│
│ │Meta Tools │ │Common Tools│ │ Dynamic ││
│ │• search │ │• ripgrep │ │• 80k pkg ││
│ │• execute │ │• jq │ │• cached ││
│ │• install │ │• fd │ │• on-dem ││
│ └────────────┘ └────────────┘ └──────────┘│
└──────────────────┬──────────────────────────┘
│
┌──────────────────▼──────────────────────────┐
│ nix run nixpkgs#
-- │
└─────────────────────────────────────────────┘可用元工具
| 工具 | 说明 |
|---|---|
nixpkgs_search | 按名称或描述搜索包 |
nixpkgs_execute | 无需注册即可运行任何程序包 |
nixpkgs_install_tool | 将包永久注册为工具 |
nixpkgs_list_installed | 显示所有已注册的工具 |
预先注册的常用工具
- 搜索:ripgrep、fd、fzf
- 数据:jq、nushell
- 文件一,不,树
- 网络:卷曲,wget
- 系统:htop、git
演出
- 初创公司:~2s(加载80k包元数据)
- 搜索:~50ms(内存查找)
- 执行:~1-3s(nix运行冷启动)+工具运行时间
- 缓存:注册工具次秒
缓存策略
- 元数据缓存:
~/.cache/nixpkgs-mcp/nixpkgs.json(每日刷新) - 工具注册表:已安装工具的内存集
- 通用工具:启动时预装
发展
# Enter dev environment
nix develop
# Run server
python server.py
# Test with MCP inspector
npx @modelcontextprotocol/inspector python server.py路线图
- \[\]持久工具注册表(将已安装的工具保存到磁盘)
- \[\]包元数据丰富(维护者、平台等)
- \[\]基于上下文的智能工具建议
- \[\]批量工具注册
- \[\]性能优化(Go/Rust重写)
- \[\]与mcp-nixos集成以获取nixos特定信息
- \[\]支持
nix shell环境 - \[\]工具使用分析
相关项目
许可证
无许可-公共领域
