File tree 3 files changed +41
-15
lines changed
3 files changed +41
-15
lines changed Original file line number Diff line number Diff line change 119
119
(update-in [:mcp.prompts/static s] (constantly m))
120
120
(update [:mcp.prompts/resources ] (fnil merge {}) (extract-resources m)))))))
121
121
122
- (comment
123
- (println @db*)
124
- (-> @db* :mcp.prompts/registry (get " github-issues" ))
125
- (update-prompt {} " github-issues" (slurp " prompts/examples/github_issues.md" )))
122
+ (defn- has-function? [s]
123
+ (fn [m]
124
+ (some #(= s (-> % :function :name )) (:functions m))))
125
+
126
+ (defn parameter-values
127
+ " extract parameter values from metadata for the tile"
128
+ [function-name]
129
+ (->> (:mcp.prompts/registry @db*)
130
+ (vals )
131
+ (filter (has-function? function-name))
132
+ (first )
133
+ :metadata
134
+ :parameter-values ))
126
135
127
136
; ; the registry.yaml file is a list of refs selected from our catalog
128
137
(defn registry-refs
136
145
137
146
(comment
138
147
(repl/setup-stdout-logger )
148
+ (println @db*)
149
+ (-> @db* :mcp.prompts/registry (get " github-issues" ))
150
+ (update-prompt {} " github-issues" (slurp " prompts/examples/github_issues.md" ))
139
151
; in /$HOME/registry.yaml
140
152
(git/collect-unique-cache-dirs
141
- (git-cache-refs
142
- (registry-refs prompts.core/registry)))
143
-
153
+ (git-cache-refs
154
+ (registry-refs prompts.core/registry)))
155
+
144
156
; prompts will come from prompts-cache
145
157
; /prompts or $HOME/.prompts-cache
146
158
(git/hashch {:owner " docker" :repo " labs-ai-tools-for-devs" :ref " slim/config" })
147
159
(add-refs (registry-refs prompts.core/registry))
148
160
(-> @db*
149
161
:mcp.prompts/registry
150
- pprint))
162
+ vals
163
+ pprint)
164
+ (parameter-values " read_file" ))
165
+
Original file line number Diff line number Diff line change 204
204
; ; messages
205
205
[{:type " text"
206
206
:text (->>
207
- tool-outputs
208
- (map :content )
209
- (apply str))}]
207
+ tool-outputs
208
+ (map :content )
209
+ (apply str))}]
210
210
; ; tool call responses
211
211
(->> tool-outputs
212
212
(mapcat (comp :content :result ))
236
236
; ; tool calls are functions, which are arguments,name maps, and ids
237
237
; ; mcp tool call params are also maps of name, and arguments
238
238
; ; TODO add the config parameters for just the registry entry that defines the tool
239
- [{:function (update params :arguments (fn [arguments] (json/generate-string arguments))) :id " 1" }])
239
+ [{:function (update
240
+ params :arguments
241
+ (fn [arguments]
242
+ (logger/trace
243
+ (-> arguments
244
+ (merge (db/parameter-values (:name params)))
245
+ (json/generate-string )))))
246
+ :id " 1" }])
240
247
(async/reduce conj [])
241
248
(async/<!! ))]
242
249
; ; TODO with mcp, tool-calls with errors are still jsonrpc results
316
323
; ; add dynamic refs from prompts volume
317
324
(db/add-refs
318
325
(concat (->> (:register opts)
319
- (map (fn [ref] {:type :static :ref ref})))
326
+ (map (fn [ref] {:type :static :ref ref})))
320
327
; ; register dynamic prompts
321
- (when (fs/exists? (fs/file registry))
322
- (db/registry-refs registry)))))
328
+ (when (fs/exists? (fs/file registry))
329
+ (db/registry-refs registry)))))
323
330
324
331
(defn server-context
325
332
" create chan server options for any io chan server that we build"
Original file line number Diff line number Diff line change 19
19
[pogonos.core :as stache]
20
20
[pogonos.partials :as partials]
21
21
[registry]
22
+ repl
22
23
schema
23
24
[selmer.parser :as selmer]))
24
25
220
221
(get-prompts {:prompts (fs/file " ./prompts/mcp/stripe.md" )}))
221
222
222
223
(comment
224
+ (repl/setup-stdout-logger )
223
225
(get-prompts {:prompts (fs/file " ./prompts/examples/curl.md" )})
224
226
(get-prompts {:prompts (fs/file " ./prompts/examples/generate-dockerfile.md" )})
225
227
(get-prompts {:prompts (fs/file " ./README.md" )})
228
+ (get-prompts {:prompts (fs/file " ./prompts/mcp/postgres.md" )})
229
+ (get-prompts {:prompts (fs/file " ./prompts/mcp/postgresql.md" )})
226
230
(=
227
231
((:prompt-function (get-prompts {:prompts (fs/file " ./prompts/examples/qrencode.md" )})) {:content " mycontent" })
228
232
[{:role " user" ,
You can’t perform that action at this time.
0 commit comments