Skip to content

Commit 82fdeac

Browse files
committed
refactor: clean up and remove unnecessary allocations in stdio server initialization
1 parent a30a711 commit 82fdeac

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

cmd/github-mcp-server/main.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,28 +120,23 @@ func runStdioServer(cfg runConfig) error {
120120
host = viper.GetString("gh-host")
121121
}
122122

123-
// Check if a token is set
124-
token := os.Getenv("GITHUB_PERSONAL_ACCESS_TOKEN")
125-
126-
// Create GH client
127-
ghClientOptions := api.ClientOptions{
123+
// Create GitHub API client
124+
httpClient, err := api.NewHTTPClient(api.ClientOptions{
128125
Host: host,
129-
AuthToken: token,
130-
}
131-
132-
httpClient, err := api.NewHTTPClient(ghClientOptions)
126+
AuthToken: os.Getenv("GITHUB_PERSONAL_ACCESS_TOKEN"),
127+
})
133128
if err != nil {
134-
return fmt.Errorf("failed to create GitHub client: %w", err)
129+
return fmt.Errorf("failed to create client: %w", err)
135130
}
136131
ghClient := gogithub.NewClient(httpClient)
137132
ghClient.UserAgent = fmt.Sprintf("github-mcp-server/%s", version)
138133

139-
t, dumpTranslations := translations.TranslationHelper()
140-
141134
getClient := func(_ context.Context) (*gogithub.Client, error) {
142135
return ghClient, nil // closing over client
143136
}
144-
// Create
137+
138+
// Create MCP server
139+
t, dumpTranslations := translations.TranslationHelper()
145140
ghServer := github.NewServer(getClient, version, cfg.readOnly, t)
146141
stdioServer := server.NewStdioServer(ghServer)
147142

0 commit comments

Comments
 (0)