Skip to content

Commit 6d3d655

Browse files
rojiCopilot
andcommitted
Align MCP OAuth wrappers with rebased generated APIs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1cd1802 commit 6d3d655

6 files changed

Lines changed: 19 additions & 16 deletions

File tree

dotnet/src/Types.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ public sealed class McpAuthContext
11421142
public string ServerUrl { get; set; } = string.Empty;
11431143

11441144
/// <summary>Parsed WWW-Authenticate parameters from the MCP server, if available.</summary>
1145-
public McpOauthRequiredWwwAuthenticateParams? WwwAuthenticateParams { get; set; }
1145+
public McpOauthWWWAuthenticateParams? WwwAuthenticateParams { get; set; }
11461146

11471147
/// <summary>Raw RFC 9728 protected-resource metadata JSON fetched by the runtime, if available.</summary>
11481148
public string? ResourceMetadata { get; set; }

dotnet/test/Unit/SessionEventSerializationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public class SessionEventSerializationTests
158158
GrantType = "client_credentials",
159159
PublicClient = false,
160160
},
161-
WwwAuthenticateParams = new McpOauthRequiredWwwAuthenticateParams
161+
WwwAuthenticateParams = new McpOauthWWWAuthenticateParams
162162
{
163163
ResourceMetadataUrl = "https://example.com/.well-known/oauth-protected-resource",
164164
},

go/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ func (c *Client) CreateSession(ctx context.Context, config *SessionConfig) (*Ses
850850
session = s
851851
registeredSessionID = localSessionID
852852
if config.OnMCPAuthRequest != nil {
853-
if _, err := c.client.Request("session.eventLog.registerInterest", map[string]any{
853+
if _, err := c.client.Request(ctx, "session.eventLog.registerInterest", map[string]any{
854854
"sessionId": localSessionID,
855855
"eventType": "mcp.oauth_required",
856856
}); err != nil {
@@ -920,7 +920,7 @@ func (c *Client) CreateSession(ctx context.Context, config *SessionConfig) (*Ses
920920
}
921921
// Local IDs registered before create; server-assigned IDs can only register now.
922922
if localSessionID == "" && config.OnMCPAuthRequest != nil {
923-
if _, err := c.client.Request("session.eventLog.registerInterest", map[string]any{
923+
if _, err := c.client.Request(ctx, "session.eventLog.registerInterest", map[string]any{
924924
"sessionId": session.SessionID,
925925
"eventType": "mcp.oauth_required",
926926
}); err != nil {
@@ -1128,7 +1128,7 @@ func (c *Client) ResumeSessionWithOptions(ctx context.Context, sessionID string,
11281128
c.sessions[sessionID] = session
11291129
c.sessionsMux.Unlock()
11301130
if config.OnMCPAuthRequest != nil {
1131-
if _, err := c.client.Request("session.eventLog.registerInterest", map[string]any{
1131+
if _, err := c.client.Request(ctx, "session.eventLog.registerInterest", map[string]any{
11321132
"sessionId": sessionID,
11331133
"eventType": "mcp.oauth_required",
11341134
}); err != nil {

python/copilot/session.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
HandlePendingToolCallRequest,
4141
LogRequest,
4242
MCPOauthHandlePendingRequest,
43-
MCPOauthPendingRequestResponseCancelled,
44-
MCPOauthPendingRequestResponseToken,
43+
MCPOauthPendingRequestResponse,
44+
MCPOauthPendingRequestResponseKind,
4545
ModelSwitchToRequest,
4646
PermissionDecision,
4747
PermissionDecisionApproveOnce,
@@ -1981,14 +1981,17 @@ async def _execute_mcp_auth_and_respond(
19811981
)
19821982

19831983
if result and result.get("kind", "token") == "token":
1984-
rpc_result = MCPOauthPendingRequestResponseToken(
1984+
rpc_result = MCPOauthPendingRequestResponse(
1985+
kind=MCPOauthPendingRequestResponseKind.TOKEN,
19851986
access_token=result["accessToken"],
19861987
expires_in=result.get("expiresIn"),
19871988
refresh_token=result.get("refreshToken"),
19881989
token_type=result.get("tokenType"),
19891990
)
19901991
else:
1991-
rpc_result = MCPOauthPendingRequestResponseCancelled()
1992+
rpc_result = MCPOauthPendingRequestResponse(
1993+
kind=MCPOauthPendingRequestResponseKind.CANCELLED
1994+
)
19921995
await self.rpc.mcp.oauth.handle_pending_request(
19931996
MCPOauthHandlePendingRequest(
19941997
request_id=request_id,
@@ -2000,7 +2003,9 @@ async def _execute_mcp_auth_and_respond(
20002003
await self.rpc.mcp.oauth.handle_pending_request(
20012004
MCPOauthHandlePendingRequest(
20022005
request_id=request_id,
2003-
result=MCPOauthPendingRequestResponseCancelled(),
2006+
result=MCPOauthPendingRequestResponse(
2007+
kind=MCPOauthPendingRequestResponseKind.CANCELLED
2008+
),
20042009
)
20052010
)
20062011
except (JsonRpcError, ProcessExitedError, OSError):

python/test_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from copilot.session import PermissionHandler
3232
from copilot.session_events import (
3333
McpOauthRequiredData,
34-
McpOauthRequiredWwwAuthenticateParams,
34+
McpOauthWWWAuthenticateParams,
3535
SessionEvent,
3636
SessionEventType,
3737
)
@@ -367,7 +367,7 @@ def handle_mcp_auth_request(request, invocation):
367367
request_id="oauth-request",
368368
server_name="oauth-server",
369369
server_url="https://example.com/mcp",
370-
www_authenticate_params=McpOauthRequiredWwwAuthenticateParams(
370+
www_authenticate_params=McpOauthWWWAuthenticateParams(
371371
resource_metadata_url="https://example.com/.well-known/oauth-protected-resource"
372372
),
373373
resource_metadata='{"resource":"https://example.com/mcp"}',

rust/src/handler.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ use crate::generated::api_types::{
2424
McpOauthPendingRequestResponseTokenKind, PermissionDecision, PermissionDecisionApproveOnce,
2525
PermissionDecisionReject, PermissionDecisionUserNotAvailable,
2626
};
27-
use crate::session_events::{
28-
McpOauthRequiredStaticClientConfig, McpOauthRequiredWwwAuthenticateParams,
29-
};
27+
use crate::session_events::{McpOauthRequiredStaticClientConfig, McpOauthWWWAuthenticateParams};
3028
use crate::types::{
3129
ElicitationRequest, ElicitationResult, ExitPlanModeData, PermissionRequestData, RequestId,
3230
SessionId,
@@ -172,7 +170,7 @@ pub struct McpAuthRequest {
172170
/// URL of the MCP server that requires OAuth.
173171
pub server_url: String,
174172
/// Parsed WWW-Authenticate parameters from the MCP server, if available.
175-
pub www_authenticate_params: Option<McpOauthRequiredWwwAuthenticateParams>,
173+
pub www_authenticate_params: Option<McpOauthWWWAuthenticateParams>,
176174
/// Raw RFC 9728 protected-resource metadata JSON fetched by the runtime, if available.
177175
pub resource_metadata: Option<String>,
178176
/// Static OAuth client configuration, if the server specifies one.

0 commit comments

Comments
 (0)