Skip to content

refactor(grain): rewrite API integration based on official Grain docs#248

Merged
JonasJesus42 merged 2 commits intomainfrom
refactor/grain-mcp-api-and-webhooks
Feb 25, 2026
Merged

refactor(grain): rewrite API integration based on official Grain docs#248
JonasJesus42 merged 2 commits intomainfrom
refactor/grain-mcp-api-and-webhooks

Conversation

@JonasJesus42
Copy link
Contributor

@JonasJesus42 JonasJesus42 commented Feb 25, 2026

  • Fix webhook creation to use correct endpoint (POST //public-api/hooks) with version:2 and view_id (fetched from GET //public-api/views)
  • Replace PostgreSQL binding with direct Supabase client integration
  • Remove OAuth, use MESH_REQUEST_CONTEXT.authorization for API key
  • Add webhook enrichment: fetch full recording details (participants, owners, tags, intelligence notes) from Grain API before indexing
  • Implement multi-field search across title, participants, and AI notes
  • Add dedicated transcript and summary tools with proper API endpoints
  • Handle Grain reachability test on webhook URL creation
  • Update all TypeScript types to match official Grain Personal API
  • Rewrite README in English with correct setup instructions

Summary by cubic

Rewrote the Grain MCP against the official Personal API. Fixes webhook setup, adds Supabase indexing and transcript/summary tools, switches auth to the Mesh API key, and includes small fixes for dev webhook override and search input handling.

  • New Features

    • Creates webhooks via POST /_/public-api/hooks (version: 2) using a recordings view; only creates when missing and passes Grain’s reachability check.
    • Enriches webhook events by fetching full recording details (participants, owners, tags, notes) before upserting into Supabase; search now matches title, participants, and AI notes, and ignores whitespace‑only queries.
    • Adds GET_TRANSCRIPT (json/txt/srt/vtt) and GET_SUMMARY (md/json/text); LIST_RECORDINGS and GET_RECORDING support cursor pagination and selective fields, including include_calendar_id.
    • Emits grain.recording_indexed after a successful index; updated types to match the Personal API.
  • Migration

    • Replace the Postgres binding with Supabase. Set SUPABASE_URL and SUPABASE_ANON_KEY, then run server/db/schema.sql.
    • Use the Grain API key from MESH_REQUEST_CONTEXT.authorization (set the connection’s Token). OAuth was removed.
    • Webhook URL is now {meshUrl}/webhooks/grain/{connectionId}. In dev, set DEVELOPMENT_MODE=true and optionally DEVELOPMENT_WEBHOOK_URL.

Written for commit 5356620. Summary will update on new commits.

- Fix webhook creation to use correct endpoint (POST /_/public-api/hooks)
  with version:2 and view_id (fetched from GET /_/public-api/views)
- Replace PostgreSQL binding with direct Supabase client integration
- Remove OAuth, use MESH_REQUEST_CONTEXT.authorization for API key
- Add webhook enrichment: fetch full recording details (participants,
  owners, tags, intelligence notes) from Grain API before indexing
- Implement multi-field search across title, participants, and AI notes
- Add dedicated transcript and summary tools with proper API endpoints
- Handle Grain reachability test on webhook URL creation
- Update all TypeScript types to match official Grain Personal API
- Rewrite README in English with correct setup instructions

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions
Copy link

github-actions bot commented Feb 25, 2026

🚀 Preview Deployments Ready!

Your changes have been deployed to preview environments:

📦 grain

🔗 View Preview

These previews will be automatically updated with new commits to this PR.


Deployed from commit: 1279233

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 20 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="grain/server/main.ts">

<violation number="1" location="grain/server/main.ts:41">
P2: Honor DEVELOPMENT_WEBHOOK_URL when DEVELOPMENT_MODE=true so the documented dev override works and avoids rebuilding an already-complete webhook URL.</violation>
</file>

<file name="grain/server/tools/search-indexed-recordings.ts">

<violation number="1" location="grain/server/tools/search-indexed-recordings.ts:69">
P2: Treat whitespace-only queries as empty so the guard blocks unfiltered searches. Otherwise a query like "   " bypasses the guard but is ignored by the DB filter, returning all recordings.</violation>
</file>

<file name="grain/server/lib/grain-client.ts">

<violation number="1" location="grain/server/lib/grain-client.ts:133">
P2: `include_calendar_id` is defined in `ListRecordingsParams` but never serialized into query params, so callers can’t request calendar IDs from the API.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

…serialize include_calendar_id

- Use DEVELOPMENT_WEBHOOK_URL env override when DEVELOPMENT_MODE=true
- Treat whitespace-only search queries as empty to prevent unfiltered DB scans
- Serialize include_calendar_id param in listRecordings API call

Co-authored-by: Cursor <cursoragent@cursor.com>
@JonasJesus42 JonasJesus42 merged commit 4fe2b47 into main Feb 25, 2026
4 of 5 checks 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.

1 participant