Deploy GBrain as a serverless remote MCP endpoint on your existing Supabase instance. One brain, accessible from Claude Desktop, Claude Code, Cowork, Perplexity Computer, and any MCP client. Zero new infrastructure. New files: - supabase/functions/gbrain-mcp/index.ts — Edge Function with Hono + MCP SDK - supabase/functions/gbrain-mcp/deno.json — Deno import map - src/edge-entry.ts — curated bundle entry point (excludes fs-dependent modules) - src/commands/auth.ts — standalone token management (create/list/revoke/test) - scripts/deploy-remote.sh — one-script deployment - .env.production.example — 3-value config template Changes: - config.ts: lazy-evaluate CONFIG_DIR (no homedir() at module scope) - schema.sql: add access_tokens + mcp_request_log tables - package.json: add build:edge script Auth: bearer tokens via access_tokens table (SHA-256 hashed, per-client, revocable) Transport: WebStandardStreamableHTTPServerTransport (stateless, Streamable HTTP) Health: /health endpoint (unauth: 200/503, auth: postgres/pgvector/openai checks) Excluded from remote: sync_brain, file_upload (may exceed 60s timeout) Setup: clone, fill .env.production, run scripts/deploy-remote.sh, create token, done. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
68 lines
1.8 KiB
Bash
Executable File
68 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Deploy GBrain Remote MCP Server to Supabase Edge Functions.
|
|
# Prerequisites: .env.production filled in, supabase CLI installed.
|
|
set -e
|
|
|
|
# Check supabase CLI
|
|
if ! command -v supabase >/dev/null 2>&1; then
|
|
echo "Error: supabase CLI not found."
|
|
echo "Install: brew install supabase/tap/supabase"
|
|
echo " or: npm install -g supabase"
|
|
exit 1
|
|
fi
|
|
|
|
# Load env
|
|
if [ ! -f .env.production ]; then
|
|
echo "Error: .env.production not found."
|
|
echo "Copy .env.production.example to .env.production and fill in your values."
|
|
exit 1
|
|
fi
|
|
source .env.production
|
|
|
|
if [ -z "$SUPABASE_PROJECT_REF" ]; then
|
|
echo "Error: SUPABASE_PROJECT_REF not set in .env.production"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Deploying GBrain Remote MCP Server..."
|
|
echo " Project: $SUPABASE_PROJECT_REF"
|
|
echo ""
|
|
|
|
# Link project
|
|
supabase link --project-ref "$SUPABASE_PROJECT_REF"
|
|
|
|
# Set secrets
|
|
supabase secrets set OPENAI_API_KEY="$OPENAI_API_KEY"
|
|
|
|
# Build the Edge Function bundle
|
|
echo ""
|
|
echo "Building Edge Function bundle..."
|
|
bun install
|
|
bun run build:edge
|
|
echo ""
|
|
|
|
# Deploy
|
|
echo "Deploying Edge Function..."
|
|
supabase functions deploy gbrain-mcp --no-verify-jwt
|
|
echo ""
|
|
|
|
# Print success
|
|
URL="https://${SUPABASE_PROJECT_REF}.supabase.co/functions/v1/gbrain-mcp/mcp"
|
|
echo "================================================"
|
|
echo " GBrain Remote MCP Server deployed!"
|
|
echo "================================================"
|
|
echo ""
|
|
echo " URL: $URL"
|
|
echo ""
|
|
echo " Next steps:"
|
|
echo " 1. Create a token:"
|
|
echo " DATABASE_URL=\$DATABASE_URL bun run src/commands/auth.ts create \"my-client\""
|
|
echo ""
|
|
echo " 2. Test it:"
|
|
echo " bun run src/commands/auth.ts test $URL --token <your-token>"
|
|
echo ""
|
|
echo " 3. Add to Claude Code:"
|
|
echo " claude mcp add gbrain -t http $URL -H \"Authorization: Bearer <token>\""
|
|
echo ""
|
|
echo " See docs/mcp/ for per-client setup guides."
|