Skip to main content
Glama
Zain4391

Supabase Management API MCP Server

by Zain4391
lists-sql-snippets-for-the-logged-in-user.js2.82 kB
/** * Lists SQL snippets for the logged in user. * * @param {Object} args - Arguments for listing SQL snippets. * @param {string} args.project_ref - Project ref (required). * @param {string} [args.cursor] - Cursor for pagination. * @param {string|number} [args.limit] - Limit for pagination. * @param {string} [args.sort_by] - Field to sort by (e.g., 'name'). * @param {string} [args.sort_order] - Sort order ('asc' or 'desc'). * @returns {Promise<Object>} - The response from the Supabase Management API. */ const listSqlSnippets = async ({ project_ref, cursor, limit, sort_by, sort_order }) => { const baseUrl = 'https://api.supabase.com'; const bearerToken = process.env.SUPABASE_PUBLIC_API_API_KEY; try { if (!project_ref) { throw new Error('project_ref is required'); } const url = new URL(`${baseUrl}/v1/snippets`); url.searchParams.append('project_ref', project_ref); if (cursor) url.searchParams.append('cursor', cursor); if (limit) url.searchParams.append('limit', String(limit)); if (sort_by) url.searchParams.append('sort_by', sort_by); if (sort_order) url.searchParams.append('sort_order', sort_order); const response = await fetch(url.toString(), { method: 'GET', headers: { 'Accept': 'application/json', 'Authorization': `Bearer ${bearerToken}` } }); if (!response.ok) { let err; try { err = await response.json(); } catch { err = await response.text(); } throw new Error(typeof err === 'string' ? err : JSON.stringify(err)); } return await response.json(); } catch (error) { return { error: error instanceof Error ? error.message : JSON.stringify(error) }; } }; /** * Tool definition for listing SQL snippets for the logged in user. */ const apiTool = { function: listSqlSnippets, definition: { type: 'function', function: { name: 'list_sql_snippets', description: 'Lists SQL snippets for the logged in user.', parameters: { type: 'object', properties: { project_ref: { type: 'string', description: 'Project ref (required).' }, cursor: { type: 'string', description: 'Cursor for pagination.' }, limit: { type: ['string', 'integer'], description: 'Limit for pagination.' }, sort_by: { type: 'string', description: 'Field to sort by (e.g., "name").' }, sort_order: { type: 'string', enum: ['asc', 'desc'], description: 'Sort order ("asc" or "desc").' } }, required: ['project_ref'] } } } }; export { apiTool };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Zain4391/Supabase_MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server