diff --git a/packages/client/src/client/auth.ts b/packages/client/src/client/auth.ts index 1a021be18..0391e35e9 100644 --- a/packages/client/src/client/auth.ts +++ b/packages/client/src/client/auth.ts @@ -1439,6 +1439,10 @@ export async function executeTokenRequest( applyClientAuthentication(authMethod, clientInformation as OAuthClientInformation, headers, tokenRequestParams); } + // Ensure Content-Type is always form-urlencoded for the token endpoint (OAuth 2.1 ยง3.2). + // Some addClientAuthentication implementations may have inadvertently set a different value. + headers.set('Content-Type', 'application/x-www-form-urlencoded'); + const response = await (fetchFn ?? fetch)(tokenUrl, { method: 'POST', headers, diff --git a/packages/server/src/server/mcp.ts b/packages/server/src/server/mcp.ts index 4d9f81c50..db0fb73d5 100644 --- a/packages/server/src/server/mcp.ts +++ b/packages/server/src/server/mcp.ts @@ -13,6 +13,7 @@ import type { ListResourcesResult, ListToolsResult, LoggingMessageNotification, + NotificationOptions, Prompt, PromptReference, ReadResourceResult, @@ -973,27 +974,27 @@ export class McpServer { /** * Sends a resource list changed event to the client, if connected. */ - sendResourceListChanged() { + sendResourceListChanged(options?: NotificationOptions) { if (this.isConnected()) { - this.server.sendResourceListChanged(); + this.server.sendResourceListChanged(options); } } /** * Sends a tool list changed event to the client, if connected. */ - sendToolListChanged() { + sendToolListChanged(options?: NotificationOptions) { if (this.isConnected()) { - this.server.sendToolListChanged(); + this.server.sendToolListChanged(options); } } /** * Sends a prompt list changed event to the client, if connected. */ - sendPromptListChanged() { + sendPromptListChanged(options?: NotificationOptions) { if (this.isConnected()) { - this.server.sendPromptListChanged(); + this.server.sendPromptListChanged(options); } } } diff --git a/packages/server/src/server/server.ts b/packages/server/src/server/server.ts index f1a1851f4..102894c3a 100644 --- a/packages/server/src/server/server.ts +++ b/packages/server/src/server/server.ts @@ -660,17 +660,17 @@ export class Server extends Protocol { }); } - async sendResourceListChanged() { + async sendResourceListChanged(options?: NotificationOptions) { return this.notification({ method: 'notifications/resources/list_changed' - }); + }, options); } - async sendToolListChanged() { - return this.notification({ method: 'notifications/tools/list_changed' }); + async sendToolListChanged(options?: NotificationOptions) { + return this.notification({ method: 'notifications/tools/list_changed' }, options); } - async sendPromptListChanged() { - return this.notification({ method: 'notifications/prompts/list_changed' }); + async sendPromptListChanged(options?: NotificationOptions) { + return this.notification({ method: 'notifications/prompts/list_changed' }, options); } }