Skip to content

feat: support custom header #549

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

popomore
Copy link

Summary

This PR adds custom header support to the MCP Inspector, allowing users to configure and send custom HTTP headers when connecting to MCP servers. This enhancement improves flexibility for testing servers that require authentication tokens, API keys, or other custom headers.

Ref #249

Motivation and Context

Many MCP servers require custom headers for authentication (e.g., Bearer tokens, API keys) or other configuration purposes. The current inspector lacks the ability to set these headers, making it difficult to test servers that have authentication requirements or need specific header configurations.
This feature addresses the need to:

  • Test MCP servers with authentication requirements
  • Send custom configuration headers
  • Provide a more complete testing environment for real-world MCP server scenarios

Changes Made

  • Added custom header configuration UI components
  • Implemented header management functionality in the connection logic
  • Added TypeScript type definitions for custom headers
  • Created tests for the new header functionality
  • Updated the server connection logic to include custom headers
  • Enhanced the inspector interface to support header input and management

How Has This Been Tested?

  • Tested custom header input and validation in the UI
  • Verified headers are properly sent with MCP server connections
  • Tested with authentication headers (Bearer tokens, API keys)
  • Confirmed backward compatibility with existing connections
  • Validated error handling for invalid header formats
  • Tested header persistence and management functionality

Breaking Changes

No breaking changes - this is a backward-compatible feature addition

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

UI
image

@wickhu
Copy link

wickhu commented Jun 26, 2025

LGTM

1 similar comment
@ZZZZ-WINK
Copy link

LGTM

@olaservo
Copy link
Member

Hi, this older PR is editing a lot of the same UI, so before we move forward with this one, lets wait on this PR to be finalized: #345

If we feel this is urgent and is blocked for too long, we can revisit how to best coordinate these. Thanks for your patience!

@cliffhall
Copy link
Member

cliffhall commented Jul 15, 2025

In the meantime, I don't love the hash in the # Headers accordion pleat. Or the Custom Headers field being a small text field with JSON contents. that would be difficult and error prone to edit. If it just contains the object that represetns all the custom header entries, it seems redundant.

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.

5 participants