Skip to content

Commit

Permalink
Add more content
Browse files Browse the repository at this point in the history
  • Loading branch information
slimslenderslacks committed Jan 18, 2025
1 parent 1a21f56 commit 79c9ce3
Show file tree
Hide file tree
Showing 10 changed files with 283 additions and 35 deletions.
3 changes: 3 additions & 0 deletions docs/content/projects/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
title: "Other Projects"
---
48 changes: 48 additions & 0 deletions docs/content/tools/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,51 @@ cascade:
type: docs
---

## Background

The `mcp/run` container is an mcp server, but it can be extended by giving it new
containers, as tools, and prompts. Existing containers, like `curl` or `ffmpeg`, can
then be exposed as MCP servers.

```mermaid
flowchart LR
desktop["Claude Desktop"]
subgraph docker["Docker"]
mcp["mcp/run"]
end
desktop --> docker
docker -- extended by --- box1["Tools/Prompt Def (curl)"]
docker -- extended by --- box2["Tools/Prompt Def (ffmpeg)"]
style desktop fill:#f9f9f9,stroke:#333,stroke-width:2px
style docker fill:#e6f3ff,stroke:#333,stroke-width:2px,color:#0066cc
style mcp fill:#fff,stroke:#333,stroke-width:1px
style box1 fill:#f9f9f9,stroke:#333,stroke-width:2px
style box2 fill:#f9f9f9,stroke:#333,stroke-width:2px
```

Our current definitions are markdown documents (see [examples](examples)).

```markdown
---
tools:
- name: curl
---

# prompt

Run the curl command, in silent mode, to fetch gists for user slimslenderslacks from GitHub.
```

## Getting Started

We can use this to extend MCP clients like Claude Desktop, and create test new tools and prompts using
VSCode. Instructions for these two paths are here.

1. Attach the MCP server [to Claude Desktop](quickstart).
{{< callout >}}
Claude Desktop has not yet implemented the `notifications/tools/list_changed`. This means that
Claude doesn't reload our tool definitions until it is restarted. It's easier to develop
prompts in VSCode where we can create a much more efficient inner loop.
{{< /callout >}}
2. [Test prompt definitions](quickstart_vscode) using our VSCode extension. Using VSCode as an
mcp server can provide an effective inner loop for developing the content.
5 changes: 5 additions & 0 deletions docs/content/tools/docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
title: Documentation
---

### Topics

* [How to author prompts](prompts)
* [Updating Claude Desktop](claude-desktop)


13 changes: 13 additions & 0 deletions docs/content/tools/docs/claude-desktop.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,16 @@ This will have already been exposed using this MCP server so when using Claude D
You'll see a prompt asking if you want to run the "hello world" tool locally.

![consent](consent.png)

## More prompts

You can register new definitions in public github repos by adding additional `--register` arguments.

```
"--register", "github:docker/labs-ai-tools-for-devs?path=prompts/examples/swagger.md"
```

We are moving these registration command to a command line. It doesn't make sense to change the claude
config each time you add or remote a defintion. However, because Claude Desktop has to be restarted
every time a definition changes today (because of the missing notification), we will work
with Anthropic to make this much smoother.
4 changes: 4 additions & 0 deletions docs/content/tools/examples/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
title: example prompts
---

* [simplest definition we can think of](hello-world)
* [Use curl to fetch your GitHub gists](curl)
* [call swagger api](swagger)
* [create an animaged gif using ffmpeg](ffmpeg)
* [read and write local files](filesystem)
* [use sqlite from an mcp client](sqlite)
* [working with local files](filesystem)
55 changes: 55 additions & 0 deletions docs/content/tools/examples/filesystem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: filesystem
---

# Description

Add `read_file` and `write_file` tool containers.

# Prompt Code

```
---
model: claude-3-5-sonnet-20241022
tools:
- name: read_file
description: |
read a file from disk
Read the complete contents of a file from the file system.
Handles various text encodings and provides detailed error messages
if the file cannot be read. Use this tool when you need to examine
the contents of a single file. Only works within allowed directories.
parameters:
type: object
properties:
path:
type: string
container:
image: vonwig/bash_alpine
entrypoint: cat
command:
- "{{path|safe}}"
- name: write_file
description: |
Create a new file or completely overwrite an existing file with new content.
Use with caution as it will overwrite existing files without warning.
Handles text content with proper encoding. Only works within allowed directories.
parameters:
type: object
properties:
path:
type: string
content:
type: string
container:
image: vonwig/bash_alpine
command:
- "-c"
- "echo {{content|safe}} > {{path|safe}}"
---
# prompt user
read the file deps.edn and then write the string "blah.txt" into the file test.txt
```
30 changes: 30 additions & 0 deletions docs/content/tools/examples/hello-world.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: hello world
---

# Description

Just echo a greeting by running a container!

