Model Context Protocol server for NixOS resources
Project description
NixMCP - Model Context Protocol for NixOS Resources
⚠️ UNDER ACTIVE DEVELOPMENT: NixMCP is being actively maintained and improved. I'm just a fool fumbling through the codebase like a raccoon in a dumpster, but having fun along the way!
NixMCP is a Model Context Protocol (MCP) server that exposes NixOS packages and options to AI models. It provides AI models with up-to-date information about NixOS resources, reducing hallucinations and outdated information.
Using the FastMCP framework, the server provides MCP endpoints for accessing the NixOS Elasticsearch API to deliver accurate information about packages and options.
Features
- MCP server implementation for NixOS resources
- Access to NixOS packages and options through a standardized MCP interface
- Get detailed package and option metadata using direct Elasticsearch API access
- Connect seamlessly with Claude and other MCP-compatible AI models
- Rich search capabilities with automatic wildcard matching
- JSON-based responses for easy integration with MCP clients
MCP Implementation
The server implements both MCP resources and tools for accessing NixOS information:
MCP Resources
nixos://status- Get server status informationnixos://package/{package_name}- Get information about a specific packagenixos://search/packages/{query}- Search for packages matching the querynixos://search/options/{query}- Search for options matching the querynixos://option/{option_name}- Get information about a specific NixOS optionnixos://search/programs/{program}- Search for packages that provide specific programsnixos://packages/stats- Get statistics about NixOS packages
MCP Tools
nixos_search- Search for packages, options, or programs with automatic wildcard handlingnixos_info- Get detailed information about a specific package or optionnixos_stats- Get statistical information about NixOS packages
Tool Usage Examples
# Search for packages
nixos_search(query="firefox", type="packages", limit=10, channel="unstable")
# Search for system options
nixos_search(query="postgresql", type="options", channel="24.11")
# Search for programs
nixos_search(query="python", type="programs")
# Get package details
nixos_info(name="nixos.firefox", type="package", channel="unstable")
# Get option details
nixos_info(name="services.postgresql.enable", type="option", channel="24.11")
# Get package statistics
nixos_stats()
Quick Start
Using Nix Develop (Recommended)
# Enter the development shell
nix develop
# List all available commands
menu
# Run the server
run
# Run tests
run-tests
# Format code
lint
Prerequisites
The server requires access to the NixOS Elasticsearch API. By default, the credentials are hardcoded in the server.py file for simplicity, but you can override them with environment variables:
For custom credentials, create a .env file in the project root with:
ELASTICSEARCH_URL=https://search.nixos.org/backend/latest-42-nixos-unstable/_search
ELASTICSEARCH_USER=your_username
ELASTICSEARCH_PASSWORD=your_password
Testing Approach
The tests use real Elasticsearch API calls instead of mocks to ensure actual API compatibility. This approach:
- Tests actual API behavior rather than simplified mocks
- Validates error handling with real-world responses
- Detects changes in the API endpoints or structure
- Remains resilient to API changes by testing response structure
The project provides Nix-based development commands:
# Enter the development environment
nix develop
# Run tests with coverage report (default)
run-tests
# Run tests without coverage
run-tests --no-coverage
# Lint and format code
lint
# Format code only
format
# Show all available commands
menu
Current code coverage is tracked on Codecov.
Using with Claude
Once the server is running, you can use it with Claude by referencing NixOS resources in your prompts:
Please provide information about the Python package in NixOS.
~nixos://package/python
What configuration options are available for NGINX in NixOS?
~nixos://option/services.nginx
How do I set up PostgreSQL in NixOS?
~nixos://search/options/postgresql
Claude will automatically fetch the requested information through the MCP server.
What is Model Context Protocol?
The Model Context Protocol (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. MCP uses a JSON-based message format exchanged over various transport mechanisms (typically standard input/output streams).
This project implements the MCP specification using the FastMCP library, providing a bridge between AI models and NixOS resources.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nixmcp-0.1.0.tar.gz.
File metadata
- Download URL: nixmcp-0.1.0.tar.gz
- Upload date:
- Size: 129.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4649d75c5d04b69a0f8d568208dc96d28a2c266edb66f885b32527714f03c070
|
|
| MD5 |
2142ec911ccbac1c025324b0ec3419e8
|
|
| BLAKE2b-256 |
e4d67642d86b008317ffcf30cef4ba6197d12393c051fcdfc9b426327bbb5c94
|
File details
Details for the file nixmcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nixmcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4aac535d343686960dcfc94fd328242f5507fef3d2e4438def09df592f395d0c
|
|
| MD5 |
f38a8f7a12f474eee679dd620fd18377
|
|
| BLAKE2b-256 |
cbb64df9fbb3ba16642d2659796c7d1e29d00055dcc0831b81852327f5026e43
|