Skip to content

Conversation

@jmckitrick
Copy link
Contributor

@jmckitrick jmckitrick commented Oct 7, 2025

Summary by CodeRabbit

  • New Features
    • Added an experimental “manage-prompts” tool to create, update, list, retrieve, and remove named prompts in project config, with validation, user-friendly messages, and error reporting.
    • Added project-level config load/save capabilities (auto-creating directories/files, readable formatting) and made home config loading publicly available for broader merging of settings.

@coderabbitai
Copy link

coderabbitai bot commented Oct 7, 2025

Walkthrough

Adds public project/home config save/load utilities and exposes the home-config loader. Introduces a new manage-prompts tool (add/remove/list/get) wired into experimental tools and using project config for prompt storage.

Changes

Cohort / File(s) Summary
Config management enhancements
src/clojure_mcp/config.clj
Made load-home-config public; added save-config-file, private get-project-config-path, and public load-project-config / save-project-config; minor doc/formatting tweaks and added clojure.pprint for pretty-save.
Tools registry update
src/clojure_mcp/tools.clj
Added 'clojure-mcp.tools.manage-prompts.tool/manage-prompts-tool to experimental-tool-syms; minor whitespace/docstring edits.
Manage prompts tool
src/clojure_mcp/tools/manage_prompts/tool.clj
New tool with name/description/schema, input validation, execution for add_prompt/remove_prompt/list_prompts/get_prompt against project config, result formatting, and registration helpers.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant TS as ToolSystem
  participant MPT as ManagePromptsTool
  participant CFG as ConfigStore

  U->>TS: invoke manage-prompts (op, prompt_name, prompt_content)
  TS->>MPT: dispatch(inputs, context)
  MPT->>MPT: validate inputs (op-specific)

  alt operations that read config
    MPT->>CFG: load-project-config(working-dir)
    CFG-->>MPT: project config
  end

  alt add_prompt
    MPT->>CFG: save-project-config(updated :prompts, working-dir)
    CFG-->>MPT: ok
  else remove_prompt
    MPT->>CFG: save-project-config(updated :prompts, working-dir)
    CFG-->>MPT: ok / not-found
  else list_prompts/get_prompt
    MPT-->>TS: formatted result (prompts or single prompt)
  end

  TS-->>U: formatted response (success / not-found / error)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Config improvements #99 — Also modifies src/clojure_mcp/config.clj to extend home/project configuration handling; overlaps with the new load/save utilities.

Poem

A rabbit taps keys in a cozy log,
Saving prompts like carrots in a fog.
Add one, list many, fetch with a hop—
Remove the mushy, keep the crop. 🥕
Configs snug in burrows, ready to plop.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “Prompt management tool” directly captures the primary feature added by this changeset—the new manage-prompts tool—and is concise, specific, and easily understood by reviewers scanning the history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 88c9baa and a9a4e98.

