Skip to content
This repository was archived by the owner on Jun 27, 2025. It is now read-only.

Commit ec64bab

Browse files
Add tiles
1 parent 9832690 commit ec64bab

File tree

11 files changed

+180
-36
lines changed

11 files changed

+180
-36
lines changed

compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ services:
1515
- github:docker/labs-ai-tools-for-devs?path=prompts/bootstrap.md
1616
volumes:
1717
docker-prompts:
18+
name: docker-prompts
1819
external: true

docs/content/tools/docs/running_containers.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
---
2+
title: defining container tools
3+
---
14

25
* default is to run synchronously without stdin and in terminal model
36
* image is mandatory
Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
---
2-
title: Using with Gordon
2+
title: QuickStart w/ Gordon
3+
weight: 4
34
---
45

5-
## gordon-mcp.yaml
6+
{{% steps %}}
7+
8+
### Install Docker Desktop Extension
9+
10+
1. Install [Docker Labs AI Tools for Devs](https://open.docker.com/extensions/marketplace?extensionId=docker/labs-ai-tools-for-devs)
11+
2. Click on the Claude button to add `mcp_docker` toolbox to your Claude Desktop.
12+
3. Select any prompts you would like to add from the catalog to your toolbox.
13+
14+
### Add gordon-mcp.yaml
615

716
When you run `docker ai` from any directory, docker ai will search that directory for a gordon-mcp.yml file.
817
If that file is present, and configured with the `mcp/docker` container then Gordon will load tools from
@@ -11,16 +20,11 @@ this container and try to use them.
1120
```yaml
1221
services:
1322
mcp_docker:
14-
image: mcp/docker:latest
15-
command: serve --mcp --register github:docker/labs-ai-tools-for-devs?path=prompts/bootstrap.md
16-
volumes:
17-
- /var/run/docker.sock:/var/run/docker.sock
18-
- docker-prompts:/prompts
23+
image: alpine:socat:latest
24+
command:
25+
- STDIO
26+
- TCP:host.docker.internal:8811
1927
x-mcp-autoremove: true
20-
21-
volumes:
22-
docker-prompts:
23-
external: false
2428
```
2529
2630
{{< callout type="info" >}}
@@ -29,8 +33,8 @@ volumes:
2933

3034
{{< /callout >}}
3135

32-
## debugging
36+
### debugging
3337

3438
We suggest using `docker ai --debug` if you are trying to debug some of your tools while using the `docker ai` cli.
3539

36-
40+
{{% /steps %}}

docs/content/tools/quickstsart_cursor.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ weight: 3
55

66
{{% steps %}}
77

8-
### Install
8+
### Go to Cursor Settings
99

10-
## Quick Start w/ Cursor
11-
12-
1. Use the Features menu of the Cursor Settings
10+
Use the Features menu of the Cursor Settings
1311

14-
![Claude Features](claude_features.png)
12+
![Claude Features](claude_features.png)
1513

16-
2. Choose `Command` mode and then copy and paste the following string into the field labeled "Command".
14+
Choose `Command` mode and then copy and paste the following string into the field labeled "Command".
1715

1816
```
1917
docker run --rm -i alpine/socat:latest STDIO TCP:host.docker.internal:8811
@@ -27,8 +25,7 @@ weight: 3
2725
After updating the list of tools, users must click the refresh button to activate new tool definitions
2826
{{< /callout >}}
2927

30-
31-
## Use tools from compose agent
28+
### Use tools in agent mode of Composer
3229

3330
Tools will only be available in the `agent` mode of the composer. Note that the composer tab has two distinct modes (`normal` and `agent`).
3431

prompts/catalog.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,3 +556,21 @@ registry:
556556
name: curl
557557
prompts: 2
558558
resources: {}
559+
stripe:
560+
description: itegrate with Stripe APIs
561+
ref: github:docker/labs-ai-tools-for-devs?path=prompts/mcp/stripe.md
562+
icon: https://cdn.jsdelivr.net/npm/simple-icons@v7/icons/stripe.svg
563+
secrets:
564+
- name: stripe.api_key
565+
brave:
566+
description: Web and local search using Brave's Search API
567+
ref: github:docker/labs-ai-tools-for-devs?path=prompts/mcp/brave.md
568+
icon: https://cdn.jsdelivr.net/npm/simple-icons@v7/icons/brave.svg
569+
secrets:
570+
- name: brave.api_key
571+
slack:
572+
description: interact with Slack Workspaces
573+
ref: github:docker/labs-ai-tools-for-devs?path=prompts/mcp/slack.md
574+
icon: https://cdn.jsdelivr.net/npm/simple-icons@v7/icons/slack.svg
575+
secrets:
576+
- name: slack.team_id

prompts/mcp/brave.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
mcp:
3+
- name: brave
4+
container:
5+
image: mcp/brave-search:latest
6+
environment:
7+
BRAVE_API_KEY: "{{ brave.api_key }}"
8+
---
9+

prompts/mcp/slack.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
mcp:
3+
- name: slack
4+
container:
5+
image: mcp/slack:latest
6+
environment:
7+
SLACK_BOT_TOKEN: "{{ slack.bot_token }}"
8+
SLACK_TEAM_ID: "{{ slack.team_id }} "
9+
---
10+

prompts/mcp/stripe.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
mcp:
3+
- name: stripe
4+
container:
5+
image: mcp/stripe:latest
6+
command:
7+
- "--tools=all"
8+
- "--api-key={{stripe.api_key}}"
9+
---
10+

src/docker.clj

Lines changed: 97 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@
124124
- coll of strings (e.g. [\"9222:9222\"])"
125125
[coll]
126126
(->>
127-
(for [s coll :let [{:keys [container host]} (parse-port s)]]
128-
[(format "%s/%s" (:port container) (:protocol container)) [{:HostPort (:port host)}]])
129-
(into {})))
127+
(for [s coll :let [{:keys [container host]} (parse-port s)]]
128+
[(format "%s/%s" (:port container) (:protocol container)) [{:HostPort (:port host)}]])
129+
(into {})))
130130

131131
(comment
132132
(port-bindings ["9222:9222"])
@@ -142,15 +142,15 @@
142142
;; Tty wraps the process in a pseudo terminal
143143
;; StdinOnce closes the stdin after the first client detaches
144144
;; OpenStdin just opens stdin
145-
(defn create-container [{:keys [image entrypoint workdir command host-dir env thread-id opts mounts volumes ports network_mode]
145+
(defn create-container [{:keys [image entrypoint workdir command host-dir environment thread-id opts mounts volumes ports network_mode]
146146
:or {opts {:Tty true}}}]
147147
(let [payload (json/generate-string
148148
(merge
149149
{:Image image}
150150
opts
151-
(when env {:env (->> env
152-
(map (fn [[k v]] (format "%s=%s" (name k) v)))
153-
(into []))})
151+
(when environment {:Env (->> environment
152+
(map (fn [[k v]] (format "%s=%s" (name k) v)))
153+
(into []))})
154154
{:HostConfig
155155
(merge
156156
{:Binds
@@ -433,6 +433,96 @@
433433
(logger/error "processing docker engine attach bytes: " t)
434434
"")))
435435

436+
(defn write-to-stdin
437+
" params
438+
client - SocketChannel for attached container"
439+
[client s]
440+
(let [buf (ByteBuffer/allocate (* 1024 20))]
441+
(.clear ^ByteBuffer buf)
442+
(try
443+
(.put ^ByteBuffer buf (.getBytes ^String s))
444+
(.flip ^ByteBuffer buf)
445+
(while (.hasRemaining buf)
446+
(.write ^SocketChannel client buf))
447+
(catch Throwable t
448+
(logger/error "write-string error " t)))))
449+
450+
(defn read-loop
451+
" params
452+
in - SocketChannel for attached container
453+
c - channel to write multiplexed stdout stderr blocks"
454+
[in c]
455+
(async/go
456+
(try
457+
(let [header-buf (ByteBuffer/allocate 8)]
458+
(loop [offset 0]
459+
(let [result (.read ^SocketChannel in header-buf)]
460+
(cond
461+
;;;;;;;;;;
462+
(= -1 result)
463+
(async/close! c)
464+
465+
;;;;;;;;;;
466+
(= 8 (+ offset result))
467+
(do
468+
(.flip ^ByteBuffer header-buf)
469+
(let [size (.getInt (ByteBuffer/wrap (Arrays/copyOfRange ^bytes (.array ^ByteBuffer header-buf) 4 8)))
470+
stream-type (case (int (nth (.array ^ByteBuffer header-buf) 0))
471+
0 :stdin
472+
1 :stdout
473+
2 :stderr)
474+
buf (ByteBuffer/allocate size)]
475+
(loop [offset 0]
476+
(let [result (.read ^SocketChannel in buf)]
477+
(cond
478+
;;;;;;;;;;
479+
(= -1 result)
480+
(async/close! c)
481+
482+
;;;;;;;;;;
483+
(= size (+ offset result))
484+
(async/>! c {stream-type (String. ^bytes (.array buf))})
485+
486+
;;;;;;;;;;
487+
:else
488+
(recur (+ offset result)))))
489+
(do
490+
(.clear ^ByteBuffer buf)
491+
(recur 0))))
492+
493+
;;;;;;;;;;
494+
:else
495+
(do
496+
(.clear ^ByteBuffer header-buf)
497+
(recur (+ offset result)))))))
498+
(catch Throwable t
499+
(logger/error "streaming exception " t)
500+
(async/close! c)))))
501+
502+
(defn attach-socket
503+
" returns SocketChannel"
504+
[container-id]
505+
(let [buf (ByteBuffer/allocate (* 1024 20))
506+
address (UnixDomainSocketAddress/of "/var/run/docker.sock")
507+
client (SocketChannel/open address)]
508+
(.configureBlocking client true)
509+
(.clear buf)
510+
;; make HTTP call
511+
(.put buf (.getBytes (String. (format "POST /containers/%s/attach?stdin=true&stdout=true&stderr=true&stream=true HTTP/1.1\n" container-id))))
512+
(.put buf (.getBytes (String. "Host: localhost\nConnection: Upgrade\nUpgrade: tcp\n\n")))
513+
(try
514+
(.flip ^ByteBuffer buf)
515+
(while (.hasRemaining buf)
516+
(.write client buf))
517+
;; TODO if successful, we should get a 101 UPGRADED response that will be exactly 117 bytes
518+
(let [buf (ByteBuffer/allocate 117)]
519+
;; TODO read the HTTP upgrade message
520+
(.read client buf)
521+
(.read client buf))
522+
(catch Throwable _
523+
client))
524+
client))
525+
436526
(defn function-call-with-stdin
437527
"creates and starts container, then writes to stdin process
438528
returns container map with Id, and socket - socket is open socket to 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
3+
image: mcp/docker:latest
44
ports:
55
- 8811:8811
66
volumes:

0 commit comments

Comments
 (0)