Skip to content

Commit 6f9f696

Browse files
authored
Add new prompt to save custom user prompts to config (#117)
* Add new prompt to save custom user prompts to config * Tweak prompt creation
1 parent 88c9baa commit 6f9f696

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/clojure_mcp/prompts.clj

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,31 @@ After doing this provide a very brief (8 lines) summary of where we are and then
280280
(.getPath file)
281281
(.getMessage e))}]})))))))})
282282

283+
(def save-new-prompt
284+
{:name "save_new_prompt"
285+
:description "Asks the user for a new prompt and a name, and saves them to their user config"
286+
:prompt-fn (fn [_ request-args clj-result-k]
287+
(clj-result-k
288+
{:description "Help user create/update a custom prompt"
289+
:messages [{:role :user
290+
:content "Here is how you create a new prompt:
291+
1. In the `.clojure-mcp` project folder, find the `config.edn` file.
292+
2. Under the `:prompts` key will be a map of strings (which name the prompts) and maps (which define the prompts).
293+
3. Note that each prompt has a description and content, and may also have arguments.
294+
4. Read each prompt, and ask the user if they want to create a new prompt or edit an existing prompt.
295+
5. Ask the user what they want the prompt to do.
296+
6. Help the user compose the content of the prompt, including any arguments, if required.
297+
7. If this is a new prompt, save it as described below.
298+
8. If this is an existing prompt, update the existing prompt.
299+
300+
How to save a prompt:
301+
302+
Save prompt in the `.clojure-mcp` project folder, in the `config.edn` file under the `:prompts` key using the STRING name of the prompt as the key,
303+
and using the following format:
304+
`:description` - \"Custom user-added prompt\"
305+
`:content` - %s
306+
`:args` - vector of args, where each arg is a map of `:name`, `:description`, and a `:required?` flag."}]}))})
307+
283308
(defn create-prompt-from-config
284309
"Creates a prompt from configuration map.
285310
Config should have :description, :args, and either :file-path or :content.
@@ -338,6 +363,7 @@ After doing this provide a very brief (8 lines) summary of where we are and then
338363
(str
339364
(load-prompt-from-resource "clojure-mcp/prompts/system/clojure_repl_form_edit.md")
340365
(load-prompt-from-resource "clojure-mcp/prompts/system/clojure_form_edit.md")))}
366+
save-new-prompt
341367
(create-project-summary working-dir)
342368
chat-session-summary
343369
resume-chat-session

0 commit comments

Comments
 (0)