Repository navigation
Add Turnstile to login and run MCP on the stateless platform kit - #244
Merged
Merged
Conversation
Login: the hosted login page shows a Cloudflare Turnstile widget when TURNSTILE_SITE_KEY and TURNSTILE_SECRET_KEY are set, and Better Auth's captcha plugin verifies the token on the email-OTP send request. Tokens must be issued for the API's host; Cloudflare's testing secrets skip that check. Setting only one key stops the API from starting. MCP: upgrade the CodeLit platform packages to 0.8.0 and serve MCP through createMcpServerKit. Requests are stateless (no sessions; 2025-era clients still work), tools are data with a risk level that sets the required scope, destructive tools (delete_media, seal_media) need confirm: true, and tool errors are platform errors. x-medialit-apikey still works and is mapped to the kit's X-API-Key. The MCP route parses its own JSON so bad bodies get a JSON-RPC error instead of a 500.
…port CodeQL flags an unanchored regex used on a URL, even in a test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cloudflare Turnstile on login
/oauth/login) shows a Turnstile widget whenTURNSTILE_SITE_KEYandTURNSTILE_SECRET_KEYare set. Off when neither is set; setting only one stops the API from starting.captchaplugin checks the token on/email-otp/send-verification-otp, the request that emails a sign-in code. Tokens must be issued for the API's host (PUBLIC_API_URL); Cloudflare's testing secrets skip that check because they always reportexample.com.@codelitdev/oauth-server-kit0.8.0. The web app is unchanged: login stays in the API.MCP on the stateless platform kit
mcp-server-kit,platform,billing,platform-conformance,observability) and serves MCP throughcreateMcpServerKit, the same way SendLit does. Drops@modelcontextprotocol/sdk1.x and the session map.resolveAuth. Tools are definitions with arisk: read tools needdata:read, the restdata:write(API keys carry both).mcp-session-id, GET/DELETE return 405. 2025-era clients still initialize in stateless mode.delete_mediaandseal_medianeedconfirm: true.update_media_settingsis now a write (idempotent), not destructive.{ code, message, details }.X-API-Keyworks alongsidex-medialit-apikey; both at once iscredential_ambiguous.frontlit/docs/for-agents/mcp-server.mddocumentsconfirm. The integration MCP client is now stateless.Testing
src/__tests__/login-captcha.test.tsandsrc/mcp/__tests__/routes.test.ts(real app, real API key, official MCP client).run-with-local-stack.sh(REST, MCP and CLI integration suites) passes against a fresh stack.data:readtoken is refused write tools withinsufficient_scope.Not tested: the Turnstile hostname check with real keys; it needs a staging host.
Deploy notes
TURNSTILE_SITE_KEYandTURNSTILE_SECRET_KEYon the API.platform-cli doctoralready fails onmain(workflow hash andnextmismatch). This PR doesn't change that;platform-cli synccan follow separately.