# Prompt Code

```markdown
---
name: hello-docker
description: run the hello-docker
model: claude-3-5-sonnet-20241022
tools:
- name: hello-docker
description: print a secret message
container:
image: busybox:latest
command:
- echo
- "Hello, World!"
---

# prompt

Use hello world to print a secret message and then explain it to me
```

66 changes: 66 additions & 0 deletions docs/content/tools/examples/sqlite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: sqlite
---

# Description

Use sqlite containers to provide 3 tools:

* `read-query`
* `list-tables`
* `describe-table`

The sqlite database ( /mcp/test1.db ) is mounted using a Docker volume.

Use these tools to ask Claude to explore the data using the tools above.

Here's a fully worked
[example](https://github.com/docker/labs-ai-tools-for-devs/blob/main/prompts/examples/mcp-sqlite.md?plain=1)
for building insights from a user defined topic.

# Prompt Code

```markdown
---
tools:
- name: read-query
description: Execute a SELECT query on the SQLite database
parameters:
type: object
properties:
query:
type: string
description: SELECT SQL query to execute
container: &sqlite-container
image: &sqlite-image vonwig/sqlite:latest
command:
- &db "/mcp/test1.db"
- "{{query|safe}}"
volumes: &mounts
- "mcp-test:/mcp"
- name: list-tables
description: List all tables in the SQLite database
container:
image: *sqlite-image
command:
- *db
- "SELECT name from sqlite_master WHERE type='table'"
volumes: *mounts
- name: describe-table
description: Get the schema information for a specific table
parameters:
type: object
properties:
table_name:
type: string
description: Name of the table to describe
container:
image: *sqlite-image
command:
- *db
- "PRAGMA table_info({{table_name}})"
volumes: *mounts
---

```

46 changes: 11 additions & 35 deletions docs/content/tools/quickstart.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,25 @@
---
title: Quick Start w/ VSCode
title: Quick Start w/ Claude Desktop
weight: 1
---

{{% steps %}}

### Download `.vsix` extension
### Install

Download the `.vsix` extension from the [releases page](https://github.com/docker/labs-ai-tools-vscode/releases).
[Configure Docker Desktop](../docs/claude-desktop) to use the `mcp/run` Docker container.

### Install extension from `.vsix` file
### Restart Claude Desktop

```sh
code --install-extension <path-to-vsix-file>
```
Restarting desktop should be a one-time activity. However, Claude
Desktop does not support the `tools/list_changed` notification so we
currently have to restart desktop more less continuously. :)

or use the VSCode command palette `Extensions: Install from VSIX...`
### Try a prompt

### Open a prompt
With the extension installed, open a prompt in VSCode. Examples can be found in the [examples](https://github.com/docker/labs-ai-tools-for-devs/tree/main/prompts/examples) directory.
Write a prompt in Claude that will run one of the tools in a registered defintion.
For example:

### Configure OpenAI API Key, or use a different model.
Default model is `gpt-4` provided by OpenAI. Use an the VSCode command palette `Docker AI: Set secret key` to set your API key.

**Changing the model:**
Use the following keys in the prompt front-matter to change the model:

Anthropic:
```yml
---
url: https://api.anthropic.com
model: claude-3-5-sonnet-20240620
---
```


Ollama:
```yml
---
model: llama3.2
url: https://docker.host.internal:11434/v1
---
```

### Run the prompt
Use the VSCode command palette `Docker AI: Run this prompt` to run the prompt.
> Use hello world to send a greeting and then respond to what comes back.
{{% /steps %}}
48 changes: 48 additions & 0 deletions docs/content/tools/quickstart_vscode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: Quick Start w/ VSCode
weight: 1
---

{{% steps %}}

### Download `.vsix` extension

Download the `.vsix` extension from the [releases page](https://github.com/docker/labs-ai-tools-vscode/releases).

### Install extension from `.vsix` file

```sh
code --install-extension <path-to-vsix-file>
```

or use the VSCode command palette `Extensions: Install from VSIX...`

### Open a prompt
With the extension installed, open a prompt in VSCode. Examples can be found in the [examples](https://github.com/docker/labs-ai-tools-for-devs/tree/main/prompts/examples) directory.

### Configure OpenAI API Key, or use a different model.
Default model is `gpt-4` provided by OpenAI. Use an the VSCode command palette `Docker AI: Set secret key` to set your API key.

**Changing the model:**
Use the following keys in the prompt front-matter to change the model:

Anthropic:
```yml
---
model: claude-3-5-sonnet-20240620
---
```


Ollama:
```yml
---
model: llama3.2
url: https://docker.host.internal:11434/v1
---
```

### Run the prompt
Use the VSCode command palette `Docker AI: Run this prompt` to run the prompt.

{{% /steps %}}

0 comments on commit 79c9ce3

Please sign in to comment.