Skip to content

Conversation

@ruggishop
Copy link
Contributor

@ruggishop ruggishop commented Oct 7, 2025

Summary

This PR adds the ability to specify custom headers to be used in OAuth MCP server calls (e.g. register), defined in the oauth_headers key in the MCP options YAML config.

If that key is present it will be passed to the handler functions, which will include them in the fetch wrapper.

The reason for having a separate key completely outside of the oauth key is to ensure there's no risk of inadvertently storing/caching them as they might contain sensitive data.

Implementation note: a first draft implementation forwarded the main headers values in the OAuth calls instead of getting them from an extra key (the current oauth_headers), but after thinking a bit about it the extra key has a bunch of benefits:

  • it does not leak secrets that may be OAuth-specific
  • the MCP server and the OAuth provider are two separate things, so it makes sense to have split headers

Change Type

Please delete any irrelevant options.

  • New feature (non-breaking change which adds functionality)

Testing

Added automated tests to make sure the headers are correctly passed down the chain.

Checklist

Please delete any irrelevant options.

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes
  • A pull request for updating the documentation has been submitted. (docs: add OAuth headers section LibreChat-AI/librechat.ai#427)

@ruggishop ruggishop force-pushed the feat/custom-headers-mcp-oauth-register branch from e066281 to 75fb68e Compare October 7, 2025 17:26
@nhtruong
Copy link
Contributor

nhtruong commented Oct 7, 2025

This should be accompanied by a doc update for https://github.com/LibreChat-AI/librechat.ai
I cant deduce how to use this feature or how it should behave by looking at the code.

@ruggishop
Copy link
Contributor Author

ruggishop commented Oct 8, 2025

This should be accompanied by a doc update for https://github.com/LibreChat-AI/librechat.ai I cant deduce how to use this feature or how it should behave by looking at the code.

Good point @nhtruong , drafted the docs update in LibreChat-AI/librechat.ai#427

@nhtruong
Copy link
Contributor

nhtruong commented Oct 8, 2025

The code looks good to me.
How does this differ from the headers prop that the mcp config already accepts?
Also I think the example headers in the doc update should be more specific to oauth. X-Custom-Header-1 is too generic.

@ruggishop
Copy link
Contributor Author

The code looks good to me. How does this differ from the headers prop that the mcp config already accepts?

The headers in the MCP config are not sent during the OAuth operations, and they imho should stay separate from them

@ruggishop ruggishop marked this pull request as ready for review October 8, 2025 18:50
@danny-avila danny-avila changed the title feat: custom OAuth headers 📮 feat: Custom OAuth Headers Support for MCP Server Config Oct 11, 2025
@danny-avila danny-avila merged commit 5ce67b5 into danny-avila:dev Oct 11, 2025
7 checks passed
Francistab705 pushed a commit to Francistab705/LibreChat that referenced this pull request Oct 27, 2025
…la#10014)

* add oauth_headers field to mcp options

* wrap fetch to pass oauth headers

* fix order

* consolidate headers passing

* fix tests
JustinBeaudry pushed a commit to Actual-Reality/LibreChat that referenced this pull request Nov 12, 2025
…la#10014)

* add oauth_headers field to mcp options

* wrap fetch to pass oauth headers

* fix order

* consolidate headers passing

* fix tests
Guiraud pushed a commit to Guiraud/LibreChat that referenced this pull request Nov 21, 2025
…la#10014)

* add oauth_headers field to mcp options

* wrap fetch to pass oauth headers

* fix order

* consolidate headers passing

* fix tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants