Skip to content

Conversation

@jonathanjma
Copy link
Owner

@jonathanjma jonathanjma commented Jan 16, 2026

Creates 2 new flows for Happiness App MCP Support!

  1. MCP Server + OAuth
    Create MCP server with 2 tools (date range and multi filter search), integrate async Fast MCP server with sync Flask backend, implement OAuth login endpoints for MCP clients to authenticate, add unit tests for MCP and OAuth.

Results in the following high level flow:

1. Claude (MCP client) tries to access /mcp
   ↓
2. MCP server returns 401 with WWW-Authenticate header
   ↓
3. Claude discovers OAuth endpoints via /.well-known/
   ↓
4. Claude redirects user to /api/mcp/oauth/authorize
   ↓
5. User enters username/password in login form
   ↓
6. Server validates credentials (using your existing token system!)
   ↓
7. Server generates authorization code
   ↓
8. Claude exchanges code for access token at /api/mcp/oauth/token
   ↓
9. Server creates session token (using your existing Token.create_token()!)
   ↓
10. Claude uses this session token as Bearer token for all MCP requests
    ↓
11. MCP validates token (using your existing verify_token logic!)
    ↓
12. MCP extracts user_id and queries their data
  1. Discord Linking
    Create endpoints to allow users with a Discord account to link it with their Happiness App account so that they can interact with the Happiness App Discord Bot (which uses MCP with Google Gemini).

Results in the following high level flow:

1. Bot calls POST /api/discord/link (authenticated with a shared secret).
2. Backend returns a link URL to /api/mcp/oauth/authorize with redirect_uri pointing to /api/discord/callback
3. User clicks link, logs in, backend receives OAuth code at /callback and exchanges it for a session token.
4. Bot polls GET /api/discord/poll (authenticated) to fetch the token once.
5. User can ask bot questions about thier happiness data, prompting Gemini and invoking MCP to get user data

@jonathanjma jonathanjma merged commit 929220d into main Jan 16, 2026
1 check passed
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