Skip to content

Commit 5298f64

Browse files
authored
oauth client example: skip DCR if MCP_CLIENT_ID is set (#549)
If the user has set the MCP_CLIENT_ID environmental variable then they don't want Dynamic Client Registration and it should be skipped.
1 parent 004ca9e commit 5298f64

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

examples/oauth_client/main.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,11 @@ func maybeAuthorize(err error) {
129129
log.Fatalf("Failed to generate state: %v", err)
130130
}
131131

132-
err = oauthHandler.RegisterClient(context.Background(), "mcp-go-oauth-example")
133-
if err != nil {
134-
log.Fatalf("Failed to register client: %v", err)
132+
if oauthHandler.GetClientID() == "" {
133+
err = oauthHandler.RegisterClient(context.Background(), "mcp-go-oauth-example")
134+
if err != nil {
135+
log.Fatalf("Failed to register client: %v", err)
136+
}
135137
}
136138

137139
// Get the authorization URL

0 commit comments

Comments
 (0)