Skip to main content
Glama
nix-devshell-mcp

nix-devshell-mcp

by kcalvelli

nix-devshell-mcp

Model Context Protocol (MCP) Server for Generating Nix Flake Development Environments

Tests Coverage TypeScript License

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 build

Configuration

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 activation

  • package.json - Node.js package configuration with scripts

  • tsconfig.json - TypeScript compiler configuration

  • src/index.ts - Starter TypeScript code

  • README.md - Project documentation

Then simply:

cd /home/user/my-app
direnv allow
npm install
npm run dev

Available 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 directory

  • profile (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 documents

Running Tests

# Run all tests
npm test

# Run with coverage
npm run test:coverage

# Watch mode
npm test -- --watch

Building

# Build TypeScript
npm run build

# Development mode (watch)
npm run dev

Linting & Formatting

# Lint code
npm run lint

# Fix linting issues
npm run lint:fix

# Format code
npm run format

Architecture

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 spaces

  • toJson - Convert object to JSON string

  • ifEquals - Conditional comparison

  • joinWith - Join array with separator

  • ifCond - Flexible conditional with operators

  • default - Return default value if falsy

  • lowercase - Convert to lowercase

  • uppercase - Convert to uppercase

  • kebabCase - Convert to kebab-case

  • camelCase - Convert to camelCase

  • pascalCase - Convert to PascalCase

Documentation

Specification Documents

Comprehensive specifications are available in the repository:

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:

Acknowledgments

Built with:


Status: āœ… Production Ready

All phases complete: Core implementation, profiles, tests, documentation.

Available Tools

2 tools
create_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

    A3.6/5.0

    Scored across 2 tools

    Disambiguation5/5

    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.

    Naming Consistency5/5

    Both names follow a consistent snake_case verb_noun pattern (list_profiles, create_devshell). The verb choice accurately reflects read vs. write semantics.

    Tool Count3/5

    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.

    Completeness3/5

    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

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Access the Nix ecosystem (Nixpkgs, NixOS, Home Manager, nix-darwin, nixvim, nixhub...)
      7
      GPL 3.0
    • A
      license
      B
      quality
      D
      maintenance
      Automates 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.
      10
      MIT