WeKnora/internal/mcp
wizardchen 7f3f219f58 feat(mcp): add OAuth2 authorization for MCP services
Support connecting to MCP servers that require OAuth2, with a Cursor-like
zero-config flow: the user provides only a URL and the system performs
metadata discovery, dynamic client registration (DCR), and the
authorization code flow with PKCE on first connect.

- Persist per-user access/refresh tokens and per-service DCR client
  credentials, encrypted at rest (AES-256-GCM)
- Store the PKCE verifier/state during the flow via Redis with an
  in-memory fallback for Lite mode
- Cache MCP clients per (service, user) so tokens stay user-isolated
- Add endpoints for authorize-url, callback, status, and token revoke;
  the callback is allowlisted for unauthenticated access
- Surface a structured "authorization required" hint when a tool call
  hits an unauthorized MCP service
- Frontend: add an auth-type selector with OAuth config, inline
  authorization status/actions, and render the connection test result
  inline in the editor drawer instead of a stacked centered dialog
2026-06-22 20:19:31 +08:00
..
client.go feat(mcp): add OAuth2 authorization for MCP services 2026-06-22 20:19:31 +08:00
errors.go refactor: Clean up code by removing unnecessary blank lines and improving comments for better readability and maintainability 2025-11-28 16:10:37 +08:00
manager.go feat(mcp): add OAuth2 authorization for MCP services 2026-06-22 20:19:31 +08:00
oauth_manager.go feat(mcp): add OAuth2 authorization for MCP services 2026-06-22 20:19:31 +08:00
oauth_state.go feat(mcp): add OAuth2 authorization for MCP services 2026-06-22 20:19:31 +08:00
oauth_tokenstore.go feat(mcp): add OAuth2 authorization for MCP services 2026-06-22 20:19:31 +08:00
types.go feat: Add MCP services support and enhance migration scripts 2025-11-09 03:27:24 +08:00