feat: expose authProvider for HTTP MCP servers to enable OAuth token refresh#6370
Conversation
Add tests to verify that authProvider functionality works correctly: - Accept authProvider field in HTTP server configuration - Handle undefined authProvider gracefully - Maintain backward compatibility for clients without authProvider These tests validate the authProvider exposure added for token refresh capability. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive documentation for the new authProvider option: - OAuth authentication section with usage examples - Configuration reference for authProvider field - Feature list updates to highlight OAuth support - CHANGELOG entry for the new functionality This documents the authProvider functionality that enables automatic token refresh for HTTP-based MCP servers. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
🦋 Changeset detectedLatest commit: df860c9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@PhoebeMay is attempting to deploy a commit to the Mastra Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Greptile Summary
This PR exposes OAuth authentication support for HTTP-based MCP (Model Context Protocol) servers by adding an authProvider field to the client configuration. The implementation adds type-safe OAuth support that's restricted to HTTP servers only (excluding stdio servers), as OAuth authentication is only relevant for HTTP-based connections.
The key changes include:
- Type System Updates: Added
authProvider?: StreamableHTTPClientTransportOptions['authProvider']toHttpServerDefinitionwhile explicitly excluding it fromStdioServerDefinitionwithauthProvider?: never - Transport Integration: Modified the
connectHttpmethod to extract and pass theauthProviderto bothStreamableHTTPClientTransportandSSEClientTransportconstructors - Comprehensive Testing: Added test coverage for authProvider configuration, backward compatibility, and proper exclusion from stdio servers
- Documentation: Updated README with OAuth authentication examples and usage patterns
This change enables automatic token refresh for long-running MCP client connections to HTTP servers that require OAuth authentication, addressing a critical need for production applications that need to maintain authenticated connections over extended periods.
Confidence score: 5/5
- This PR is very safe to merge with minimal risk of production issues
- The implementation follows established patterns, maintains backward compatibility, and includes comprehensive tests
- All files look well-implemented with proper type safety and no apparent issues
3 files reviewed, no comments
wardpeet
left a comment
There was a problem hiding this comment.
LGTM, but @DanielSLew, does this look correct for you?
Summary
Exposes authProvider option for HTTP-based MCP servers to enable OAuth authentication with automatic token refresh.
Changes
Test plan