feat: Add creds for GitHub auth, add "none" auth to publisher (#276)
## Motivation and Context - Adds credentials for the new MCP Registry Login GitHub Apps (local, staging, prod) - Adds support for "none" auth to publisher ## How Has This Been Tested? - Tested publisher workflows locally - Unit and integration tests passing ## Breaking Changes None ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply. --> - [x] I have read the [MCP Documentation](https://modelcontextprotocol.io) - [x] My code follows the repository's style guidelines - [x] New and existing tests pass locally - [x] I have added appropriate error handling - [x] I have added or updated documentation as needed --- Merging based on Tadas's approval review, and only making minor docs changes on top of that.
This commit is contained in:
parent
d555acb65b
commit
e9fe6f9ab8
1 changed files with 275 additions and 113 deletions
|
|
@ -15,6 +15,7 @@ import (
|
|||
|
||||
"github.com/modelcontextprotocol/registry/tools/publisher/auth"
|
||||
"github.com/modelcontextprotocol/registry/tools/publisher/auth/github"
|
||||
"github.com/modelcontextprotocol/registry/tools/publisher/auth/none"
|
||||
)
|
||||
|
||||
// Server structure types for JSON generation
|
||||
|
|
@ -103,8 +104,8 @@ func publishCommand() error {
|
|||
publishFlags.StringVar(®istryURL, "registry-url", "", "URL of the registry (required)")
|
||||
publishFlags.StringVar(&mcpFilePath, "mcp-file", "", "path to the MCP file (required)")
|
||||
publishFlags.BoolVar(&forceLogin, "login", false, "force a new login even if a token exists")
|
||||
publishFlags.StringVar(&authMethod, "auth-method", "github-oauth",
|
||||
"authentication method to use (default: github-oauth)")
|
||||
publishFlags.StringVar(&authMethod, "auth-method", "github",
|
||||
"authentication method (github for authenticated, none for anonymous) (default: github)")
|
||||
|
||||
// Set custom usage function
|
||||
publishFlags.Usage = func() {
|
||||
|
|
@ -116,7 +117,7 @@ func publishCommand() error {
|
|||
fmt.Fprint(os.Stdout, " --registry-url string URL of the registry (required)\n")
|
||||
fmt.Fprint(os.Stdout, " --mcp-file string path to the MCP file (required)\n")
|
||||
fmt.Fprint(os.Stdout, " --login force a new login even if a token exists\n")
|
||||
fmt.Fprint(os.Stdout, " --auth-method string authentication method to use (default: github-oauth)\n")
|
||||
fmt.Fprint(os.Stdout, " --auth-method string authentication method (github for authenticated, none for anonymous) (default: github)\n")
|
||||
}
|
||||
|
||||
if err := publishFlags.Parse(os.Args[2:]); err != nil {
|
||||
|
|
@ -136,9 +137,12 @@ func publishCommand() error {
|
|||
|
||||
var authProvider auth.Provider // Determine the authentication method
|
||||
switch authMethod {
|
||||
case "github-oauth":
|
||||
case "github":
|
||||
log.Println("Using GitHub OAuth for authentication")
|
||||
authProvider = github.NewOAuthProvider(forceLogin, registryURL)
|
||||
case "none":
|
||||
log.Println("Using anonymous authentication")
|
||||
authProvider = none.NewProvider(registryURL)
|
||||
default:
|
||||
return fmt.Errorf("unsupported authentication method: %s", authMethod)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue