Skip to content

Add support for --header flags in MCP Inspector CLI #716

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 4 commits into
base: main
Choose a base branch
from

Conversation

philfreo
Copy link

@philfreo philfreo commented Aug 14, 2025

Closes #420

Summary

Adds support for (multiple) --header flags to the MCP Inspector CLI, enabling custom HTTP headers for authentication and other purposes.

Changes

  • Add --header option to both wrapper CLI and main CLI with "HeaderName: Value" format validation
  • Pass headers to HTTP and SSE transports via requestInit.headers
  • Fix output truncation issue by removing forced process.exit(0)
  • Update TypeScript types to include headers

Usage

node cli/build/cli.js --cli https://example.com/mcp --transport http --method tools/list --header "Authorization: Bearer token" --header "X-Custom-Header: value"

Testing

  • ✅ Multiple headers parsed correctly
  • ✅ Header format validation works
  • ✅ Headers sent to HTTP/SSE transports
  • ✅ Full JSON output (no truncation)
  • ✅ Works with both wrapper and direct CLI usage

Example Use Case

This enables authentication with MCP servers that require API keys or other custom headers:

node cli/build/cli.js --cli https://mcp.close.com/mcp --transport http --method tools/list --header "Close-API-Key: ${CLOSE_API_KEY}" --header "Close-Scope: mcp.write_safe"

@philfreo philfreo marked this pull request as draft August 14, 2025 15:59
@philfreo philfreo changed the title Add support for multiple --header flags in MCP Inspector CLI Add support for --header flags in MCP Inspector CLI Aug 14, 2025
- Add --header option to both wrapper CLI (cli.ts) and main CLI (index.ts)
- Support multiple headers with "HeaderName: Value" format validation
- Pass headers to HTTP and SSE transports via requestInit.headers
- Add parseHeaderPair function for proper header parsing
- Fix output truncation issue by removing forced process.exit(0)
- Update types to include headers in Args and TransportOptions

Usage: --header "Authorization: Bearer token" --header "X-Custom: value"
@philfreo philfreo force-pushed the feature/add-header-support branch 3 times, most recently from 67f7674 to a2111af Compare August 14, 2025 16:19
- Document --header flag usage with examples
- Explain header format requirements
- Clarify transport support (HTTP, SSE, not STDIO)
- Add authentication examples with API keys and bearer tokens
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.

Feature request: Support configuration of Authentication Header in CLI Mode
1 participant