Skip to content

Commit c33e614

Browse files
Slim/stateful (#68)
* Support long-running stateful servers * Fix environment schema * Check for divergent branches * Add or for blank interpolations * Update cache keys to be the whole container def
1 parent 34e7ae1 commit c33e614

21 files changed

+475
-150
lines changed

cleanup-images.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
# Script to find and remove all Docker images from the vonwig or mcp namespaces
4+
# Usage: ./docker-namespace-cleanup.sh
5+
6+
echo "Finding Docker images from 'vonwig' and 'mcp' namespaces..."
7+
8+
# Get all images that match either namespace
9+
# Using grep to filter for images that contain vonwig or mcp in their repository names
10+
vonwig_images=$(docker images | grep 'vonwig' | awk '{print $1":"$2}')
11+
mcp_images=$(docker images | grep 'mcp' | awk '{print $1":"$2}')
12+
13+
# Combine the lists
14+
all_matched_images="$vonwig_images $mcp_images"
15+
16+
# Check if any images were found
17+
if [ -z "$all_matched_images" ]; then
18+
echo "No Docker images found from 'vonwig' or 'mcp' namespaces."
19+
exit 0
20+
fi
21+
22+
# Count found images
23+
image_count=$(echo "$all_matched_images" | wc -w)
24+
echo "Found $image_count images to remove."
25+
26+
# Ask for confirmation before removing
27+
read -p "Do you want to proceed with removal? (y/n): " confirm
28+
if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
29+
echo "Operation cancelled."
30+
exit 0
31+
fi
32+
33+
# Iterate through each image and remove it
34+
echo "Removing Docker images..."
35+
for image in $all_matched_images; do
36+
echo "Removing image: $image"
37+
docker rmi -f "$image"
38+
done
39+
40+
echo "All matching Docker images have been removed."

deps-lock.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@
7272
"mvn-repo": "https://repo.clojars.org/",
7373
"hash": "sha256-Ijax5VAq9/FFnKomP+huFSOKh/HWGiwXLAZty/1iwo8="
7474
},
75+
{
76+
"mvn-path": "borkdude/dynaload/0.3.5/dynaload-0.3.5.jar",
77+
"mvn-repo": "https://repo.clojars.org/",
78+
"hash": "sha256-CIfAzbmvzs18SW6iWKMuQ6py52bz8GMuG9D1JFyowkw="
79+
},
80+
{
81+
"mvn-path": "borkdude/dynaload/0.3.5/dynaload-0.3.5.pom",
82+
"mvn-repo": "https://repo.clojars.org/",
83+
"hash": "sha256-XBwijxopsG0KfQNJD15k+vcTo8YWcpi6Fxz/wzz57Rg="
84+
},
7585
{
7686
"mvn-path": "camel-snake-kebab/camel-snake-kebab/0.4.3/camel-snake-kebab-0.4.3.jar",
7787
"mvn-repo": "https://repo.clojars.org/",
@@ -92,6 +102,26 @@
92102
"mvn-repo": "https://repo.clojars.org/",
93103
"hash": "sha256-LaaIDz3x3lGTb/GfarGHaT5MAc3MVCiFWE5Z85qs6z4="
94104
},
105+
{
106+
"mvn-path": "cider/cider-nrepl/0.47.1/cider-nrepl-0.47.1.jar",
107+
"mvn-repo": "https://repo.clojars.org/",
108+
"hash": "sha256-Jd/9suFKMi/vs+Qg/Eyole6eg52Do7Qcm8AuEU6/k5Q="
109+
},
110+
{
111+
"mvn-path": "cider/cider-nrepl/0.47.1/cider-nrepl-0.47.1.pom",
112+
"mvn-repo": "https://repo.clojars.org/",
113+
"hash": "sha256-wqnXFQ7ux9mx57/czHmWFj7bGA/Fo8tEUGRRCYvL5/s="
114+
},
115+
{
116+
"mvn-path": "cider/orchard/0.23.3/orchard-0.23.3.jar",
117+
"mvn-repo": "https://repo.clojars.org/",
118+
"hash": "sha256-HCBow7MARg+qaAC/KuuOgUqWBmzj6D5RuG7x+hIDtO4="
119+
},
120+
{
121+
"mvn-path": "cider/orchard/0.23.3/orchard-0.23.3.pom",
122+
"mvn-repo": "https://repo.clojars.org/",
123+
"hash": "sha256-44cVYzDbmG7P6jkWRo+B8wK32Ffr9lu8DMy31g6hAp4="
124+
},
95125
{
96126
"mvn-path": "clj-commons/clj-yaml/1.0.28/clj-yaml-1.0.28.jar",
97127
"mvn-repo": "https://repo.clojars.org/",
@@ -517,6 +547,16 @@
517547
"mvn-repo": "https://repo1.maven.org/maven2/",
518548
"hash": "sha256-Rm9ue5kB6VKuGtJPDpSUpWgJYfBOQiObWuZOjcr2KXo="
519549
},
550+
{
551+
"mvn-path": "mx/cider/logjam/0.3.0/logjam-0.3.0.jar",
552+
"mvn-repo": "https://repo.clojars.org/",
553+
"hash": "sha256-h1moSv+GjTrjwDEil7l6psf7j5NUK39llkv5kT9K4J8="
554+
},
555+
{
556+
"mvn-path": "mx/cider/logjam/0.3.0/logjam-0.3.0.pom",
557+
"mvn-repo": "https://repo.clojars.org/",
558+
"hash": "sha256-k9fFPsmXKX/14Z92LgY8cFtCu8jmbBE/DCbyRWK1D6Q="
559+
},
520560
{
521561
"mvn-path": "net/java/dev/jna/jna-platform/5.15.0/jna-platform-5.15.0.jar",
522562
"mvn-repo": "https://repo1.maven.org/maven2/",
@@ -547,6 +587,16 @@
547587
"mvn-repo": "https://repo1.maven.org/maven2/",
548588
"hash": "sha256-GvaZ+Nndq2f5oNIC+9eRXrA2Klpt/V/8VMr6NGXJywo="
549589
},
590+
{
591+
"mvn-path": "nrepl/nrepl/1.0.0/nrepl-1.0.0.jar",
592+
"mvn-repo": "https://repo.clojars.org/",
593+
"hash": "sha256-owuXNP8uY582Xw11U7SHcwbypUPPAh4pnRW/HqvWpbs="
594+
},
595+
{
596+
"mvn-path": "nrepl/nrepl/1.0.0/nrepl-1.0.0.pom",
597+
"mvn-repo": "https://repo.clojars.org/",
598+
"hash": "sha256-dHN5LZGfjodYUES5nySqLqFVNCBgRI2opHhGvkXz2nI="
599+
},
550600
{
551601
"mvn-path": "org/apache/apache/18/apache-18.pom",
552602
"mvn-repo": "https://repo1.maven.org/maven2/",

deps.edn

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
org.babashka/http-client {:mvn/version "0.4.12"}
1515
com.taoensso/timbre {:mvn/version "5.2.1"}
1616
io.github.slimslenderslacks/lsp4clj {:git/sha "04390f9b1dcf0946dff335b48951617bc6bf6a9d"}
17-
funcool/promesa {:mvn/version "9.0.470"}}
17+
funcool/promesa {:mvn/version "9.0.470"}
18+
borkdude/dynaload {:mvn/version "0.3.5"}}
1819
:aliases {:main {:main-opts ["-m" "docker.main"]}
1920
:build {:ns-default build
20-
:deps {io.github.clojure/tools.build {:git/tag "v0.9.5" :git/sha "24f2894"}}}}}
21+
:deps {io.github.clojure/tools.build {:git/tag "v0.9.5" :git/sha "24f2894"}}}
22+
:main-repl {:main-opts ["-m" "docker.main"]
23+
:extra-deps {cider/cider-nrepl {:mvn/version "0.47.1"}}}}}

