@@ -81,6 +81,44 @@ public void SendMessageRequest_CanSerializeRequestHeaders_WithSdkOptions()
8181 Assert . Equal ( "trace-value" , root . GetProperty ( "requestHeaders" ) . GetProperty ( "X-Trace" ) . GetString ( ) ) ;
8282 }
8383
84+ [ Fact ]
85+ public void McpHttpServerConfig_CanSerializeOauthOptions_WithSdkOptions ( )
86+ {
87+ var options = GetSerializerOptions ( ) ;
88+ McpServerConfig original = new McpHttpServerConfig
89+ {
90+ Url = "https://example.com/mcp" ,
91+ Headers = new Dictionary < string , string > { [ "Authorization" ] = "Bearer token" } ,
92+ OauthClientId = "client-id" ,
93+ OauthPublicClient = false ,
94+ OauthGrantType = McpHttpServerConfigOauthGrantType . ClientCredentials ,
95+ Tools = [ "*" ] ,
96+ Timeout = 3000
97+ } ;
98+
99+ var json = JsonSerializer . Serialize ( original , options ) ;
100+ using var document = JsonDocument . Parse ( json ) ;
101+ var root = document . RootElement ;
102+ Assert . Equal ( "http" , root . GetProperty ( "type" ) . GetString ( ) ) ;
103+ Assert . Equal ( "https://example.com/mcp" , root . GetProperty ( "url" ) . GetString ( ) ) ;
104+ Assert . Equal ( "Bearer token" , root . GetProperty ( "headers" ) . GetProperty ( "Authorization" ) . GetString ( ) ) ;
105+ Assert . Equal ( "client-id" , root . GetProperty ( "oauthClientId" ) . GetString ( ) ) ;
106+ Assert . False ( root . GetProperty ( "oauthPublicClient" ) . GetBoolean ( ) ) ;
107+ Assert . Equal ( "client_credentials" , root . GetProperty ( "oauthGrantType" ) . GetString ( ) ) ;
108+ Assert . Equal ( "*" , root . GetProperty ( "tools" ) [ 0 ] . GetString ( ) ) ;
109+ Assert . Equal ( 3000 , root . GetProperty ( "timeout" ) . GetInt32 ( ) ) ;
110+
111+ var deserialized = JsonSerializer . Deserialize < McpServerConfig > ( json , options ) ;
112+ var httpConfig = Assert . IsType < McpHttpServerConfig > ( deserialized ) ;
113+ Assert . Equal ( "https://example.com/mcp" , httpConfig . Url ) ;
114+ Assert . Equal ( "Bearer token" , httpConfig . Headers ! [ "Authorization" ] ) ;
115+ Assert . Equal ( "client-id" , httpConfig . OauthClientId ) ;
116+ Assert . False ( httpConfig . OauthPublicClient ) ;
117+ Assert . Equal ( McpHttpServerConfigOauthGrantType . ClientCredentials , httpConfig . OauthGrantType ) ;
118+ Assert . Equal ( "*" , Assert . Single ( httpConfig . Tools ) ) ;
119+ Assert . Equal ( 3000 , httpConfig . Timeout ) ;
120+ }
121+
84122 private static JsonSerializerOptions GetSerializerOptions ( )
85123 {
86124 var prop = typeof ( CopilotClient )
0 commit comments