Skip to content

Commit 88c632b

Browse files
Allow server startup without token for future zero-config OAuth
- Remove hard error when no token/OAuth configured - Server now starts with warning instead of failing - OAuth flow attempted if configured, but failures don't block startup - Tools will fail when called without auth, but server remains running - Enables future zero-configuration with baked-in fallback OAuth app - Clear warning messages guide users on authentication options - Addresses comment 3765150847 Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
1 parent 5e50dfd commit 88c632b

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

cmd/github-mcp-server/main.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"context"
5-
"errors"
65
"fmt"
76
"os"
87
"sort"
@@ -39,7 +38,7 @@ var (
3938
RunE: func(cmd *cobra.Command, _ []string) error {
4039
token := viper.GetString("personal_access_token")
4140

42-
// If no token provided, check if OAuth is configured
41+
// If no token provided, attempt OAuth if configured
4342
if token == "" {
4443
oauthClientID := viper.GetString("oauth_client_id")
4544
if oauthClientID != "" {
@@ -54,12 +53,20 @@ var (
5453

5554
result, err := oauth.StartOAuthFlow(cmd.Context(), oauthCfg)
5655
if err != nil {
57-
return fmt.Errorf("OAuth flow failed: %w", err)
56+
// OAuth flow failed - warn but allow server to start
57+
// This enables future zero-configuration fallback patterns
58+
fmt.Fprintf(os.Stderr, "Warning: OAuth flow failed: %v\n", err)
59+
fmt.Fprintf(os.Stderr, "Starting server without authentication - tools will fail until authenticated\n")
60+
} else {
61+
token = result.AccessToken
5862
}
59-
60-
token = result.AccessToken
6163
} else {
62-
return errors.New("GITHUB_PERSONAL_ACCESS_TOKEN not set and OAuth not configured (set --oauth-client-id or GITHUB_OAUTH_CLIENT_ID)")
64+
// No token and no OAuth configured - warn but allow server to start
65+
// This enables future zero-configuration use with baked-in fallback app
66+
fmt.Fprintf(os.Stderr, "Warning: No authentication configured\n")
67+
fmt.Fprintf(os.Stderr, " - Set GITHUB_PERSONAL_ACCESS_TOKEN environment variable, or\n")
68+
fmt.Fprintf(os.Stderr, " - Configure OAuth with --oauth-client-id (or GITHUB_OAUTH_CLIENT_ID)\n")
69+
fmt.Fprintf(os.Stderr, "Starting server without authentication - tools will fail until authenticated\n")
6370
}
6471
}
6572

0 commit comments

Comments
 (0)