Skip to content

hasundue/claude-code.nix

 
 

Repository files navigation

Claude Code MCP Integration for Nix

A Nix-based integration system for Claude Code that provides seamless configuration and management of MCP (Model Context Protocol) servers through devenv and Home Manager.

Features

  • Pre-configured MCP Servers: Built-in support for popular MCP servers including Asana, GitHub, Grafana, Git, Filesystem, and more
  • Secure Credential Management: Automatic handling of API tokens and credentials from files
  • devenv Integration: Easy setup for development environments
  • Home Manager Support: System-wide Claude Code configuration
  • Extensible: Add custom MCP servers and tools

Quick Start

Add this flake's overlay to your nixpkgs import.

let
  pkgs = import nixpkgs {
    overlays = [ claude-code.overlays.default ];
  };
in
# ...

Using with devenv

Add to your devenv module configuration (assuming nix flakes)

{
  imports = [ inputs.claude-code.devenvModules.claude-code ];
  
  claude-code = {
    enable = true;
    mcp = {
      git.enable = true;
      filesystem = {
        enable = true;
        allowedPaths = [ "/path/to/your/project" ];
      };
      github = {
        enable = true;
        tokenFilepath = "/path/to/github-token";
      };
    };
  };
}

Using with Home Manager

Add to your Home Manager configuration:

{
  imports = [ inputs.claude-code.homeManagerModules.claude-code ];
  
  programs.claude-code = {
    enable = true;
    mcp = {
      git.enable = true;
      filesystem = {
        enable = true;
        allowedPaths = [ "${config.home.homeDirectory}/Projects" ];
      };
      asana = {
        enable = true;
        tokenFilepath = "/var/run/agenix/asana.token";
      };
    };
  };
}

Available MCP Servers

Built-in Presets

Preset Description Source
asana Asana task management integration with API token support roychri/mcp-server-asana
buildkite Buildkite CI/CD pipeline integration and monitoring buildkite/buildkite-mcp-server
fetch Web content fetching with proxy support and custom user agents modelcontextprotocol/servers
filesystem Local filesystem access with configurable path restrictions modelcontextprotocol/servers
git Git repository operations and version control modelcontextprotocol/servers
github GitHub API integration with configurable toolsets (repos, issues, users, pull_requests, code_security) github/github-mcp-server
grafana Grafana monitoring, alerting, and dashboard management with multiple toolsets grafana/mcp-grafana
lsp-golang Language Server Protocol integration for Go development with configurable workspace isaacphi/mcp-language-server
lsp-nix Language Server Protocol integration for Nix development with configurable workspace isaacphi/mcp-language-server
lsp-python Language Server Protocol integration for Python development with configurable workspace isaacphi/mcp-language-server
lsp-rust Language Server Protocol integration for Rust development with configurable workspace isaacphi/mcp-language-server
lsp-typescript Language Server Protocol integration for TypeScript development with configurable workspace isaacphi/mcp-language-server
sequential-thinking Enhanced reasoning and knowledge graph capabilities modelcontextprotocol/servers
time Time and timezone utilities with configurable local timezone modelcontextprotocol/servers

Custom MCP Servers

Add custom MCP servers using the servers attribute:

mcp.servers.my-custom-server = {
  type = "stdio";
  command = "${pkgs.my-mcp-server}/bin/server";
  args = [ "--option" "value" ];
  env = {
    API_KEY_FILE = "/path/to/api-key";
  };
};

Extending with Custom Tools

Add custom tools that can be used by MCP servers:

programs.claude-code = {
  extraTools = {
    my-tool = {
      package = pkgs.my-custom-package;
      binary = "my-binary";
    };
  };
};

Security Features

  • Credential File Support: All MCP servers support reading credentials from files instead of environment variables
  • Path Restrictions: Filesystem access is restricted to explicitly allowed paths
  • No Credential Exposure: API tokens and keys are never exposed in the Nix store

Contributing

See CONTRIBUTE.md for development setup, testing, and contribution guidelines.

License

This project is licensed under the MIT License.

About

Flake with mcp server presets for home-manager and devenv modules

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Nix 87.5%
  • Shell 12.5%