Skip to content

Commit 248c346

Browse files
Slim/0.0.17 (#267)
* Fix camel-case issue for _ * new version of filesystem for Windows
1 parent 3a4c406 commit 248c346

File tree

11 files changed

+89
-32
lines changed

11 files changed

+89
-32
lines changed

deps-lock.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
{
2727
"lib": "io.github.slimslenderslacks/lsp4clj",
2828
"url": "https://github.com/slimslenderslacks/lsp4clj.git",
29-
"rev": "04390f9b1dcf0946dff335b48951617bc6bf6a9d",
29+
"rev": "80f8facfadc4933ae12687087d7713d134f45a96",
3030
"git-dir": "https/github.com/slimslenderslacks/lsp4clj",
31-
"hash": "sha256-LtBVHKhOsn6L8arX0AWuNnsz5YWT1dypmZFxosJ6rzQ="
31+
"hash": "sha256-J3t25kzwBgslrktJBrPE6e03moG+2f+7z/ei5WkgRfA="
3232
}
3333
],
3434
"mvn-deps": [

deps.edn

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
org.clojure/core.async {:mvn/version "1.6.681"}
1515
org.babashka/http-client {:mvn/version "0.4.12"}
1616
com.taoensso/timbre {:mvn/version "5.2.1"}
17-
io.github.slimslenderslacks/lsp4clj {:git/sha "04390f9b1dcf0946dff335b48951617bc6bf6a9d"}
17+
io.github.slimslenderslacks/lsp4clj {:git/sha "80f8facfadc4933ae12687087d7713d134f45a96"}
1818
funcool/promesa {:mvn/version "9.0.470"}
1919
borkdude/dynaload {:mvn/version "0.3.5"}}
2020
:aliases {:main {:main-opts ["-m" "docker.main"]}

dev/catalog.clj

+25-9
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@
7878
(spit "servers.edn" (pr-str (into [] (map name (keys (:registry catalog))))))
7979
(string/join "," (->> (:registry catalog) keys (map name)))
8080

81-
(->> (-> catalog :registry vals)
82-
(map :config )
81+
(->> (-> catalog :registry vals)
82+
(map :config)
8383
(filter seq)
8484
count)
8585

@@ -105,9 +105,9 @@
105105
(fs/file (:path k))
106106
(git/ref-map->prompt-file k))}))))
107107

108-
(f->prompt (fs/file "prompts/mcp/notion.md") )
109-
(f->prompt (fs/file "prompts/mcp/multiversx-mx.md") )
110-
(f->prompt (fs/file "prompts/mcp/elasticsearch.md") )
108+
(f->prompt (fs/file "prompts/mcp/notion.md"))
109+
(f->prompt (fs/file "prompts/mcp/multiversx-mx.md"))
110+
(f->prompt (fs/file "prompts/mcp/elasticsearch.md"))
111111

112112
;; parse all of the current git prompts
113113
(def local-prompt-files-parsed
@@ -125,20 +125,36 @@
125125
(map (fn [m] [(-> m :ref :ref-string) (secrets (:prompt m))]))
126126
(into {})))
127127