📒 Files selected for processing (3)
  • src/clojure_mcp/config.clj (7 hunks)
  • src/clojure_mcp/tools.clj (3 hunks)
  • src/clojure_mcp/tools/manage_prompts/tool.clj (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.{clj,cljc}

📄 CodeRabbit inference engine (CLAUDE.md)

src/**/*.{clj,cljc}: Use :require with ns aliases for imports (e.g., [clojure.string :as string])
Include clear tool :description for LLM guidance
Validate inputs and provide helpful error messages in MCP tools
Return structured data with both result and error status in MCP tools
Maintain atom-based state for consistent service access in MCP tools

Files:

  • src/clojure_mcp/tools.clj
  • src/clojure_mcp/config.clj
  • src/clojure_mcp/tools/manage_prompts/tool.clj
**/*.{clj,cljc}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{clj,cljc}: Use kebab-case for vars/functions; end predicates with ? (e.g., is-top-level-form?)
Use try/catch with specific exception handling; use atom for tracking errors
Use 2-space indentation and maintain whitespace in edited forms
Align namespaces with directory structure (e.g., clojure-mcp.repl-tools)

Files:

  • src/clojure_mcp/tools.clj
  • src/clojure_mcp/config.clj
  • src/clojure_mcp/tools/manage_prompts/tool.clj
🔇 Additional comments (15)
src/clojure_mcp/tools.clj (1)

33-34: LGTM!

The manage-prompts tool symbol is correctly added to the experimental tools collection, following the established naming convention.

src/clojure_mcp/config.clj (6)

5-5: LGTM!

The clojure.pprint import is correctly aliased and used in the save-config-file function for pretty-printing EDN output.


38-43: LGTM!

Making load-home-config public is intentional based on the PR objectives, enabling external access to home config loading.


45-59: LGTM!

The save-config-file implementation correctly:

  • Creates parent directories when needed
  • Pretty-prints EDN for readability
  • Logs success/failure appropriately
  • Returns a boolean indicating success

The error handling with try/catch is appropriate for file I/O operations.


61-64: LGTM!

The get-project-config-path function correctly constructs the project config path following the established .clojure-mcp/config.edn convention.


66-71: LGTM!

The load-project-config function correctly reuses the existing load-config-file utility and follows the same pattern as load-home-config.


73-76: LGTM!

The save-project-config function is a clean wrapper that composes save-config-file with get-project-config-path, maintaining good separation of concerns.

src/clojure_mcp/tools/manage_prompts/tool.clj (8)

1-6: LGTM!

The namespace declaration follows Clojure conventions:

  • Uses kebab-case naming
  • Properly requires dependencies with aliases
  • Includes clear docstring

As per coding guidelines.


8-9: LGTM!

The tool name correctly uses snake_case for MCP protocol compatibility.


11-32: LGTM!

The tool description is comprehensive and follows coding guidelines:

  • Clear explanation of operations
  • Helpful examples
  • Guidance on when to use the tool

As per coding guidelines requiring clear tool descriptions for LLM guidance.


34-43: LGTM!

The JSON schema correctly defines:

  • Enum constraint for operations
  • Clear property descriptions
  • Required fields

45-65: LGTM!

The input validation is thorough and follows coding guidelines:

  • Validates required parameters
  • Provides helpful error messages with context
  • Uses specific exception handling with ex-info

As per coding guidelines requiring validation with helpful error messages.


67-106: LGTM!

The execution logic correctly:

  • Handles all four operations with appropriate logic
  • Uses try/catch for error handling with logging
  • Returns structured data with :result and :error status
  • Leverages project config utilities appropriately

The prompt names are stored as strings in the :prompts map as intended (matching the schema definition).

As per coding guidelines requiring structured data with result and error status.


147-151: LGTM!

The create-manage-prompts-tool function correctly extracts the working directory from the nREPL client atom and constructs the tool configuration map.


153-159: LGTM!

The manage-prompts-tool function properly wraps the tool creation and returns a registration map using the tool-system API.

@jmckitrick
Copy link
Contributor Author

@bhauman This is a first round effort, and just lists custom prompts. If I'm on the right track, I'll proceed with adding/editing next.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/clojure_mcp/tools/manage_prompts/tool.clj (1)

135-141: Consider filtering nil values before joining.

The when forms in the vector can return nil if their conditions are false, resulting in blank lines in the output when joined. For cleaner formatting, filter out nil values before joining.

Apply this diff to remove blank lines:

                          (str "Prompt: " (:prompt_name result) "\n\n"
                               (if (map? content)
-                                (str/join "\n"
-                                          [(when (:description content)
-                                             (str "Description: " (:description content)))
-                                           (when (:content content)
-                                             (str "Content:\n" (:content content)))
-                                           (when (:file-path content)
-                                             (str "File: " (:file-path content)))])
+                                (str/join "\n"
+                                          (filter some?
+                                                  [(when (:description content)
+                                                     (str "Description: " (:description content)))
+                                                   (when (:content content)
+                                                     (str "Content:\n" (:content content)))
+                                                   (when (:file-path content)
+                                                     (str "File: " (:file-path content)))]))
                                 content))))
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a9a4e98 and 8378f58.

📒 Files selected for processing (1)
  • src/clojure_mcp/tools/manage_prompts/tool.clj (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/**/*.{clj,cljc}

📄 CodeRabbit inference engine (CLAUDE.md)

src/**/*.{clj,cljc}: Use :require with ns aliases for imports (e.g., [clojure.string :as string])
Include clear tool :description for LLM guidance
Validate inputs and provide helpful error messages in MCP tools
Return structured data with both result and error status in MCP tools
Maintain atom-based state for consistent service access in MCP tools

Files:

  • src/clojure_mcp/tools/manage_prompts/tool.clj
**/*.{clj,cljc}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{clj,cljc}: Use kebab-case for vars/functions; end predicates with ? (e.g., is-top-level-form?)
Use try/catch with specific exception handling; use atom for tracking errors
Use 2-space indentation and maintain whitespace in edited forms
Align namespaces with directory structure (e.g., clojure-mcp.repl-tools)

Files:

  • src/clojure_mcp/tools/manage_prompts/tool.clj
🧠 Learnings (1)
📚 Learning: 2025-08-02T20:23:28.499Z
Learnt from: CR
PR: bhauman/clojure-mcp#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-02T20:23:28.499Z
Learning: Applies to src/**/*.{clj,cljc} : Use `:require` with ns aliases for imports (e.g., `[clojure.string :as string]`)

Applied to files:

  • src/clojure_mcp/tools/manage_prompts/tool.clj
🔇 Additional comments (1)
src/clojure_mcp/tools/manage_prompts/tool.clj (1)

148-152: get-nrepl-user-dir always returns a valid directory. create-and-start-nrepl-connection initializes the client map with a canonical :nrepl-user-dir, so working-dir cannot be nil.

Likely an incorrect or invalid review comment.

@jmckitrick jmckitrick closed this Oct 8, 2025
@jmckitrick jmckitrick deleted the jcm/save-prompts branch October 8, 2025 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant