This document describes Clojure MCP (Model Context Protocol), an alpha-stage server designed to seamlessly integrate AI models with Clojure's REPL-driven development workflow. It provides a comprehensive suite of Clojure-aware editing and development tools, aiming to enhance productivity through immediate feedback, incremental development, and human oversight. The project emphasizes a cohesive toolbox for interacting with Clojure codebases, featuring intelligent file reading, structure-aware editing, and direct REPL evaluation. While compatible with various AI clients, it specifically recommends Claude Desktop for a cost-free, integrated experience. The accompanying community discussion highlights the power of AI in understanding and indexing codebases, the natural synergy between AI agents and REPL-driven development, and practical approaches to integrating ad-hoc REPL experiments into formal tests.
Clojure MCP: AI-Assisted REPL-Driven Development
Project Introduction:
Clojure MCP (Model Context Protocol) is an alpha-stage server that connects AI models to a Clojure nREPL, providing specialized Clojure editing tools to enhance the development experience.
It's designed to be a "superser" of tools beyond what Claude Code offers, with a strong recommendation for use with Claude Desktop to avoid API charges and leverage custom prompts.
Key Takeaway: Clojure MCP aims to significantly improve Clojure development workflow by deeply integrating AI assistance into the REPL-driven process.
Core Features and Philosophy:
Clojure-Aware Editing: Integrates with existing tools like clj-kondo, parinfer, cljfmt, and clj-rewrite for smart, structure-aware operations, including Emacs edit highlighting (alpha).
Why REPL-Driven Development with AI? Enables immediate feedback, incremental development in small steps, human oversight, and encourages a functional approach.
Cohesive Clojure Toolbox: Tools are designed as a unified "action space," sharing context, maintaining state (e.g., file read/write tracking for safety), and providing consistent interfaces.
Key Takeaway: The system promotes an interactive and iterative development style where AI assists in building and validating code in real-time, focusing on programmer guidance.
Installation and Setup:
Prerequisites: Requires Clojure (1.11+), Java (JDK 11+), and recommends Claude Desktop.
Project Configuration: Involves cloning the repository and configuring deps.edn in your target Clojure project with nREPL and MCP server aliases.
Claude Desktop Integration: Configure Claude Desktop's claude_desktop_config.json to launch the MCP server, specifying paths to your Clojure project and binaries.
Usage Workflow: After starting the nREPL and Claude Desktop, users add "resources" (e.g., PROJECT_SUMMARY.md, custom coding style guides, system prompts) to the AI conversation to provide context, then interactively design, code, validate in the REPL, and commit changes.
Key Takeaway: The setup process links your Clojure project's REPL to an AI client, creating a context-rich environment for AI-assisted coding.
Tooling Overview:
Tool Categories: Tools are organized into Read-Only (e.g., LS, read_file for smart Clojure file exploration, fs_grep), Code Evaluation (clojure_eval for REPL execution, bash), File Editing (clojure_edit for structure-aware form manipulation, file_write), and Agent Tools (dispatch_agent, architect, code_critique).
Smart Features:read_file offers collapsed views (function signatures only) and pattern matching for Clojure files; clojure_edit performs form-based replacements/insertions with syntax validation and defmethod handling.
Agent Tools: Require LLM API keys (Gemini, OpenAI, Anthropic), enabling advanced AI-powered tasks like autonomous searches and architectural guidance.
Key Takeaway: Clojure MCP provides a diverse and specialized set of tools tailored for Clojure's unique syntax and development patterns, designed to work cohesively with an AI assistant.
Customization and Configuration:
Modular Design: The core API (core.clj) is separate from the example implementation (main.clj), allowing users to easily define custom resources, prompts, and tools.
Project-Specific Configuration: A .clojure-mcp/config.edn file in the project root allows defining allowed-directories for security (controlling file access) and enabling emacs-notify for Emacs integration.
Security Note: The bash tool does not respect the allowed-directories boundaries.
Key Takeaway: The project is highly customizable, enabling developers to tailor the AI's capabilities and access permissions to their specific project needs.
Community Discussion Highlights (Hacker News):
AI as a "Code Indexer": Users found LLMs incredibly powerful for "indexing" their codebase, allowing them to ask specific, context-aware questions (e.g., checking for missing :app-id validations) that go beyond general design feedback. This can involve feeding the entire codebase or using vector databases.
Value of Claude Desktop: Confirmed as a "top tip" for avoiding API charges when using MCP setups with Claude, leveraging local execution.
REPL-Driven Development & LLM Interaction: The community largely agreed that REPL-driven development is a natural fit for AI agents, despite initial concerns about LLMs managing REPL state. The recommended practice of writing code in .clj files and evaluating from the editor (rather than accumulating ad-hoc state) resolves many state management challenges.
Seamless REPL-to-Test Workflow: Clojure's workflow allows for easy conversion of REPL-based experiments into formal unit tests (e.g., by renaming comment blocks to deftest), minimizing the "mess" created during experimentation.
LLM API Key Flexibility: While Claude Desktop is recommended for cost-free usage, the MCP server's agent tools support API keys from Gemini, OpenAI, and Anthropic.
Broader Agent Landscape: Discussion also touched upon other AI agent CLIs (e.g., Amazon Q, Claude Code, OpenAI Codex, Ampcode, Aider, Google Jules) and the potential for MCPs to connect to frontend environments (e.g., Playwright MCP for Chrome tab interaction).
Key Takeaway: The community validates the core premise of Clojure MCP, recognizing the immense potential of AI in deeply understanding code context and seamlessly integrating with interactive, REPL-centric development processes, while also acknowledging the evolving nature of the AI tool landscape.