feat(mcp): MCP server for connecting external AI agents#31
Open
Pycomet wants to merge 1 commit into
Open
Conversation
Lets users connect their own AI agent (Claude Code, Cursor, custom agents) to their GrindProof account over the Model Context Protocol. - Personal access tokens: SHA-256 hashed at rest, shown once, revocable, optional expiry (mcp_tokens table + RLS + fixed-window rate-limit RPC) - RLS preserved for external calls by minting a short-lived HS256 JWT (SUPABASE_JWT_SECRET) so auth.uid() scoping still applies - resolveCredential is the single credential->identity boundary, so OAuth can be layered on later without touching transport or tools - Shared transport-neutral tool registry (specs.ts + AI-SDK/MCP adapters): coach keeps its 10 tools; MCP exposes 16 (adds goal write + check-in logging). sanitizeForPrompt output hardening preserved for both surfaces - Goal/daily-check write logic extracted into src/lib/actions and reused by the tRPC routers (behavior-preserving; accountability side effects kept) - Remote Streamable-HTTP endpoint at /api/mcp/mcp (custom auth wrapper for proper 401 vs 429) + "Connect an agent" settings UI (generate/list/revoke) Migration is not yet applied to Supabase (needs `supabase db push`). SUPABASE_JWT_SECRET must be set in .env.local and Vercel. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ksr7x9xqCDazE3RqjCmcEX
Contributor
|
Deployment failed with the following error: Learn More: https://vercel.link/3Fpeeb1 |
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.
What & why
Lets users connect their own AI agent (Claude Code, Cursor, custom agents) to their GrindProof account over the Model Context Protocol — turning GrindProof into an accountability backend any agent can plug into. v1 uses a personal access token (OAuth is an explicit, layerable v2).
Highlights
mcp_tokenstable + RLS + a lightweight fixed-window rate-limit RPC (no external infra).SUPABASE_JWT_SECRET) soauth.uid()scoping still applies. Defense-in-depth even if a tool forgets auser_idfilter.resolveCredential) so OAuth later touches only that function, not the transport or tools.specs.ts+ AI-SDK / MCP adapters). The in-app coach keeps its 10 tools; MCP exposes 16 (adds goal write + check-in logging). ThesanitizeForPromptoutput hardening now protects both surfaces.src/lib/actions/{goals,daily-checks}.tsand reused by the tRPC routers (behavior-preserving; accountability side effects — carry-over RPC, score recompute, pattern engine — kept)./api/mcp/mcp(the[trpc]route collision forces the nested segment); custom auth wrapper gives proper 401 vs 429.Verification
tscclean · 283 tests pass (34 new, incl. the prompt-injection hardening test) · production build green (/api/mcp/[transport]compiles, settings page prerenders).mcp_tokensnot yet applied (migration pending).Required before it works live
SUPABASE_JWT_SECRET(Supabase → Settings → API → JWT Secret) in.env.localand Vercel (all envs).supabase db push)./api/mcp/mcp; verify cross-user isolation (RLS) and revoke → immediate 401.🤖 Generated with Claude Code
https://claude.ai/code/session_01Ksr7x9xqCDazE3RqjCmcEX