-
Notifications
You must be signed in to change notification settings - Fork 698
feat: add HTTP client option to OAuthConfig #616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
It's already possible to customize the underlying client used by the SSE and streamable HTTP transports, but not the OAuth handler. This adds an option to customize the underlying client used by the OAuth handler.
WalkthroughAdds an injectable HTTP client to OAuth by adding Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.go📄 CodeRabbit inference engine (AGENTS.md)
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
client/transport/oauth.go
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go
📄 CodeRabbit inference engine (AGENTS.md)
**/*.go
: Order imports: standard library first, then third-party, then local packages (goimports enforces this)
Follow Go naming conventions: exported identifiers in PascalCase; unexported in camelCase; acronyms uppercase (HTTP, JSON, MCP)
Error handling: return sentinel errors, wrap with fmt.Errorf("context: %w", err), and check with errors.Is/As
Prefer explicit types and strongly-typed structs; avoid using any except where protocol flexibility is required (e.g., Arguments any)
All exported types and functions must have GoDoc comments starting with the identifier name; avoid inline comments unless necessary
Functions that are handlers or long-running must accept context.Context as the first parameter
Ensure thread safety for shared state using sync.Mutex and document thread-safety requirements in comments
For JSON: use json struct tags with omitempty for optional fields; use json.RawMessage for flexible/deferred parsing
Files:
client/transport/oauth.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: test
- GitHub Check: coverage
🔇 Additional comments (1)
client/transport/oauth.go (1)
163-163
: LGTM!The assignment correctly uses the initialized HTTPClient from the config, enabling custom client injection throughout the OAuth handler operations.
if config.HTTPClient == nil { | ||
config.HTTPClient = &http.Client{Timeout: 30 * time.Second} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
LGTM! Verify timeout consistency across transports.
The initialization pattern matches the existing TokenStore setup and properly provides a sensible default. The 30-second timeout is reasonable for OAuth operations.
Since the PR mentions that SSE and streamable HTTP transports also allow client customization, verify that the 30-second default timeout is consistent with those implementations:
🏁 Script executed:
#!/bin/bash
# Description: Check default HTTP client timeouts in other transport implementations
# Search for default HTTP client initialization patterns in transport files
rg -n --type=go -A2 -B2 'http\.Client.*Timeout.*time\.(Second|Minute)' client/transport/
Length of output: 249
🏁 Script executed:
#!/bin/bash
# List all Go files in client/transport to inspect transport implementations
fd -t f -e go client/transport
Length of output: 369
🏁 Script executed:
#!/bin/bash
# List all Go files under client/transport
find client/transport -type f -name '*.go'
# Search for any http.Client default initialization in those files
rg -n --type=go 'http\.Client' client/transport
Length of output: 1467
Add default HTTPClient Timeout to SSE and streamable transports
The SSE (client/transport/sse.go:93) and streamable HTTP (client/transport/streamable_http.go:139) transports use &http.Client{} without a Timeout, causing inconsistent behavior compared to the 30 s default in OAuth transport. Set a default Timeout (e.g., 30 s) in those initializations.
🤖 Prompt for AI Agents
In client/transport/oauth.go around lines 157-159, and apply the same change to
client/transport/sse.go (around line 93) and client/transport/streamable_http.go
(around line 139): the transports currently initialize http.Client without a
Timeout which leads to inconsistent behavior; when creating a default
http.Client, set Timeout: 30 * time.Second (e.g., &http.Client{Timeout: 30 *
time.Second}) so all transports use the same 30s default timeout.
Description
It's already possible to customize the underlying client used by the SSE
and streamable HTTP transports, but not the OAuth handler. This adds
an option to customize the underlying client used by the OAuth handler.
Type of Change
Checklist
MCP Spec Compliance
Additional Information
It's a pretty tiny change and I've tested it out locally.
Summary by CodeRabbit