Skip to content

feat: add secure UUID-based routing with Bearer token auth (fix #2900)#180

Open
gambletan wants to merge 1 commit into
firecrawl:mainfrom
gambletan:fix/2900-secure-mcp-auth
Open

feat: add secure UUID-based routing with Bearer token auth (fix #2900)#180
gambletan wants to merge 1 commit into
firecrawl:mainfrom
gambletan:fix/2900-secure-mcp-auth

Conversation

@gambletan
Copy link
Copy Markdown

@gambletan gambletan commented Mar 8, 2026

Summary

This PR addresses Issue #2900 by adding support for secure authentication to the Firecrawl MCP server.

Changes

  1. Added function - Supports extracting API key ID from headers:

    • header (primary)
    • header (alternative)
  2. Added environment variable - Enables UUID-based routing validation when set

  3. Updated authentication - When is configured:

    • Requests must include the API key ID via header
    • The API key is passed via Bearer token in header
  4. Documentation - Added secure authentication section explaining:

    • How to use Bearer token instead of API key in URL
    • Example curl command
    • Security benefits

Security Improvement

Before (insecure):

https://mcp.firecrawl.dev/{FIRECRAWL_API_KEY}/v2/mcp

After (secure):

curl -X POST https://mcp.firecrawl.dev/v2/mcp   -H "Authorization: Bearer YOUR_FIRECRAWL_API_KEY"   -H "x-api-key-id: YOUR_UUID"

This prevents API keys from being logged in URL paths by proxies, load balancers, and web servers.

Testing

The code compiles successfully. Please review and test the authentication flow.

- Add extractApiKeyId function to support x-api-key-id header
- Add FIRECRAWL_API_KEY_ID env var for UUID-based routing validation
- Update authenticate function to validate API key ID when configured
- Add documentation for secure authentication with Bearer token

This change allows users to:
- Use Bearer token in Authorization header instead of API key in URL
- Optionally use UUID-based routing with x-api-key-id header
- Avoid exposing API keys in URL paths (security best practice)
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.

1 participant