@@ -159,24 +159,10 @@ func getNameFromPackageJSON() string {
159159func detectServerName (subfolder string ) string {
160160 // Try to get from git remote
161161 repoURL := detectRepoURL ()
162- if repoURL != "" {
163- // Extract owner/repo from GitHub URL
164- if strings .Contains (repoURL , "github.com" ) {
165- parts := strings .Split (repoURL , "/" )
166- if len (parts ) >= 5 {
167- owner := parts [3 ]
168- repo := strings .TrimSuffix (parts [4 ], ".git" )
169-
170- // If we're in a subdirectory, use the current folder name
171- if subfolder != "" {
172- if cwd , err := os .Getwd (); err == nil {
173- folderName := filepath .Base (cwd )
174- return fmt .Sprintf ("io.github.%s/%s" , owner , folderName )
175- }
176- }
177-
178- return fmt .Sprintf ("io.github.%s/%s" , owner , repo )
179- }
162+ if repoURL != "" && strings .Contains (repoURL , "github.com" ) {
163+ name := buildGitHubServerName (repoURL , subfolder )
164+ if name != "" {
165+ return name
180166 }
181167 }
182168
@@ -194,6 +180,26 @@ func detectServerName(subfolder string) string {
194180 return "com.example/my-mcp-server"
195181}
196182
183+ func buildGitHubServerName (repoURL , subfolder string ) string {
184+ parts := strings .Split (repoURL , "/" )
185+ if len (parts ) < 5 {
186+ return ""
187+ }
188+
189+ owner := parts [3 ]
190+ repo := strings .TrimSuffix (parts [4 ], ".git" )
191+
192+ // If we're in a subdirectory, use the current folder name
193+ if subfolder != "" {
194+ if cwd , err := os .Getwd (); err == nil {
195+ folderName := filepath .Base (cwd )
196+ return fmt .Sprintf ("io.github.%s/%s" , owner , folderName )
197+ }
198+ }
199+
200+ return fmt .Sprintf ("io.github.%s/%s" , owner , repo )
201+ }
202+
197203func detectDescription () string {
198204 // Try to get from package.json
199205 if data , err := os .ReadFile ("package.json" ); err == nil {
0 commit comments