Skip to content

Commit d115db2

Browse files
committed
Add server bootstrap command
1 parent cd0118e commit d115db2

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

cmd/docker-mcp/commands/server.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package commands
33
import (
44
"encoding/json"
55
"fmt"
6+
"path/filepath"
67
"strings"
78

89
"github.com/docker/cli/cli/command"
@@ -111,5 +112,28 @@ func serverCommand(docker docker.Client, dockerCli command.Cli) *cobra.Command {
111112
},
112113
})
113114

115+
var language string
116+
initCommand := &cobra.Command{
117+
Use: "init <directory>",
118+
Short: "Initialize a new MCP server project",
119+
Long: "Initialize a new MCP server project in the specified directory with boilerplate code, Dockerfile, and compose.yaml",
120+
Args: cobra.ExactArgs(1),
121+
RunE: func(cmd *cobra.Command, args []string) error {
122+
dir := args[0]
123+
if err := server.Init(cmd.Context(), dir, language); err != nil {
124+
return err
125+
}
126+
serverName := filepath.Base(dir)
127+
fmt.Fprintf(cmd.OutOrStdout(), "Successfully initialized MCP server project in %s\n", dir)
128+
fmt.Fprintf(cmd.OutOrStdout(), "Next steps:\n")
129+
fmt.Fprintf(cmd.OutOrStdout(), " cd %s\n", dir)
130+
fmt.Fprintf(cmd.OutOrStdout(), " docker build -t %s:latest .\n", serverName)
131+
fmt.Fprintf(cmd.OutOrStdout(), " docker compose up\n")
132+
return nil
133+
},
134+
}
135+
initCommand.Flags().StringVar(&language, "language", "go", "Programming language for the server (currently only 'go' is supported)")
136+
cmd.AddCommand(initCommand)
137+
114138
return cmd
115139
}

0 commit comments

Comments
 (0)