Skip to content

Commit 1b027da

Browse files
Forward OAuth client metadata URL
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 72de60f commit 1b027da

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

rust/src/types.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,12 @@ pub struct SessionConfig {
18601860
/// applied automatically at session creation/resume time. `None` means no
18611861
/// explicit value is set and the runtime default takes effect.
18621862
pub mcp_oauth_token_storage: Option<String>,
1863+
/// URL identifying this host's OAuth client metadata document.
1864+
///
1865+
/// Authorization servers that support client ID metadata documents can use
1866+
/// this URL as the MCP OAuth client ID. Older runtimes ignore this optional
1867+
/// field.
1868+
pub auth_client_id_metadata_url: Option<String>,
18631869
/// Enables runtime discovery of supported configuration. Explicitly supplied
18641870
/// configuration takes precedence over discovered values.
18651871
pub enable_config_discovery: Option<bool>,
@@ -2235,6 +2241,7 @@ impl Default for SessionConfig {
22352241
excluded_builtin_agents: None,
22362242
mcp_servers: None,
22372243
mcp_oauth_token_storage: None,
2244+
auth_client_id_metadata_url: None,
22382245
enable_config_discovery: None,
22392246
skip_embedding_retrieval: None,
22402247
organization_custom_instructions: None,
@@ -2388,6 +2395,7 @@ impl SessionConfig {
23882395
tool_filter_precedence: "excluded",
23892396
mcp_servers: self.mcp_servers,
23902397
mcp_oauth_token_storage: self.mcp_oauth_token_storage,
2398+
auth_client_id_metadata_url: self.auth_client_id_metadata_url,
23912399
embedding_cache_storage: self.embedding_cache_storage,
23922400
env_value_mode: "direct",
23932401
enable_config_discovery: self.enable_config_discovery,
@@ -2715,6 +2723,12 @@ impl SessionConfig {
27152723
self
27162724
}
27172725

2726+
/// Set the URL identifying this host's OAuth client metadata document.
2727+
pub fn with_auth_client_id_metadata_url(mut self, url: impl Into<String>) -> Self {
2728+
self.auth_client_id_metadata_url = Some(url.into());
2729+
self
2730+
}
2731+
27182732
/// Set embedding cache storage mode.
27192733
pub fn with_embedding_cache_storage(
27202734
mut self,
@@ -3101,6 +3115,9 @@ pub struct ResumeSessionConfig {
31013115
/// Controls how MCP OAuth tokens are stored for this session.
31023116
/// See [`SessionConfig::mcp_oauth_token_storage`] for details.
31033117
pub mcp_oauth_token_storage: Option<String>,
3118+
/// Re-supply the host OAuth client metadata document URL on resume.
3119+
/// See [`SessionConfig::auth_client_id_metadata_url`] for details.
3120+
pub auth_client_id_metadata_url: Option<String>,
31043121
/// Enables runtime discovery of supported configuration. Explicitly supplied
31053122
/// configuration takes precedence over discovered values.
31063123
pub enable_config_discovery: Option<bool>,
@@ -3457,6 +3474,7 @@ impl ResumeSessionConfig {
34573474
tool_filter_precedence: "excluded",
34583475
mcp_servers: self.mcp_servers,
34593476
mcp_oauth_token_storage: self.mcp_oauth_token_storage,
3477+
auth_client_id_metadata_url: self.auth_client_id_metadata_url,
34603478
embedding_cache_storage: self.embedding_cache_storage,
34613479
env_value_mode: "direct",
34623480
enable_config_discovery: self.enable_config_discovery,
@@ -3556,6 +3574,7 @@ impl ResumeSessionConfig {
35563574
excluded_builtin_agents: None,
35573575
mcp_servers: None,
35583576
mcp_oauth_token_storage: None,
3577+
auth_client_id_metadata_url: None,
35593578
enable_config_discovery: None,
35603579
skip_embedding_retrieval: None,
35613580
organization_custom_instructions: None,
@@ -3855,6 +3874,12 @@ impl ResumeSessionConfig {
38553874
self
38563875
}
38573876

3877+
/// Set the host OAuth client metadata document URL on resume.
3878+
pub fn with_auth_client_id_metadata_url(mut self, url: impl Into<String>) -> Self {
3879+
self.auth_client_id_metadata_url = Some(url.into());
3880+
self
3881+
}
3882+
38583883
/// Set embedding cache storage mode on resume.
38593884
pub fn with_embedding_cache_storage(
38603885
mut self,
@@ -6375,6 +6400,25 @@ mod tests {
63756400
assert!(empty_json.get("largeOutput").is_none());
63766401
}
63776402

6403+
#[test]
6404+
fn auth_client_id_metadata_url_reaches_create_and_resume_wire_payloads() {
6405+
let url = "https://example.com/oauth/client-metadata.json";
6406+
6407+
let (create_wire, _) = SessionConfig::default()
6408+
.with_auth_client_id_metadata_url(url)
6409+
.into_wire(None)
6410+
.expect("default create has no duplicate handlers");
6411+
let create_json = serde_json::to_value(&create_wire).unwrap();
6412+
assert_eq!(create_json["authClientIdMetadataUrl"], url);
6413+
6414+
let (resume_wire, _) = ResumeSessionConfig::new(SessionId::from("sess-1"))
6415+
.with_auth_client_id_metadata_url(url)
6416+
.into_wire()
6417+
.expect("default resume has no duplicate handlers");
6418+
let resume_json = serde_json::to_value(&resume_wire).unwrap();
6419+
assert_eq!(resume_json["authClientIdMetadataUrl"], url);
6420+
}
6421+
63786422
#[test]
63796423
fn session_config_builder_composes() {
63806424
use indexmap::IndexMap;

rust/src/wire.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ pub(crate) struct SessionCreateWire {
9090
#[serde(skip_serializing_if = "Option::is_none")]
9191
pub mcp_oauth_token_storage: Option<String>,
9292
#[serde(skip_serializing_if = "Option::is_none")]
93+
pub auth_client_id_metadata_url: Option<String>,
94+
#[serde(skip_serializing_if = "Option::is_none")]
9395
pub embedding_cache_storage: Option<String>,
9496
pub env_value_mode: &'static str,
9597
#[serde(skip_serializing_if = "Option::is_none")]
@@ -230,6 +232,8 @@ pub(crate) struct SessionResumeWire {
230232
#[serde(skip_serializing_if = "Option::is_none")]
231233
pub mcp_oauth_token_storage: Option<String>,
232234
#[serde(skip_serializing_if = "Option::is_none")]
235+
pub auth_client_id_metadata_url: Option<String>,
236+
#[serde(skip_serializing_if = "Option::is_none")]
233237
pub embedding_cache_storage: Option<String>,
234238
pub env_value_mode: &'static str,
235239
#[serde(skip_serializing_if = "Option::is_none")]

0 commit comments

Comments
 (0)