128+
(first local-prompt-files-parsed)
129+
(def volume-summary
130+
(->> local-prompt-files-parsed
131+
(filter #(or (->> % :prompt :metadata :mcp (some (fn [x] (-> x :container :volumes))))
132+
(->> % :prompt :functions (some (fn [x] (-> x :function :container :volumes))))))
133+
(map (fn [m] [(-> m :ref :ref-string)
134+
(->> m :prompt ((fn [prompt]
135+
(cond
136+
(-> prompt :metadata :mcp) (->> prompt
137+
:metadata
138+
:mcp
139+
(map (fn [x] (-> x :container :volumes))))
140+
(-> prompt :functions) (->> prompt
141+
:functions
142+
(map (fn [x] (-> x :function :container :volumes))))))))]))
143+
(into {})))
144+
128145
;; secret summary
129146
(def secrets
130147
(->> container-summary
131148
vals
132149
(mapcat #(->> % (map (comp :secrets :container))))
133150
(filter seq)))
134151

135-
(->> secrets
152+
(->> secrets
136153
(mapcat keys)
137154
(map name)
138-
(string/join ",")
139-
)
155+
(string/join ","))
140156

141-
;; summary
157+
;; summary
142158
(->> container-summary
143159
(mapcat (fn [[k v]] (->> v (map (fn [m]
144160
{:image (-> m :container :image)

docs/content/tools/docs/authoring-prompts.md

+8
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,11 @@ parameter-values:
195195
user: slimslenderslacks
196196
---
197197
```
198+
199+
### volumes
200+
201+
* easist is to use docker volumes
202+
* using `"{{config|volume|into}}"`
203+
* needs `"{{config|volume-target|into}}"` for wsl2 - to send the mappings
204+
* using combination of `volume` and `environment` when the app supports it
205+

prompts/mcp/filesystem.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mcp:
66
volumes:
77
- "{{filesystem.paths|volume|into}}"
88
command:
9-
- "{{filesystem.paths|into}}"
9+
- "{{filesystem.paths|volume-target|into}}"
1010
source:
1111
url: https://github.com/modelcontextprotocol/servers/tree/2025.4.6
1212
parameter-values:

runbook.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ docker pull mcp/docker:prerelease
2020

2121
```sh
2222
# docker:command=build-release
23-
VERSION="0.0.16"
23+
VERSION="0.0.17"
2424
docker buildx build \
2525
--builder hydrobuild \
2626
--platform linux/amd64,linux/arm64 \

src/extension/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
IMAGE?=docker/labs-ai-tools-for-devs
2-
TAG?=0.2.60
2+
TAG?=0.2.84
33

44
BUILDER=buildx-multi-arch
55

src/extension/docker-compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
mcp_docker:
3-
image: mcp/docker:0.0.16
3+
image: mcp/docker:0.0.17
44
ports:
55
- 8811:8811
66
volumes:

src/interpolate.clj

+21-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
(:require
33
[cheshire.core :as json]
44
[clojure.edn :as edn]
5+
[clojure.string :as string]
56
[selmer.filters :as filters]
67
[selmer.parser :as selmer]))
78

@@ -12,21 +13,32 @@
1213
[:safe [:coll (into [] v)]]
1314
v)))
1415

16+
(defn parse-path [s]
17+
(when s
18+
(if-let [[_ drive path] (re-find #"(\p{Alpha}):(.*)" s)]
19+
{:source s
20+
:target (format "/drive/%s%s" (string/lower-case drive) (string/replace path #"\\" "/"))}
21+
{:source s
22+
:target s})))
23+
24+
(defn format-volume [{:keys [source target]}]
25+
(format "%s:%s" source target))
26+
1527
(filters/add-filter! :volume (fn [v]
1628
(if (coll? v)
17-
(->> v (map #(format "%s:%s" % %)) (into []))
18-
(format "%s:%s" v v))))
29+
(->> v (map parse-path) (map format-volume) (into []))
30+
(-> v parse-path format-volume))))
31+
32+
(filters/add-filter! :volume-target (fn [v]
33+
(if (coll? v)
34+
(->> v (map parse-path) (map :target) (into []))
35+
(-> v parse-path :target))))
1936

2037
(filters/add-filter! :or (fn [v s]
2138
(if (or (nil? v) (= "" v))
2239
[]
2340
v)))
2441

25-
(comment
26-
"this allows us to expand strings into lists of strings to be spread into container definitions"
27-
(selmer/render "{{hello.you|volume|into}}" {:hello {:you ["yes" "no"]}})
28-
(selmer/render "{{hello.you|volume|into}}" {}))
29-
3042
(defn interpolate [m template]
3143
(when-let [s (selmer/render template m {})]
3244
(if-let [parsed (try (edn/read-string s) (catch Throwable _ nil))]
@@ -57,8 +69,8 @@
5769
(dissoc defaults :functions)
5870
(when (-> definition :container :command)
5971
{:command (interpolate-coll
60-
(-> definition :container :command)
61-
arg-context)})
72+
(-> definition :container :command)
73+
arg-context)})
6274
(when (-> definition :container :entrypoint)
6375
{:entrypoint (->> (-> definition :container :entrypoint)
6476
(map (fn [s] (first (interpolate arg-context s))))

src/jsonrpc/server.clj

+13-4
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@
7272

7373
;; merges client-info capabilities and client protocol-version
7474
(swap! db* assoc-in [:servers server-id] params)
75-
{:protocol-version "2024-11-05"
75+
{:protocolVersion "2024-11-05"
7676
:capabilities {:prompts {:listChanged true}
7777
:tools {:listChanged true}
7878
:resources {:listChanged true}}
79-
:server-info {:name "docker-mcp-server"
79+
:serverInfo {:name "docker-mcp-server"
8080
:version "0.0.1"}})
8181

8282
(defmethod lsp.server/receive-notification "notifications/initialized" [_ {:keys [db* server server-id]} _]
@@ -207,7 +207,7 @@
207207

208208
(defmethod lsp.server/receive-request "resources/subscribe" [_ _ params]
209209
(logger/info "resources/subscribe" params)
210-
{:resource-templates []})
210+
{:resourceTemplates []})
211211

212212
;; -----------------
213213
;; MCP Tools
@@ -343,6 +343,12 @@
343343
(apply log-wrapper-fn log-args)
344344
(recur))))
345345

346+
(defn ^:private monitor-audit-logs [audit-ch]
347+
(async/go-loop []
348+
(when-let [log-args (async/<! audit-ch)]
349+
(apply log-wrapper-fn log-args)
350+
(recur))))
351+
346352
(defn initialize-prompts [opts]
347353
;; initialize mcp cache
348354
(client/initialize-cache)
@@ -366,7 +372,8 @@
366372
(let [timbre-logger (logger/->TimbreLogger)
367373
log-path (logger/setup timbre-logger)
368374
db* db/db*
369-
log-ch (async/chan (async/sliding-buffer 20))]
375+
log-ch (async/chan (async/sliding-buffer 20))
376+
audit-ch (async/chan)]
370377
;; add option map and log-path to the db
371378
(swap! db* merge {:log-path log-path} (dissoc opts :in))
372379
;; initialize shutdown hook
@@ -381,12 +388,14 @@
381388
jsonrpc.prompt-change-events/markdown-tool-updated)
382389
;; monitor our log channel (used by all chan servers)
383390
(monitor-server-logs log-ch)
391+
(monitor-audit-logs audit-ch)
384392
;; this won't do anything if nrepl is not present
385393
(nrepl/setup-nrepl)
386394
;; common server opts
387395
(merge
388396
{;:keyword-function identity
389397
:log-ch log-ch
398+
:audit-ch audit-ch
390399
:trace-ch log-ch
391400
:trace-level trace-level
392401
:keyword-function keyword

test/interpolate_t.clj

+15-3
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,29 @@
22
(:require
33
[cheshire.core :as json]
44
[clojure.test :as t]
5-
[interpolate]))
5+
[interpolate]
6+
[selmer.parser :as selmer]))
67

78
(t/deftest container-defintion-tests
89
(t/is
910
(=
10-
{:command []
11-
:environment {"YES" "yes"}}
11+
{:environment {"YES" "yes"}}
1212
(interpolate/container-definition
1313
{:container
1414
{:environment
1515
{"YES" "{{data.yes}}"
1616
"NO" "{{data.no}}"}}}
1717
{}
1818
(json/generate-string {:data {:yes "yes"}})))))
19+
20+
(comment
21+
"this allows us to expand strings into lists of strings to be spread into container definitions"
22+
(selmer/render "{{hello.you|volume|into}}" {:hello {:you ["yes" "no"]}})
23+
(selmer/render "{{hello.you|volume|into}}" {:hello {:you ["/Users/slim" "/Users/slim/Desktop"]}})
24+
(selmer/render "{{hello.you|volume-target|into}}" {:hello {:you ["C:\\hello" "C:\\goodbye"]}})
25+
(selmer/render "{{hello.you|volume|into}}" {:hello {:you ["C:\\hello" "C:\\goodbye"]}})
26+
(selmer/render "{{hello.you|volume|into}}" {}))
27+
28+
;; usually volume|into
29+
;;
30+

0 commit comments

Comments
 (0)