Skip to content

Commit 2a6c065

Browse files
committed
Add runningInContainer helper + skip transport auth and OAuth stream when in container
1 parent db5d68d commit 2a6c065

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/gateway/run.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,9 @@ func (g *Gateway) Run(ctx context.Context) error {
260260
return fmt.Errorf("loading configuration: %w", err)
261261
}
262262

263-
if g.McpOAuthDcrEnabled {
263+
// Skip OAuth when running in container mode - Docker Desktop backend socket not available
264+
inContainer := os.Getenv("DOCKER_MCP_IN_CONTAINER") == "1"
265+
if g.McpOAuthDcrEnabled && !inContainer {
264266
// Start OAuth notification monitor to receive OAuth related events from Docker Desktop
265267
log.Log("- Starting OAuth notification monitor")
266268
monitor := oauth.NewNotificationMonitor()
@@ -319,7 +321,7 @@ func (g *Gateway) Run(ctx context.Context) error {
319321
// Initialize authentication token for SSE and streaming modes
320322
// Skip authentication when running in container (DOCKER_MCP_IN_CONTAINER=1)
321323
transport := strings.ToLower(g.Transport)
322-
inContainer := os.Getenv("DOCKER_MCP_IN_CONTAINER") == "1"
324+
inContainer = os.Getenv("DOCKER_MCP_IN_CONTAINER") == "1"
323325
if (transport == "sse" || transport == "http" || transport == "streamable" || transport == "streaming" || transport == "streamable-http") && !inContainer {
324326
token, wasGenerated, err := getOrGenerateAuthToken()
325327
if err != nil {

0 commit comments

Comments
 (0)