From e5960c4e97514e67d652252fdce69a850fe42a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20Kadir=20Ak=C4=B1n?= Date: Sun, 6 Apr 2025 20:36:19 +0300 Subject: [PATCH] fix: templates --- README.md | 2 +- cmd/mcptools/commands/new.go | 3 +-- cmd/mcptools/commands/version.go | 6 ++++++ cmd/mcptools/main.go | 6 +++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fd2decc..72f9ca5 100644 --- a/README.md +++ b/README.md @@ -317,7 +317,7 @@ mcp tools node build/index.js Project templates are stored in either: - Local `./templates/` directory - User's home directory: `~/.mcpt/templates/` -- Next to the MCP Tools executable +- Homebrew installation path (`/opt/homebrew/Cellar/mcp/v#.#.#/templates`) When installing via Homebrew, templates are automatically installed to your home directory. But if you use source install, you need to run `make install-templates`. diff --git a/cmd/mcptools/commands/new.go b/cmd/mcptools/commands/new.go index 9a3c501..3c71c8e 100644 --- a/cmd/mcptools/commands/new.go +++ b/cmd/mcptools/commands/new.go @@ -10,8 +10,6 @@ import ( "github.com/spf13/cobra" ) -var TemplatesPath string = os.Getenv("HOME") + "/.mcpt/templates" - // Constants for template options. const ( sdkTypeScript = "ts" @@ -104,6 +102,7 @@ func createProjectStructure(components map[string]string, sdk, transport string) // Look for templates in multiple locations templatesDir := findTemplatesDir(sdk) + if templatesDir == "" { return fmt.Errorf("could not find templates directory for SDK: %s", sdk) } diff --git a/cmd/mcptools/commands/version.go b/cmd/mcptools/commands/version.go index cb1505e..6b55df7 100644 --- a/cmd/mcptools/commands/version.go +++ b/cmd/mcptools/commands/version.go @@ -2,6 +2,7 @@ package commands import ( "fmt" + "os" "github.com/spf13/cobra" ) @@ -9,6 +10,9 @@ import ( // Version information placeholder. var Version = "dev" +// TemplatesPath information placeholder. +var TemplatesPath = os.Getenv("HOME") + "/.mcpt/templates" + // VersionCmd creates the version command. func VersionCmd() *cobra.Command { return &cobra.Command{ @@ -16,6 +20,8 @@ func VersionCmd() *cobra.Command { Short: "Print the version information", Run: func(cmd *cobra.Command, _ []string) { fmt.Fprintf(cmd.OutOrStdout(), "MCP Tools version %s\n", Version) + // print build parameters + fmt.Fprintf(cmd.OutOrStdout(), " Templates path: %s\n", TemplatesPath) }, } } diff --git a/cmd/mcptools/main.go b/cmd/mcptools/main.go index 2911755..16c93b9 100644 --- a/cmd/mcptools/main.go +++ b/cmd/mcptools/main.go @@ -10,10 +10,10 @@ import ( "github.com/spf13/cobra" ) -// version information placeholders. +// Build parameters. var ( - Version = "dev" - TemplatesPath = os.Getenv("HOME") + "/.mcpt/templates" + Version string + TemplatesPath string ) func init() {