Skip to content

Add bearer token/API key auth for MCP endpoints #1906

Description

@karthikchary2606

Problem

MCP endpoints (/mcp/sse, /mcp/message) currently require OAuth2 interactive authentication, making them unsuitable for:

  • Programmatic access (CI/CD, automation, webhooks)
  • Service accounts & API keys
  • Non-browser MCP clients (Claude Code, custom agents, monitoring tools)
  • Enterprise LDAP/SAML deployments (see Discussion How can I use MCP server with ldap auth ? #1496)

Current Limitation

  • Session IDs from SSE handshake are ephemeral and garbage-collected when the stream closes
  • No HTTP-based alternative endpoint
  • No bearer token support
  • No API key support
  • No service account authentication
  • Blocks entire category of programmatic use cases

Requested Solution

Add Spring Security filter chain for /mcp/** endpoints that:

  1. Accept Authorization: Bearer <token> header
  2. Support static API keys or JWT tokens
  3. Keep OAuth2 for main UI endpoints (backward compatible)
  4. Enable LDAP/SAML integration via bearer tokens

Use Cases Enabled

  • Claude MCP integration (Claude Code, Claude UI)
  • CI/CD automation (Jenkins, GitHub Actions, GitLab CI)
  • Monitoring agents (Prometheus exporters, custom collectors)
  • Webhooks and event processors
  • Service-to-service communication
  • Enterprise LDAP/SAML with bearer token delegation

Implementation Details

  • Location: kafka-ui-api/src/main/java/io/kafbat/ui/config/McpAuthSecurityConfig.java (new)
  • Scope: MCP endpoints only (/mcp/**)
  • Backward Compatibility: Full (OAuth2 remains default for UI)
  • Effort: ~2-4 hours
  • Example:
curl -H 'Authorization: Bearer your-api-key' https://kafka-ui/mcp/sse

Why This Matters

MCP (v1.3.0+) is a powerful feature, but without programmatic authentication, it's unusable for automation. Currently:

  • Users must manually extract browser SESSION cookies (hack, not production-ready)
  • Session IDs expire unpredictably (ephemeral architecture)
  • Cannot integrate with Claude AI or other AI agents
  • Blocks enterprise adoption (LDAP users especially)

References

Community Impact

This would:

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/authApp authentication related issuesimpact/apiA PR with changes which affect APIimpact/changelogA PR with changes which should be addressed in the changelog explicitlyimpact/documentationA PR with changes which should be addressed in the documentationscope/backendRelated to backend changestype/enhancementEn enhancement/improvement to an already existing feature

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions