mirror of
https://github.com/supabase/supabase.git
synced 2026-05-09 08:18:16 +08:00
Adds prompt guardrails and evals to prevent the AI assistant from asking users to share sensitive data (API keys, `.env` contents, etc.) and to warn when credentials are shared. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Stronger safety behavior: assistant now refuses requests to share full environment files, asks for variable names only, and directs users to secure secret-management tooling. * Immediate warning and guidance if credentials or other sensitive values are pasted in chat, without repeating exposed secrets. * **Behavior** * Clarified evaluation rules so responses more consistently follow the new safety guidance. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import { createMCPClient } from '@ai-sdk/mcp'
|
|
import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js'
|
|
import { createSupabaseMcpServer } from '@supabase/mcp-server-supabase'
|
|
import { createSupabaseApiPlatform } from '@supabase/mcp-server-supabase/platform/api'
|
|
|
|
import { API_URL } from '@/lib/constants'
|
|
|
|
export async function createSupabaseMCPClient({
|
|
accessToken,
|
|
projectId,
|
|
}: {
|
|
accessToken: string
|
|
projectId: string
|
|
}) {
|
|
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair()
|
|
|
|
// Instantiate the MCP server and connect to its transport
|
|
const apiUrl = API_URL?.replace('/platform', '')
|
|
const server = createSupabaseMcpServer({
|
|
platform: createSupabaseApiPlatform({
|
|
accessToken,
|
|
apiUrl,
|
|
}),
|
|
contentApiUrl: process.env.NEXT_PUBLIC_CONTENT_API_URL,
|
|
projectId,
|
|
readOnly: true,
|
|
})
|
|
await server.connect(serverTransport)
|
|
|
|
// Create the MCP client and connect to its transport
|
|
const client = await createMCPClient({
|
|
name: 'supabase-studio',
|
|
transport: clientTransport,
|
|
})
|
|
|
|
return client
|
|
}
|