Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions crates/rmcp/src/transport/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ impl AuthorizationSession {
mut auth_manager: AuthorizationManager,
scopes: &[&str],
redirect_uri: &str,
client_name: Option<&str>,
) -> Result<Self, AuthError> {
// set redirect uri
let config = OAuthClientConfig {
Expand All @@ -634,7 +635,7 @@ impl AuthorizationSession {

// try to dynamic register client
let config = match auth_manager
.register_client("MCP Client", redirect_uri)
.register_client(client_name.unwrap_or("MCP Client"), redirect_uri)
.await
{
Ok(config) => config,
Expand Down Expand Up @@ -793,6 +794,7 @@ impl OAuthState {
&mut self,
scopes: &[&str],
redirect_uri: &str,
client_name: Option<&str>,
) -> Result<(), AuthError> {
if let OAuthState::Unauthorized(mut manager) = std::mem::replace(
self,
Expand All @@ -802,7 +804,8 @@ impl OAuthState {
let metadata = manager.discover_metadata().await?;
manager.metadata = Some(metadata);
debug!("start session");
let session = AuthorizationSession::new(manager, scopes, redirect_uri).await?;
let session =
AuthorizationSession::new(manager, scopes, redirect_uri, client_name).await?;
*self = OAuthState::Session(session);
Ok(())
} else {
Expand Down
6 changes: 5 additions & 1 deletion examples/clients/src/auth/oauth_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ async fn main() -> Result<()> {
.await
.context("Failed to initialize oauth state machine")?;
oauth_state
.start_authorization(&["mcp", "profile", "email"], MCP_REDIRECT_URI)
.start_authorization(
&["mcp", "profile", "email"],
MCP_REDIRECT_URI,
Some("Test MCP Client"),
)
.await
.context("Failed to start authorization")?;

Expand Down
Loading