Skip to content

Commit 018629f

Browse files
authored
Add task create and task catalog (github#4)
* Start adding catalog code. * Add create cli (from check code). * Add catalog command, fix messaging. * Docs update. * Remove TODO.
1 parent 596fb0c commit 018629f

File tree

23 files changed

+2085
-115
lines changed

23 files changed

+2085
-115
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
catalogs/

CONTRIBUTING.md

Lines changed: 53 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22
Thank you for your interest in contributing to the official Docker MCP Registry.
33
This document outlines how to contribute to this project.
44

5+
## Prerequisites
6+
7+
- Go v1.24+
8+
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
9+
- [Task](https://taskfile.dev/)
10+
11+
512
## 🔄 Pull request process overview
613
- Fork the repository to your own GitHub account and clone it locally.
714
- Repository includes a `servers` folder where you should add a new folder with a `server.yaml` inside.
8-
- Repository includes a `scripts` folder with bash scripts to automate some of the steps.
15+
- Repository includes a `scripts` folder with bash scripts and Go code to automate some of the steps.
916
- Correctly format your commit messages, see Commit message guidelines below. _Note: All commits must include a Signed-off-by trailer at the end of each commit message to indicate that the contributor agrees to the Developer Certificate of Origin._
1017
- Open a PR by ensuring the title and its description reflect the content of the PR.
1118
- Ensure that CI passes, if it fails, fix the failures.
@@ -22,76 +29,72 @@ Add your entry by creating a new folder following the `owner@name` template, and
2229
- The GitHub URL of your project. The project needs to have a valid Dockerfile.
2330
- A brief description of your MCP Server.
2431
- A category for the MCP server, one of:
25-
* 'ai'
26-
* 'data-visualization'
27-
* 'database'
28-
* 'devops'
29-
* 'ecommerce'
30-
* 'finance'
31-
* 'games'
32-
* 'communication'
33-
* 'monitoring'
34-
* 'productivity'
35-
* 'search'
36-
37-
#### 🚀 Generate folder and `server.yaml` using `new-server.sh` script
38-
You can use our script to automate the creation of the files. Let's assume we have a new MCP Server to access my org's database. The MCP is called `My-ORGDB-MCP` and the GitHub repo is located at: `https://github.com/myorg/my-orgdb-mcp`
39-
40-
You can call the tool passing the MCP server name, category, and github url.
32+
* 'ai'
33+
* 'data-visualization'
34+
* 'database'
35+
* 'devops'
36+
* 'ecommerce'
37+
* 'finance'
38+
* 'games'
39+
* 'communication'
40+
* 'monitoring'
41+
* 'productivity'
42+
* 'search'
43+
44+
#### 🚀 Generate folder and `server.yaml` using `task create`
45+
You can use our command to automate the creation of the files. Let's assume we have a new MCP Server to access my org's database. My server's GitHub repo is located at: `https://github.com/myorg/my-orgdb-mcp`
46+
47+
You can call the creation tool passing the category (required), and github url. If your server requires any environment variables, pass them at the end with `-e KEY=value`.
4148

4249
```
43-
./scripts/new-server.sh My-ORGDB-MCP databases https://github.com/myorg/my-orgdb-mcp
50+
task create -- --category database https://github.com/myorg/my-orgdb-mcp -e API_TOKEN=test
4451
```
4552

46-
This will create a directory under `servers` as follows: `./servers/my-orgdb-mcp` and inside you will find a `server.yaml` file with your MCP definition.
53+
This will build an image using the Dockerfile at the root of the repository, run it while verifying the MCP server is able to list tools, and then create the necessary files. It will create a directory under `servers` as follows: `./servers/my-orgdb-mcp` and inside you will find a `server.yaml` file with your MCP definition.
4754

4855
```
49-
server:
50-
name: test01
51-
image: mcp/test01
56+
name: my-orgdb-mcp
57+
image: mcp/my-orgdb-mcp
5258
type: server
5359
meta:
54-
category: test
60+
category: database
5561
tags:
56-
- test
57-
highlighted: false
62+
- database
5863
about:
59-
title: test01
64+
title: My OrgDB MCP (TODO)
65+
description: TODO (only to provide a better description than the upstream project)
6066
icon: https://avatars.githubusercontent.com/u/182288589?s=200&v=4
6167
source:
62-
project: https://github.com/docker/mcp-registry
63-
branch: main
64-
# config:
65-
# description: TODO
66-
# secrets:
67-
# - name: test01.secret_name
68-
# env: TEST01
69-
# example: TODO
70-
# env:
71-
# - name: ENV_VAR_NAME
72-
# example: TODO
73-
# value: '{{test01.env_var_name}}'
74-
# parameters:
75-
# type: object
76-
# properties:
77-
# param_name:
78-
# type: string
79-
# required:
80-
# - param_name
68+
project: https://github.com/myorg/my-orgdb-mcp
69+
config:
70+
description: Configure the connection to TODO
71+
secrets:
72+
- name: my-orgdb-mcp.api_token
73+
env: API_TOKEN
74+
example: <API_TOKEN>
8175
```
8276

83-
If you want to provide a specific Docker image built by your organisation, you can pass it to the script as follows:
77+
If you want to provide a specific Docker image built by your organisation instead of having Docker build the image, you can specify it with the `--image` flag:
8478

8579
```
86-
IMAGE_NAME=myorg/myimage ./scripts/new-server.sh My-ORGDB-MCP databases https://github.com/myorg/my-orgdb-mcp
80+
task create -- --category database --image myorg/my-mcp https://github.com/myorg/my-orgdb-mcp -e API_TOKEN=test
8781
```
8882

89-
As you can see, the configuration block has been commented out. If you need to pass environmental variables or secrets, please uncomment the necessary lines.
90-
9183
🔒 If you don't provide a Docker image, we will build the image for you and host it in [Docker Hub's `mcp` namespace](https://hub.docker.com/u/mcp), the benefits are: image will include cryptographic signatures, provenance tracking, SBOMs, and automatic security updates. Otherwise, self-built images still benefit from container isolation but won't include the enhanced security features of Docker-built images.
9284

9385
### 3️⃣ Run & Test your MCP Server locally
94-
🚧 tbd
86+
After creating your server file with `task create`, you will be given instructions for running it locally. In the case of my-orgdb-mcp, we would run the following commands next.
87+
88+
```
89+
task catalog -- my-orgdb-mcp
90+
docker mcp catalog import $PWD/catalogs/my-orgdb-mcp/catalog.yaml
91+
```
92+
93+
Now, if we go into the MCP Toolkit on Docker Desktop, we'll see our new MCP server there! We can configure and enable it there, and test it against configured clients. Once we're done testing, we can restore it back to the original Docker catalog.
94+
95+
```
96+
docker mcp catalog reset
97+
```
9598

9699
### 4️⃣ Create `commit` and raise the Pull Request
97100
🚧 tbd

Taskfile.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "3"
2+
3+
tasks:
4+
create:
5+
desc: Create a new mcp server definition
6+
cmd: go run ./cmd/create {{.CLI_ARGS}}
7+
8+
catalog:
9+
desc: Generate a test catalog
10+
cmd: go run ./cmd/catalog {{.CLI_ARGS}}

cmd/catalog/main.go

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"log"
7+
"os"
8+
"path/filepath"
9+
10+
"github.com/docker/mcp-registry/pkg/catalog"
11+
"github.com/docker/mcp-registry/pkg/servers"
12+
)
13+
14+
func main() {
15+
if len(os.Args) != 2 {
16+
fmt.Println("Usage: catalog <server-name>")
17+
os.Exit(1)
18+
}
19+
20+
name := os.Args[1]
21+
22+
if err := run(name); err != nil {
23+
log.Fatal(err)
24+
}
25+
}
26+
27+
func run(name string) error {
28+
serverFile := filepath.Join("servers", name, "server.yaml")
29+
server, err := servers.Read(serverFile)
30+
if err != nil {
31+
if os.IsNotExist(err) {
32+
fmt.Fprintf(os.Stderr, "server.yaml for %s not found. Run `task create -- <your_repo>` to create a new server definition first.\n", name)
33+
}
34+
return err
35+
}
36+
37+
tile, err := catalog.ToTile(context.Background(), server)
38+
if err != nil {
39+
return err
40+
}
41+
42+
catalogDir := filepath.Join("catalogs", name)
43+
if err := os.MkdirAll(catalogDir, 0755); err != nil {
44+
return err
45+
}
46+
47+
if err := writeCatalog(name, catalogDir, tile); err != nil {
48+
return err
49+
}
50+
51+
return nil
52+
}
53+
54+
func writeCatalog(name, catalogDir string, tile catalog.Tile) error {
55+
catalogFile := filepath.Join(catalogDir, "catalog.yaml")
56+
57+
if err := catalog.WriteYaml(catalogFile, catalog.TopLevel{
58+
Version: catalog.Version,
59+
Name: "docker-mcp", // overwrite the default catalog
60+
DisplayName: "Local Test Catalog",
61+
Registry: catalog.TileList{
62+
{
63+
Name: name,
64+
Tile: tile,
65+
},
66+
},
67+
}); err != nil {
68+
return err
69+
}
70+
71+
fmt.Printf("Catalog written to %s\n", catalogFile)
72+
73+
return nil
74+
}

0 commit comments

Comments
 (0)