Skip to content

Conversation

Jeetulsamaiya
Copy link
Contributor

@Jeetulsamaiya Jeetulsamaiya commented Aug 26, 2025

This PR solves this issue:
#756 #750 #549 #249

  • Introduced CustomHeaders component for managing custom headers.
  • Updated Sidebar to include CustomHeaders component.
  • Enhanced useConnection hook to handle custom headers and legacy auth migration.
  • Added tests for custom headers functionality.
  • Updated package.json and package-lock.json for new dependencies.

Motivation and Context

This change addresses the need for flexible authentication and header management in the Inspector UI. Previously, the application only supported a single bearer token with a custom header name. This enhancement allows users to configure multiple custom headers with key-value pairs, providing better support for various authentication schemes and API requirements. The implementation also maintains backward compatibility by automatically migrating existing legacy auth configurations to the new custom headers system.

How Has This Been Tested?

  • Added comprehensive unit tests for the custom headers functionality in useConnection.test.tsx
  • Tested migration from legacy bearer token authentication to custom headers
  • Verified that disabled headers are properly ignored
  • Tested both form-based and JSON-based header configuration modes
  • Ensured backward compatibility with existing authentication configurations
  • Tested the UI components for adding, editing, and removing custom headers

Breaking Changes

No breaking changes. The implementation maintains full backward compatibility with existing bearer token and header name configurations. Legacy auth settings are automatically migrated to the new custom headers format when the application loads.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

The implementation includes:

  • A new CustomHeaders component with both form-based and JSON editor modes
  • Type definitions for custom headers in customHeaders.ts
  • Migration utilities for backward compatibility with legacy auth
  • Enhanced useConnection hook to process multiple headers
  • Server-side support for multiple custom auth headers via x-custom-auth-headers
  • UI improvements with toggle switches for enabling/disabling individual headers
  • Password-style input fields with visibility toggles for sensitive header values

The feature supports both streamable HTTP and SSE transports, allowing users to configure authentication headers for various API endpoints and authentication schemes beyond simple bearer tokens.

Fixes #756
Fixes #750
Fixes #549
Fixes #249

@ColinMcNeil
Copy link

Also related to #549

@Jeetulsamaiya
Copy link
Contributor Author

Screenshot from 2025-08-27 00-22-11 Screenshot from 2025-08-27 00-22-08 Screenshot from 2025-08-27 00-21-51

these are the design screenshots

@alex210501
Copy link
Contributor

I think it would makes sense to also add those configuration field to the mcp.json file too. I'm not strongly familiar with the code, so maybe you already did it and I just did not see it.

- Introduced CustomHeaders component for managing custom headers.
- Updated Sidebar to include CustomHeaders component.
- Enhanced useConnection hook to handle custom headers and legacy auth migration.
- Added tests for custom headers functionality.
- Updated package.json and package-lock.json for new dependencies.
Copy link
Member

@olaservo olaservo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thank you for this PR! I just had a minor comment so far. I wanted to test this locally but don't have a server ready at the moment that requires custom auth headers, so just wanted to leave a note that I'm not ignoring this one while I set up something to test with locally (unless you have a specific server you have been testing this with?)

@Jeetulsamaiya
Copy link
Contributor Author

Hi, thank you for this PR! I just had a minor comment so far. I wanted to test this locally but don't have a server ready at the moment that requires custom auth headers, so just wanted to leave a note that I'm not ignoring this one while I set up something to test with locally (unless you have a specific server you have been testing this with?)

I’ve set up an MCP server at my company, but it’s not deployed to prod and is only accessible on our internal network, so I can’t share the URL for testing.

@ryanchase-cohere
Copy link

Hi @olaservo

Thank you for your support on this! A simple way to test this would be to host an MCP server on Google Cloud Run and make it private because Cloud Run expects a user's google identity token to be sent as the X-Serverless-Authorization header, while the MCP server itself in most cases relies on the Authorization header for custom authorization. https://cloud.google.com/run/docs/authenticating/service-to-service#acquire-token

@ryanchase-cohere
Copy link

Hi @olaservo

Thank you for your support on this! A simple way to test this would be to host an MCP server on Google Cloud Run and make it private because Cloud Run expects a user's google identity token to be sent as the X-Serverless-Authorization header, while the MCP server itself in most cases relies on the Authorization header for custom authorization. https://cloud.google.com/run/docs/authenticating/service-to-service#acquire-token

here's an example: https://cloud.google.com/blog/topics/developers-practitioners/build-and-deploy-a-remote-mcp-server-to-google-cloud-run-in-under-10-minutes

@cliffhall
Copy link
Member

I think it would makes sense to also add those configuration field to the mcp.json file too. I'm not strongly familiar with the code, so maybe you already did it and I just did not see it.

That would be best left for a separate PR. This one is big enough already.

@cliffhall cliffhall mentioned this pull request Sep 12, 2025
9 tasks
@@ -23,6 +23,10 @@ export default tseslint.config(
"warn",
{ allowConstantExport: true },
],
"@typescript-eslint/no-unused-vars": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being added?

@Jeetulsamaiya
Copy link
Contributor Author

@cliffhall Thanks for the suggestion I agree — having Authorization: Bearer as the default makes sense since it’s the most common case, while still giving users the flexibility to customize or add extra headers as needed.

I’ll review the requested changes and ensure everything is addressed. I plan to push an update with this change within the next 2–3 days.

@ramyres110
Copy link

Good morning, I forked and will implement this because or business rule, but, I came here to tag this PR as important, more than others, cause, this is basic for the internet and mcp transport for list with security and personalizations.
For context, my tools list return have difent schemas defined by user informations as authorization and x-locate, x-company, etc.

Thanks all for this!

Jeetulsamaiya and others added 2 commits September 15, 2025 19:30
- Provide "Authorization: Bearer " as default starting header
- Remove legacy auth props from components
- Centralize migration logic and fix localStorage cleanup
- Update tests for new auth architecture
@Jeetulsamaiya
Copy link
Contributor Author

@cliffhall I’ve pushed the update

  • Added Authorization: Bearer <token> as the default header.
  • Addressed the requested changes and ensured everything is correctly applied.
  • Users still have full flexibility to customize or add additional headers.
  • Verified backward compatibility through testing.

Please let me know if you spot anything I may have missed

Copy link
Member

@cliffhall cliffhall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes were made. Tested locally, observed request headers in browser and at the server endpoint.
LGTM! 👍

Request headers in browser

Screenshot 2025-09-15 at 11 52 17 AM

Request headers at server

Screenshot 2025-09-15 at 12 10 00 PM

@cliffhall
Copy link
Member

cliffhall commented Sep 15, 2025

@olaservo You don't necessarily need the server to expect the headers, as long as you can see that they are verifiably sent and received by the server. I did that in my review and everything looks good. Just temporarily added a console.log(req.headers) to the everything server's /mcp POST endpoint.

@cliffhall cliffhall merged commit 4352d32 into modelcontextprotocol:main Sep 15, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
8 participants