-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: Add Accept header to auth metadata request #901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Rebasing to the latest changes. I hope you will consider this small fix as it will do wonders for integration in the SAP ecosystem. |
0845a57 to
c94ba4b
Compare
pcarleton
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change looks good overall!
if you could rebase it, that'd be great. we also just recently did a prettier pass, so hopefully the test change will be less of a formatting monster
src/client/auth.test.ts
Outdated
| expect(options.headers).toEqual({ | ||
| "MCP-Protocol-Version": "2025-01-01" | ||
| "MCP-Protocol-Version": "2025-01-01", | ||
| Accept: "application/json", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: this is the substantive part of the test change (rest of the changes in this file are formatting, we separately need to fix formatting all over so we can stop having them creep into changes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pcarleton Should be rebased now with a little less over-formatting and confusing diffs 😄
|
PR has been rebased and the changes should now be less massive with the formatting fixed |
|
Thanks @SVLaursen ! |
Adds the Accept header of 'application/json' to the auth metadata request for the MCP client.
Reason for this being that in some cases, particularly in the SAP ecosystem, auth services have a default of going to a login page/IDP selection screen if the Accept is '/'.
Motivation and Context
Recently I've been working on getting MCP into the ERP world, particularly the SAP sphere. All apps used in this area are typically deployed to the Business Technology Platform (BTP) where auth systems like XSUAA are used.
Unfortunately with the current implementation of the auth metadata fetcher for the client side, the default logic of the XSUAA service comes into play, as it defaults to a login page when a query against the metadata endpoint is made, unless the requester explicitly asks for the JSON content.
Therefore by asking specifically for the metadata as JSON this problem can be avoided, and seeing as the subsequent logic in the client library also depends on the data received being of JSON format, it would make sense.
How Has This Been Tested?
I tested this using our internal implementation and the client returned the metadata as expected.
Breaking Changes
Not to my knowledge.
Types of changes
Checklist
Additional context