dev/catalog.clj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525
(println t))))
2626

2727
(defn f->prompt [f]
28-
(prompts/get-prompts {:prompts f}))
28+
(try (prompts/get-prompts {:prompts f}) (catch Throwable t (println t) {})))
2929

3030
(defn tile-metadata [m]
31-
{:tools (-> m :functions)
31+
{:tools (->> (:functions m)
32+
(map #(select-keys [:name] (:function %)))
33+
(into []))
3234
:prompts (count (:messages m))
3335
:resources (or (:resources m) {})})
3436

@@ -54,7 +56,7 @@
5456
(comment
5557
;; setup stdout logger
5658
(repl/setup-stdout-logger)
57-
59+
(generate-updated-catalog)
5860
;; parse catalog
5961
(def catalog (yaml/parse-string (slurp "prompts/catalog.yaml")))
6062

dev/socket_client.clj

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
(ns socket-client
2+
(:require
3+
[cheshire.core :as json]
4+
[clojure.core.async :as async]
5+
[clojure.java.io :as io])
6+
(:import
7+
[java.io BufferedInputStream]
8+
[java.net Socket]))
9+
10+
(def socket (Socket. "localhost" 8811))
11+
12+
(def reader (io/reader (BufferedInputStream. (.getInputStream socket))))
13+
14+
(async/thread
15+
(loop []
16+
(let [line (.readLine reader)]
17+
(when line
18+
(println line)
19+
(recur)))))
20+
21+
(def writer (io/writer (.getOutputStream socket)))
22+
23+
(defn send [m]
24+
(.write writer (json/generate-string m))
25+
(.write writer "\n")
26+
(.flush writer))
27+
28+
(send {:jsonrpc "2.0" :method "initialize" :id 0 :params {:protocolVersion "2024-11-05"
29+
:capabilities {:roots {}}
30+
:client-info {:name "Socket Client" :version "0.1"}}})
31+
32+
(send {:jsonrpc "2.0" :method "notifications/initialized" :params {}})
33+
34+
(send {:jsonrpc "2.0" :id 1 :result {:roots [{:uri "file:///Users/slim" :name "home-directory"}]}})
35+
36+
(.close socket)
37+

prompts/mcp/openapi-schema.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ mcp:
44
image: vonwig/openapi-schema:latest
55
workdir: /app
66
volumes:
7-
- "{{openApiSchemaPath}}:{{openApiSchemaPath}}"
7+
- "{{openApiSchemaPath|or:[]|volume|into}}"
88
---
99

remove-secrets.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# Script to remove all Docker secrets
4+
# Usage: ./docker-secret-cleanup.sh
5+
6+
echo "Retrieving list of Docker secrets..."
7+
8+
# Get the list of secrets (assuming the output format has the secret name as the first column)
9+
secrets=$(docker x secret list | awk 'NR>1 {print $1}')
10+
11+
# Check if any secrets were found
12+
if [ -z "$secrets" ]; then
13+
echo "No Docker secrets found."
14+
exit 0
15+
fi
16+
17+
# Iterate through each secret and remove it
18+
echo "Removing Docker secrets..."
19+
for secret in $secrets; do
20+
echo "Removing secret: $secret"
21+
docker x secret rm "$secret"
22+
done
23+
24+
echo "All Docker secrets have been removed."

runbook.md

Lines changed: 2 additions & 2 deletions
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.7"
23+
VERSION="0.0.8"
2424
docker buildx build \
2525
--builder hydrobuild \
2626
--platform linux/amd64,linux/arm64 \
@@ -35,7 +35,7 @@ docker run --rm -t --init -v docker-prompts:/prompts alpine:latest tail -f /prom
3535
```
3636

3737
```sh
38-
clj -M:main serve --mcp --port 8811 --register "github:docker/labs-ai-tools-for-devs?path=prompts/bootstrap.md"
38+
clj -M:main-repl serve --mcp --port 8811
3939
```
4040

4141
```sh

src/docker.clj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,14 @@
354354
(or (:entrypoint container-definition) Entrypoint)
355355
(or (:command container-definition) Cmd)))]
356356
(-> container-definition
357-
(assoc :entrypoint ["/bin/sh" "-c" (injected-entrypoint (:secrets container-definition) Env real-entrypoint)])
357+
(assoc :entrypoint ["/bin/sh" "-c" (injected-entrypoint
358+
(:secrets container-definition)
359+
(concat
360+
Env
361+
(->> (:environment container-definition)
362+
(map (fn [[k v]] (format "%s=%s" k v)))
363+
(into [])))
364+
real-entrypoint)])
358365
(dissoc :command))))
359366

360367
(defn run-streaming-function-with-no-stdin

src/extension/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
mcp_docker:
3-
image: mcp/docker:0.0.7
3+
image: mcp/docker:0.0.8
44
ports:
55
- 8811:8811
66
volumes:

0 commit comments

Comments
 (0)