Skip to content

Commit dbfbe23

Browse files
Add server level config parameters to tool/run context
1 parent ab47118 commit dbfbe23

File tree

3 files changed

+41
-15
lines changed

3 files changed

+41
-15
lines changed

src/jsonrpc/db.clj

+23-8
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,19 @@
119119
(update-in [:mcp.prompts/static s] (constantly m))
120120
(update [:mcp.prompts/resources] (fnil merge {}) (extract-resources m)))))))
121121

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))
126135

127136
;; the registry.yaml file is a list of refs selected from our catalog
128137
(defn registry-refs
@@ -136,15 +145,21 @@
136145

137146
(comment
138147
(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"))
139151
; in /$HOME/registry.yaml
140152
(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+
144156
; prompts will come from prompts-cache
145157
; /prompts or $HOME/.prompts-cache
146158
(git/hashch {:owner "docker" :repo "labs-ai-tools-for-devs" :ref "slim/config"})
147159
(add-refs (registry-refs prompts.core/registry))
148160
(-> @db*
149161
:mcp.prompts/registry
150-
pprint))
162+
vals
163+
pprint)
164+
(parameter-values "read_file"))
165+

src/jsonrpc/server.clj

+14-7
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@
204204
;; messages
205205
[{:type "text"
206206
:text (->>
207-
tool-outputs
208-
(map :content)
209-
(apply str))}]
207+
tool-outputs
208+
(map :content)
209+
(apply str))}]
210210
;; tool call responses
211211
(->> tool-outputs
212212
(mapcat (comp :content :result))
@@ -236,7 +236,14 @@
236236
;; tool calls are functions, which are arguments,name maps, and ids
237237
;; mcp tool call params are also maps of name, and arguments
238238
;; 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"}])
240247
(async/reduce conj [])
241248
(async/<!!))]
242249
;; TODO with mcp, tool-calls with errors are still jsonrpc results
@@ -316,10 +323,10 @@
316323
;; add dynamic refs from prompts volume
317324
(db/add-refs
318325
(concat (->> (:register opts)
319-
(map (fn [ref] {:type :static :ref ref})))
326+
(map (fn [ref] {:type :static :ref ref})))
320327
;; 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)))))
323330

324331
(defn server-context
325332
"create chan server options for any io chan server that we build"

src/prompts.clj

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
[pogonos.core :as stache]
2020
[pogonos.partials :as partials]
2121
[registry]
22+
repl
2223
schema
2324
[selmer.parser :as selmer]))
2425

@@ -220,9 +221,12 @@
220221
(get-prompts {:prompts (fs/file "./prompts/mcp/stripe.md")}))
221222

222223
(comment
224+
(repl/setup-stdout-logger)
223225
(get-prompts {:prompts (fs/file "./prompts/examples/curl.md")})
224226
(get-prompts {:prompts (fs/file "./prompts/examples/generate-dockerfile.md")})
225227
(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")})
226230
(=
227231
((:prompt-function (get-prompts {:prompts (fs/file "./prompts/examples/qrencode.md")})) {:content "mycontent"})
228232
[{:role "user",

0 commit comments

Comments
 (0)