Skip to content

feat: add TenantExtension auth to MCP endpoint#286

Draft
DK09876 wants to merge 2 commits intomainfrom
MCPAuth
Draft

feat: add TenantExtension auth to MCP endpoint#286
DK09876 wants to merge 2 commits intomainfrom
MCPAuth

Conversation

@DK09876
Copy link
Contributor

@DK09876 DK09876 commented Feb 3, 2026

Summary

  • Replace static MCP_AUTH_TOKEN check with TenantExtension authentication
  • MCP now uses the same auth path as REST API
  • Sets _current_schema from TenantContext for multi-tenant isolation
  • Returns proper 401 on authentication failure

Test plan

  • Unit tests for middleware auth (no auth → 401, wrong key → 401, valid key → passes)
  • Unit test for multi-tenant schema routing
  • Manual curl tests with ApiKeyTenantExtension locally
  • Deploy to dev and verify MCP auth works with CloudTenantExtension

🤖 Generated with Claude Code

DK09876 and others added 2 commits February 4, 2026 10:30
Replace static MCP_AUTH_TOKEN check with TenantExtension authentication,
making MCP use the same auth path as REST API.

- MCPMiddleware now calls tenant_extension.authenticate()
- Sets _current_schema from TenantContext for multi-tenant isolation
- Returns 401 on AuthenticationError (same as REST API)
- DefaultTenantExtension: no auth (local dev)
- ApiKeyTenantExtension: validates against env var
- CloudTenantExtension: HMAC + DB lookup (production)

Adds tests for middleware auth rejection, acceptance, and schema routing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Keep MCP_AUTH_TOKEN env var for legacy MCP servers
- Add authenticate_mcp() method to TenantExtension base class
  - Default implementation calls authenticate()
  - Extensions can override to opt-out of MCP auth
- Add mcp_auth_disabled config option to ApiKeyTenantExtension
  - Set HINDSIGHT_API_TENANT_MCP_AUTH_DISABLED=true to skip MCP auth
- Remove CloudTenantExtension from public docstring
- Add tests for legacy auth token and mcp_auth_disabled flag
- Update MCP docs with new auth configuration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@DK09876 DK09876 marked this pull request as draft February 4, 2026 20:00
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.

2 participants