nix-devshell-mcp
Provides an Angular frontend profile that generates a Nix flake devshell with Angular 17+, Angular CLI, standalone components, a hot-reload development server, and testing setup.
Generated TypeScript/Node.js devshells include ESLint for linting.
Provides a Python FastAPI profile that generates a Nix flake devshell with FastAPI, Uvicorn, Pydantic, pytest/httpx testing, linting and type-checking, and virtual environment auto-activation.
Supports automatic Git repository initialization when creating a project.
Provides Node.js profiles that generate Nix devshells with configurable Node.js versions and related project tooling.
Supports npm as a selectable package manager and can configure private npm registry settings in generated Node.js devshells.
Supports pnpm as a selectable package manager in generated TypeScript/Node.js devshells.
Generated TypeScript/Node.js devshells include Prettier for code formatting.
Generated Python/FastAPI devshells include Pydantic for data validation.
Supports private PyPI index configuration in generated Python devshells.
Generated Python/FastAPI devshells include pytest and httpx for testing.
Provides Python development profiles that generate Nix devshells with configurable Python versions and Python tooling for FastAPI projects.
Provides a Java Spring Boot profile that generates a Nix devshell with a configurable JDK, Spring Boot 3.2, Maven, REST controller scaffolding, and Spring Boot DevTools.
Provides a TypeScript + Node.js profile that generates a Nix devshell with TypeScript 5.x, strict type checking, tsx, starter source/config files, and associated tooling.
Generated TypeScript/Node.js devshells include Vitest for testing.
Supports Yarn as a selectable package manager in generated Node.js/TypeScript devshells.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@nix-devshell-mcp Create a TypeScript Node.js 20 devshell in ~/projects/my-api with direnv"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
nix-devshell-mcp
Model Context Protocol (MCP) Server for Generating Nix Flake Development Environments
This MCP server enables AI assistants to generate fully-configured Nix flake development environments from conversational prompts. It provides a bridge between natural language descriptions of development needs and production-ready Nix devshell configurations.
Features
⨠Conversational Development Environment Creation
Generate complete Nix flake projects from natural language
4 production-ready profile templates
Automatic direnv configuration
Git repository initialization
š”ļø Non-Destructive & Safe
Never overwrites existing files
Path traversal protection
Atomic file writes
Comprehensive validation
š§ Enterprise-Ready
Private npm registry support
Private PyPI index configuration
Maven repository configuration
Two-level configuration system (user + project)
šØ Highly Customizable
Handlebars templating with 11 custom helpers
JSON schema validation
Environment variable resolution
Post-creation hooks
Related MCP server: mcp-nix
Quick Start
Installation
# Clone the repository
git clone https://github.com/kcalvelli/nix-devshell-mcp.git
cd nix-devshell-mcp
# Install dependencies
npm install
# Build the project
npm run buildConfiguration
Add to your Claude Desktop config (~/.config/Claude/claude_desktop_config.json):
{
"mcpServers": {
"nix-devshell": {
"command": "node",
"args": ["/path/to/nix-devshell-mcp/build/index.js"]
}
}
}Usage Example
Once configured, you can ask Claude:
"Create a TypeScript Node.js project with Node 20 in /home/user/my-app"Claude will use the create_devshell tool to generate:
flake.nix- Nix flake with Node.js 20, TypeScript, development tools.envrc- direnv configuration for automatic activationpackage.json- Node.js package configuration with scriptstsconfig.json- TypeScript compiler configurationsrc/index.ts- Starter TypeScript codeREADME.md- Project documentation
Then simply:
cd /home/user/my-app
direnv allow
npm install
npm run devAvailable Profiles
typescript-node
Modern TypeScript + Node.js development with ES modules and strict type checking.
Includes:
Node.js (configurable version, default 20)
TypeScript 5.x with strict mode
tsx for development, vitest for testing
ESLint, Prettier
Package manager choice (npm/yarn/pnpm)
Use cases: REST APIs, CLI tools, backend services, GraphQL servers
python-fastapi
Python FastAPI development with async support and automatic OpenAPI documentation.
Includes:
Python (configurable version, default 3.11)
FastAPI, Uvicorn, Pydantic
pytest, httpx for testing
Black, Flake8, mypy
Virtual environment auto-activation
Use cases: REST APIs, microservices, async web applications
angular-frontend
Angular 17+ frontend development with standalone components.
Includes:
Node.js 20
Angular CLI 17+
TypeScript, standalone components
Development server with hot reload
Testing framework setup
Use cases: Single-page applications, progressive web apps, enterprise frontends
java-spring-boot
Enterprise Java development with Spring Boot 3.x and Maven.
Includes:
JDK (configurable version, default 17)
Spring Boot 3.2.0
Maven build tool
REST controller scaffolding
Spring Boot DevTools
Use cases: Enterprise backends, microservices, RESTful APIs, web applications
Configuration
User Configuration
Create ~/.config/nix-devshell-mcp/config.json:
{
"author": "Your Name",
"email": "your.email@example.com",
"gitAutoInit": true,
"defaults": {
"nodeVersion": "20",
"pythonVersion": "311",
"javaVersion": "17"
},
"privateRegistry": {
"npm": {
"registry": "https://registry.company.com",
"authToken": "${NPM_TOKEN}"
}
}
}Project Configuration
Create devshell-config.json in your project:
{
"projectName": "my-awesome-project",
"description": "An awesome project",
"nodeVersion": "20",
"author": "Team Name"
}Configuration Priority
Tool options > Project config > User config > Profile defaults
Environment Variables
Use ${VAR_NAME} syntax in configs to reference environment variables:
{
"npmRegistry": "${PRIVATE_NPM_REGISTRY}",
"authToken": "${NPM_TOKEN}"
}MCP Tools
create_devshell
Creates a development environment from a profile template.
Parameters:
projectPath(required): Absolute path to project directoryprofile(required): Profile name (typescript-node, python-fastapi, angular-frontend, java-spring-boot)options(optional): Configuration overrides
Example:
{
"projectPath": "/home/user/my-project",
"profile": "typescript-node",
"options": {
"nodeVersion": "20",
"projectName": "my-api",
"packageManager": "pnpm"
}
}list_profiles
Lists all available development environment profiles.
Returns:
{
"profiles": [
{
"name": "typescript-node",
"displayName": "TypeScript + Node.js",
"description": "Modern TypeScript development...",
"version": "1.0.0",
"tags": ["typescript", "nodejs", "backend"]
}
]
}Development
Project Structure
nix-devshell-mcp/
āāā src/
ā āāā config/ # Configuration management
ā āāā fs/ # Filesystem operations
ā āāā profiles/ # Profile loading and management
ā āāā templates/ # Handlebars template rendering
ā āāā tools/ # DevshellTool orchestration
ā āāā utils/ # Error handling, logging
ā āāā validation/ # Input and schema validation
ā āāā index.ts # MCP server entry point
āāā templates/ # Profile templates
ā āāā typescript-node/
ā āāā python-fastapi/
ā āāā angular-frontend/
ā āāā java-spring-boot/
āāā tests/ # Test suite (104 tests, 83% coverage)
āāā docs/ # Specification documentsRunning Tests
# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Watch mode
npm test -- --watchBuilding
# Build TypeScript
npm run build
# Development mode (watch)
npm run devLinting & Formatting
# Lint code
npm run lint
# Fix linting issues
npm run lint:fix
# Format code
npm run formatArchitecture
Core Components
ConfigManager - Handles configuration loading, merging, and environment variable resolution.
FilesystemManager - Manages file operations with atomic writes, path validation, and non-destructive behavior.
ProfileManager - Loads and validates profile templates from the templates directory.
TemplateRenderer - Renders Handlebars templates with custom helpers for common transformations.
Validator - Performs JSON schema validation using AJV for inputs and configurations.
DevshellTool - Orchestrates all components to create complete development environments.
Handlebars Helpers
The template renderer includes 11 custom helpers:
indent- Indent text by N spacestoJson- Convert object to JSON stringifEquals- Conditional comparisonjoinWith- Join array with separatorifCond- Flexible conditional with operatorsdefault- Return default value if falsylowercase- Convert to lowercaseuppercase- Convert to uppercasekebabCase- Convert to kebab-casecamelCase- Convert to camelCasepascalCase- Convert to PascalCase
Documentation
Specification Documents
Comprehensive specifications are available in the repository:
PRD.md - Product requirements and user stories
TECHNICAL_SPEC.md - System architecture and design
API_SPEC.md - MCP tool API specifications
TEMPLATE_SPEC.md - Template implementations
CONFIG_SCHEMA.md - Configuration system
TEST_SPEC.md - Testing strategy
IMPLEMENTATION_PLAN.md - Development phases
QUICK_REFERENCE.md - Quick reference guide
SUMMARY.md - Executive summary
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Testing
The project includes comprehensive test coverage:
104 tests across 6 test suites
83.21% statement coverage
69.05% branch coverage
98.66% function coverage
Tests cover:
Configuration management
Filesystem operations
Profile loading and validation
Template rendering
Input validation
End-to-end orchestration
Requirements
Node.js: 18+ required
Nix: with flakes enabled
direnv: for automatic environment activation
License
ISC
Support
For issues or questions:
Check the documentation first
Review existing GitHub issues
Create a new issue with detailed information
Acknowledgments
Built with:
@modelcontextprotocol/sdk - MCP protocol implementation
Handlebars - Template engine
AJV - JSON schema validation
Vitest - Testing framework
Status: ā Production Ready
All phases complete: Core implementation, profiles, tests, documentation.
Available Tools
2 toolscreate_devshellB
Creates a Nix flake development environment from a template profile. Generates flake.nix, direnv configuration, and scaffolding files. Non-destructive: will not overwrite existing files.
Inputs: profile (required), projectPath (required), options.
list_profilesA
Lists all available development environment profiles with their descriptions. Use this to discover which profiles are available before creating a devshell.
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
TDQS
Scored across 2 tools
The two tools target clearly distinct stages: list_profiles is read-only discovery, while create_devshell performs scaffolding. There is no overlap in purpose and the descriptions reinforce the intended workflow order.
Both names follow a consistent snake_case verb_noun pattern (list_profiles, create_devshell). The verb choice accurately reflects read vs. write semantics.
Two tools is on the thin side even for a narrow domain; the set covers a single discover-then-create flow. Additional operations (e.g., inspecting or removing an existing devshell) would round out the surface without bloating it.
Discovery and creation are covered, but there is no way to inspect an existing devshell, update/regenerate it, or clean up afterward. Agents that need lifecycle management beyond initial scaffold will hit a dead end.
Maintenance
Related MCP Connectors
AI that works, like you: in your own files, with every change signed.
Create, run and manage Homemade dev VMs and projects from your AI agent.
Persistent cloud workspaces for AI agents: run commands, edit files, use git and a browser.
Adaptive plan/build/review cycles for AI coding assistants, persisted across sessions.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables creation of ephemeral, polyglot development environments using Nix for on-demand execution of code with specific dependencies across Python, Node.js, Ruby, R, and Lua without cluttering the system.2MIT
- AlicenseNot gradedqualityBmaintenanceAccess the Nix ecosystem (Nixpkgs, NixOS, Home Manager, nix-darwin, nixvim, nixhub...)7GPL 3.0
- AlicenseBqualityDmaintenanceAutomates setup of local development environments for Python, Node.js, Flutter, Android, and more on macOS and Linux. Can be used as a standalone CLI or as an MCP server for AI assistant integration.10MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI assistants to interact with NixOS development tools, manage builds, and optimize workflows through natural language.Apache 2.0