@supabase/mcp-server-supabase 0.16.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-AQJ4OQXH.js → chunk-BTGEP5EB.js} +4 -4
- package/dist/chunk-BTGEP5EB.js.map +1 -0
- package/dist/chunk-DIWVSO7X.cjs +2 -0
- package/dist/{chunk-2ELO73TX.cjs.map → chunk-DIWVSO7X.cjs.map} +1 -1
- package/dist/chunk-DP5DAOXI.cjs +295 -0
- package/dist/chunk-DP5DAOXI.cjs.map +1 -0
- package/dist/chunk-JIUJWRLL.js +2 -0
- package/dist/{chunk-SG7AFJOS.js.map → chunk-JIUJWRLL.js.map} +1 -1
- package/dist/{chunk-EM7YPWKE.cjs → chunk-TK2UZS5X.cjs} +4 -4
- package/dist/chunk-TK2UZS5X.cjs.map +1 -0
- package/dist/chunk-WOFMZZMH.js +295 -0
- package/dist/chunk-WOFMZZMH.js.map +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -37
- package/dist/index.d.ts +31 -37
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/platform/api-platform.cjs +1 -1
- package/dist/platform/api-platform.js +1 -1
- package/dist/platform/index.d.cts +6 -6
- package/dist/platform/index.d.ts +6 -6
- package/package.json +5 -3
- package/dist/chunk-2ELO73TX.cjs +0 -2
- package/dist/chunk-7LBYXIBL.js +0 -294
- package/dist/chunk-7LBYXIBL.js.map +0 -1
- package/dist/chunk-AQJ4OQXH.js.map +0 -1
- package/dist/chunk-EM7YPWKE.cjs.map +0 -1
- package/dist/chunk-SG7AFJOS.js +0 -2
- package/dist/chunk-YF5MBEBT.cjs +0 -294
- package/dist/chunk-YF5MBEBT.cjs.map +0 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict"; function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var
|
|
2
|
+
"use strict"; function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkDP5DAOXIcjs = require('./chunk-DP5DAOXI.cjs');var _chunkDIWVSO7Xcjs = require('./chunk-DIWVSO7X.cjs');var _chunkTK2UZS5Xcjs = require('./chunk-TK2UZS5X.cjs');require('./chunk-PHWSETKC.cjs');require('./chunk-6FWRABME.cjs');var _util = require('util');var _stdio = require('@modelcontextprotocol/server/stdio');var _crypto = require('crypto');var _events = require('events');var _http = require('http');var _node = require('@modelcontextprotocol/node');var _server = require('@modelcontextprotocol/server');var _v4 = require('zod/v4');function g(r,c=","){return r.split(c).map(t=>t.trim()).filter(t=>t!=="")}var D=_v4.z.object({project_ref:_v4.z.string().optional(),read_only:_v4.z.stringbool().default(!1),experimental_apps:_v4.z.stringbool().default(!1),features:_v4.z.string().transform(r=>g(r)).optional(),skip_elicitations:_v4.z.string().transform(r=>g(r)).optional().pipe(_v4.z.array(_v4.z.enum(_chunkDP5DAOXIcjs.a)).optional())});function Q(r){let c=Array.isArray(r)?r:[r],i,t,l,o;for(let e of c){if(!_server.isJSONRPCRequest.call(void 0, e)&&!_server.isJSONRPCNotification.call(void 0, e))continue;t??=_server.isSpecType.CallToolRequest(e)?`${e.method} ${e.params.name}`:e.method;let n=_optionalChain([e, 'access', _2 => _2.params, 'optionalAccess', _3 => _3._meta]),a=_optionalChain([n, 'optionalAccess', _4 => _4[_server.CLIENT_INFO_META_KEY]]);_server.isSpecType.Implementation(a)&&(i??=a);let s=_optionalChain([n, 'optionalAccess', _5 => _5[_server.PROTOCOL_VERSION_META_KEY]]);if(typeof s=="string"&&(l??=s),_server.isSpecType.InitializeRequest(e))i??=e.params.clientInfo,l??=e.params.protocolVersion,o??=_nullishCoalesce(JSON.stringify(e.params.capabilities.elicitation), () => ("absent"));else if(_server.isSpecType.CallToolRequest(e)&&(e.params.name==="create_edge_function_secret"||_chunkDP5DAOXIcjs.a.includes(e.params.name))){let f=_optionalChain([n, 'optionalAccess', _6 => _6[_server.CLIENT_CAPABILITIES_META_KEY]]);o??=_nullishCoalesce(JSON.stringify(_optionalChain([f, 'optionalAccess', _7 => _7.elicitation])), () => ("absent"))}}let u=i?[i.name,i.version].filter(Boolean).join("/"):"unknown",m=[(_nullishCoalesce(t, () => ("unknown"))).padEnd(28),u.padEnd(24),`(${_nullishCoalesce(l, () => ("legacy"))})`].join(" ");return o===void 0?m:`${m} elicitation=${o}`}async function P({port:r,apiUrl:c,contentApiUrl:i,secretUrlTemplate:t,log:l=o=>console.error(`[${new Date().toLocaleTimeString("en-GB")}] ${o}`)}){let o=_chunkDP5DAOXIcjs.c.call(void 0, c);if(t===void 0)switch(new URL(_nullishCoalesce(c, () => ("https://api.supabase.com"))).origin){case"https://api.supabase.com":case"https://api.supabase.green":t=`${o}/mcp/secrets?ref={ref}&name={name}`;break;default:throw new Error("A custom --api-url requires an explicit --secret-url-template.")}_chunkDP5DAOXIcjs.e.call(void 0, t);let u={connectUrlTemplate:t},m=_crypto.randomBytes.call(void 0, 32),e=_server.localhostAllowedHostnames.call(void 0, ),n=_http.createServer.call(void 0, _node.toNodeHandler.call(void 0, {fetch:async s=>{let f=_server.hostHeaderValidationResponse.call(void 0, s,e);if(f)return f;let d=_optionalChain([s, 'access', _8 => _8.headers, 'access', _9 => _9.get, 'call', _10 => _10("authorization"), 'optionalAccess', _11 => _11.match, 'call', _12 => _12(/^Bearer (.+)$/i), 'optionalAccess', _13 => _13[1]]);if(!d)return Response.json({error:"missing bearer token"},{status:401});let y=new URL(s.url),w=0;for(let h of y.searchParams.keys())if(h==="skip_elicitations"&&w++,w>1||/^skip_elicitations\[[^[\]]*\]/.test(h))return Response.json({error:"skip_elicitations must be a single CSV string"},{status:400});let T=D.safeParse(Object.fromEntries(y.searchParams));if(!T.success)return Response.json({error:_v4.z.prettifyError(T.error)},{status:400});let{project_ref:N,read_only:U,experimental_apps:j,features:k,skip_elicitations:x}=T.data;l(Q(await s.clone().json().catch(()=>{})));let L=_chunkDIWVSO7Xcjs.a.call(void 0, {accessToken:d,apiUrl:c});k&&_chunkDP5DAOXIcjs.d.call(void 0, L,k);let O=_server.createMcpHandler.call(void 0, ()=>_chunkDP5DAOXIcjs.h.call(void 0, {platform:L,projectId:N,readOnly:U,features:k,experimentalApps:j,contentApiUrl:i,dashboardUrl:o,elicitation:{requestState:{key:m,principal:_crypto.createHash.call(void 0, "sha256").update(d).digest("hex")},confirmation:{enabledTools:_chunkDP5DAOXIcjs.a.filter(h=>!_optionalChain([x, 'optionalAccess', _14 => _14.includes, 'call', _15 => _15(h)])),ttlSeconds:600},secretCollection:u&&{...u,ttlSeconds:120}}}),{legacy:"stateless",onerror:console.error});return s.signal.addEventListener("abort",()=>O.close(),{once:!0}),O.fetch(s)}},{onerror:console.error}));n.listen(r,"127.0.0.1"),await _events.once.call(void 0, n,"listening");let a=n.address();if(!a||typeof a=="string")throw new Error("expected a TCP address");return{url:`http://127.0.0.1:${a.port}/mcp`,close:async()=>{n.close(),n.closeAllConnections(),await _events.once.call(void 0, n,"close")}}}var{version:Z}=_chunkTK2UZS5Xcjs.a;async function ee(){let{values:{["access-token"]:r,["project-ref"]:c,["read-only"]:i,["api-url"]:t,["content-api-url"]:l,["secret-url-template"]:o,["version"]:u,["features"]:m,["http"]:e,["port"]:n}}=_util.parseArgs.call(void 0, {options:{"access-token":{type:"string"},"project-ref":{type:"string"},"read-only":{type:"boolean",default:!1},"api-url":{type:"string"},"content-api-url":{type:"string"},"secret-url-template":{type:"string"},version:{type:"boolean"},features:{type:"string"},http:{type:"boolean",default:!1},port:{type:"string",default:"3111"}}});if(u&&(console.log(Z),process.exit(0)),o!==void 0&&!e){console.error("--secret-url-template requires --http."),process.exitCode=1;return}let a=m?g(m):void 0,s=_nullishCoalesce(l, () => (process.env.SUPABASE_CONTENT_API_URL));if(e){try{let y=await P({port:Number(n),apiUrl:t,contentApiUrl:s,secretUrlTemplate:o});console.error(`Supabase MCP server listening on ${y.url}`)}catch(y){console.error(y),process.exitCode=1}return}let f=_nullishCoalesce(r, () => (process.env.SUPABASE_ACCESS_TOKEN));f||(console.error("Please provide a personal access token (PAT) with the --access-token flag or set the SUPABASE_ACCESS_TOKEN environment variable"),process.exit(1));let d=_chunkDIWVSO7Xcjs.a.call(void 0, {accessToken:f,apiUrl:t});a&&_chunkDP5DAOXIcjs.d.call(void 0, d,a),_stdio.serveStdio.call(void 0, ()=>_chunkDP5DAOXIcjs.h.call(void 0, {platform:d,projectId:c,readOnly:i,features:a,contentApiUrl:s,dashboardUrl:_chunkDP5DAOXIcjs.c.call(void 0, t)}),{onerror:console.error})}ee().catch(console.error);
|
|
3
3
|
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/mcp/mcp/packages/mcp-server-supabase/dist/cli.cjs","../src/cli.ts","../src/transports/local-http-entry.ts","../src/transports/util.ts"],"names":["parseList","list","delimiter","feature","querySchema","z","value","CURRENT_ELICITATION_TOOLS","describeRequest","body","messages","client","method","protocolVersion","elicitation","message","isJSONRPCRequest","isJSONRPCNotification","isSpecType"],"mappings":"AAAA;AACA,6qBAAoE,wDAAyC,wDAAyC,gCAA6B,gCAA6B,4BCAtL,2DACC,gCCFa,gCACnB,4BACQ,kDACC,sDAYvB,4BACW,SCVFA,CAAAA,CAAUC,CAAAA,CAAcC,CAAAA,CAAY,GAAA,CAAe,CAEjE,OADcD,CAAAA,CAAK,KAAA,CAAMC,CAAS,CAAA,CAAE,GAAA,CAAKC,CAAAA,EAAYA,CAAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CACtD,MAAA,CAAQA,CAAAA,EAAYA,CAAAA,GAAY,EAAE,CACjD,CDyBA,IAAMC,CAAAA,CAAcC,KAAAA,CAAE,MAAA,CAAO,CAC3B,WAAA,CAAaA,KAAAA,CAAE,MAAA,CAAO,CAAA,CAAE,QAAA,CAAS,CAAA,CACjC,SAAA,CAAWA,KAAAA,CAAE,UAAA,CAAW,CAAA,CAAE,OAAA,CAAQ,CAAA,CAAK,CAAA,CACvC,QAAA,CAAUA,KAAAA,CACP,MAAA,CAAO,CAAA,CACP,SAAA,CAAWC,CAAAA,EAAUN,CAAAA,CAAUM,CAAK,CAAC,CAAA,CACrC,QAAA,CAAS,CAAA,CACZ,iBAAA,CAAmBD,KAAAA,CAChB,MAAA,CAAO,CAAA,CACP,SAAA,CAAWC,CAAAA,EAAUN,CAAAA,CAAUM,CAAK,CAAC,CAAA,CACrC,QAAA,CAAS,CAAA,CACT,IAAA,CAAKD,KAAAA,CAAE,KAAA,CAAMA,KAAAA,CAAE,IAAA,CAAKE,mBAAyB,CAAC,CAAA,CAAE,QAAA,CAAS,CAAC,CAC/D,CAAC,CAAA,CAGM,SAASC,CAAAA,CAAgBC,CAAAA,CAAuB,CACrD,IAAMC,CAAAA,CAAsB,KAAA,CAAM,OAAA,CAAQD,CAAI,CAAA,CAAIA,CAAAA,CAAO,CAACA,CAAI,CAAA,CAC1DE,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACJ,GAAA,CAAA,IAAWC,EAAAA,GAAWL,CAAAA,CAAU,CAC9B,EAAA,CAAI,CAACM,sCAAAA,CAAwB,CAAA,EAAK,CAACC,2CAAAA,CAA6B,CAAA,CAAG,QAAA,CACnEL,CAAAA,GAAWM,kBAAAA,CAAW,eAAA,CAAgBH,CAAO,CAAA,CACzC,CAAA,EAAA","file":"/home/runner/work/mcp/mcp/packages/mcp-server-supabase/dist/cli.cjs","sourcesContent":[null,"#!/usr/bin/env node\nimport { parseArgs } from 'node:util';\nimport { serveStdio } from '@modelcontextprotocol/server/stdio';\n\nimport packageJson from '../package.json' with { type: 'json' };\nimport { createSupabaseApiPlatform } from './platform/api-platform.js';\nimport { createSupabaseMcpServer } from './server.js';\nimport { startLocalHttpEntry } from './transports/local-http-entry.js';\nimport { parseList } from './transports/util.js';\nimport { dashboardUrlForApiUrl, parseFeatureGroups } from './util.js';\n\nconst { version } = packageJson;\n\nasync function main() {\n const {\n values: {\n ['access-token']: cliAccessToken,\n ['project-ref']: projectId,\n ['read-only']: readOnly,\n ['api-url']: apiUrl,\n ['content-api-url']: cliContentApiUrl,\n ['secret-url-template']: secretUrlTemplate,\n ['version']: showVersion,\n ['features']: cliFeatures,\n ['http']: http,\n ['port']: cliPort,\n },\n } = parseArgs({\n options: {\n ['access-token']: {\n type: 'string',\n },\n ['project-ref']: {\n type: 'string',\n },\n ['read-only']: {\n type: 'boolean',\n default: false,\n },\n ['api-url']: {\n type: 'string',\n },\n ['content-api-url']: {\n type: 'string',\n },\n ['secret-url-template']: {\n type: 'string',\n },\n ['version']: {\n type: 'boolean',\n },\n ['features']: {\n type: 'string',\n },\n ['http']: {\n type: 'boolean',\n default: false,\n },\n ['port']: {\n type: 'string',\n default: '3111',\n },\n },\n });\n\n if (showVersion) {\n console.log(version);\n process.exit(0);\n }\n\n if (secretUrlTemplate !== undefined && !http) {\n console.error('--secret-url-template requires --http.');\n process.exitCode = 1;\n return;\n }\n\n const features = cliFeatures ? parseList(cliFeatures) : undefined;\n\n const contentApiUrl =\n cliContentApiUrl ?? process.env.SUPABASE_CONTENT_API_URL;\n\n if (http) {\n try {\n const entry = await startLocalHttpEntry({\n port: Number(cliPort),\n apiUrl,\n contentApiUrl,\n secretUrlTemplate,\n });\n console.error(`Supabase MCP server listening on ${entry.url}`);\n } catch (error) {\n console.error(error);\n process.exitCode = 1;\n }\n return;\n }\n\n const accessToken = cliAccessToken ?? process.env.SUPABASE_ACCESS_TOKEN;\n\n if (!accessToken) {\n console.error(\n 'Please provide a personal access token (PAT) with the --access-token flag or set the SUPABASE_ACCESS_TOKEN environment variable'\n );\n process.exit(1);\n }\n\n const platform = createSupabaseApiPlatform({\n accessToken,\n apiUrl,\n });\n\n if (features) {\n parseFeatureGroups(platform, features);\n }\n\n // `serveStdio` reports transport startup and out-of-band wire errors only\n // through `onerror`, and swallows them otherwise, so this keeps the stderr\n // output the previous awaited `server.connect()` got from `main().catch`.\n serveStdio(\n () =>\n createSupabaseMcpServer({\n platform,\n projectId,\n readOnly,\n features,\n contentApiUrl,\n dashboardUrl: dashboardUrlForApiUrl(apiUrl),\n }),\n { onerror: console.error }\n );\n}\n\nmain().catch(console.error);\n","import { createHash, randomBytes } from 'node:crypto';\nimport { once } from 'node:events';\nimport { createServer } from 'node:http';\nimport { toNodeHandler } from '@modelcontextprotocol/node';\nimport {\n CLIENT_CAPABILITIES_META_KEY,\n CLIENT_INFO_META_KEY,\n createMcpHandler,\n hostHeaderValidationResponse,\n type Implementation,\n isJSONRPCNotification,\n isJSONRPCRequest,\n isSpecType,\n localhostAllowedHostnames,\n PROTOCOL_VERSION_META_KEY,\n} from '@modelcontextprotocol/server';\nimport { z } from 'zod/v4';\n\nimport { createSupabaseApiPlatform } from '../platform/api-platform.js';\nimport { createSupabaseMcpServer } from '../server.js';\nimport { assertValidConnectUrlTemplate } from '../tools/secret-tools.js';\nimport { CURRENT_ELICITATION_TOOLS } from '../types.js';\nimport { dashboardUrlForApiUrl, parseFeatureGroups } from '../util.js';\nimport { parseList } from './util.js';\n\nexport type LocalHttpEntryOptions = {\n port: number;\n apiUrl?: string;\n contentApiUrl?: string;\n secretUrlTemplate?: string;\n log?: (line: string) => void;\n};\n\n// https://supabase.com/docs/guides/ai-tools/mcp#configuration-options\nconst querySchema = z.object({\n project_ref: z.string().optional(),\n read_only: z.stringbool().default(false),\n features: z\n .string()\n .transform((value) => parseList(value))\n .optional(),\n skip_elicitations: z\n .string()\n .transform((value) => parseList(value))\n .optional()\n .pipe(z.array(z.enum(CURRENT_ELICITATION_TOOLS)).optional()),\n});\n\n/** e.g. `tools/call create_branch claude-code/2.1.260 (2026-07-28)` */\nexport function describeRequest(body: unknown): string {\n const messages: unknown[] = Array.isArray(body) ? body : [body];\n let client: Implementation | undefined;\n let method: string | undefined;\n let protocolVersion: string | undefined;\n let elicitation: string | undefined;\n for (const message of messages) {\n if (!isJSONRPCRequest(message) && !isJSONRPCNotification(message)) continue;\n method ??= isSpecType.CallToolRequest(message)\n ? `${message.method} ${message.params.name}`\n : message.method;\n const meta = message.params?._meta;\n const metaClient = meta?.[CLIENT_INFO_META_KEY];\n if (isSpecType.Implementation(metaClient)) client ??= metaClient;\n const metaVersion = meta?.[PROTOCOL_VERSION_META_KEY];\n if (typeof metaVersion === 'string') protocolVersion ??= metaVersion;\n if (isSpecType.InitializeRequest(message)) {\n client ??= message.params.clientInfo;\n protocolVersion ??= message.params.protocolVersion;\n elicitation ??=\n JSON.stringify(message.params.capabilities.elicitation) ?? 'absent';\n } else if (\n isSpecType.CallToolRequest(message) &&\n (message.params.name === 'create_edge_function_secret' ||\n (CURRENT_ELICITATION_TOOLS as readonly string[]).includes(\n message.params.name\n ))\n ) {\n const capabilities = meta?.[CLIENT_CAPABILITIES_META_KEY] as\n | { elicitation?: unknown }\n | undefined;\n elicitation ??= JSON.stringify(capabilities?.elicitation) ?? 'absent';\n }\n }\n const name = client\n ? [client.name, client.version].filter(Boolean).join('/')\n : 'unknown';\n const description = [\n (method ?? 'unknown').padEnd(28),\n name.padEnd(24),\n `(${protocolVersion ?? 'legacy'})`,\n ].join(' ');\n return elicitation === undefined\n ? description\n : `${description} elicitation=${elicitation}`;\n}\n\nexport async function startLocalHttpEntry({\n port,\n apiUrl,\n contentApiUrl,\n secretUrlTemplate,\n log = (line) =>\n console.error(`[${new Date().toLocaleTimeString('en-GB')}] ${line}`),\n}: LocalHttpEntryOptions) {\n const dashboardUrl = dashboardUrlForApiUrl(apiUrl);\n if (secretUrlTemplate === undefined) {\n switch (new URL(apiUrl ?? 'https://api.supabase.com').origin) {\n case 'https://api.supabase.com':\n case 'https://api.supabase.green':\n secretUrlTemplate = `${dashboardUrl}/mcp/secrets?ref={ref}&name={name}`;\n break;\n default:\n throw new Error(\n 'A custom --api-url requires an explicit --secret-url-template.'\n );\n }\n }\n assertValidConnectUrlTemplate(secretUrlTemplate);\n const secretCollection = { connectUrlTemplate: secretUrlTemplate };\n const requestStateKey = randomBytes(32);\n const allowedHostnames = localhostAllowedHostnames();\n\n const server = createServer(\n toNodeHandler(\n {\n fetch: async (request) => {\n const rejected = hostHeaderValidationResponse(\n request,\n allowedHostnames\n );\n if (rejected) return rejected;\n\n const accessToken = request.headers\n .get('authorization')\n ?.match(/^Bearer (.+)$/i)?.[1];\n if (!accessToken) {\n return Response.json(\n { error: 'missing bearer token' },\n { status: 401 }\n );\n }\n\n const url = new URL(request.url);\n // Hosted query parsing turns repeated or bracketed skips into\n // non-string values. Reject those before flattening query parameters.\n let skipCount = 0;\n for (const key of url.searchParams.keys()) {\n if (key === 'skip_elicitations') skipCount++;\n if (skipCount > 1 || /^skip_elicitations\\[[^[\\]]*\\]/.test(key)) {\n return Response.json(\n { error: 'skip_elicitations must be a single CSV string' },\n { status: 400 }\n );\n }\n }\n const query = querySchema.safeParse(\n Object.fromEntries(url.searchParams)\n );\n if (!query.success) {\n return Response.json(\n { error: z.prettifyError(query.error) },\n { status: 400 }\n );\n }\n const {\n project_ref: projectId,\n read_only: readOnly,\n features,\n skip_elicitations: skipElicitations,\n } = query.data;\n\n log(\n describeRequest(\n await request\n .clone()\n .json()\n .catch(() => undefined)\n )\n );\n\n const platform = createSupabaseApiPlatform({ accessToken, apiUrl });\n if (features) parseFeatureGroups(platform, features);\n const handler = createMcpHandler(\n () =>\n createSupabaseMcpServer({\n platform,\n projectId,\n readOnly,\n features,\n contentApiUrl,\n dashboardUrl,\n elicitation: {\n requestState: {\n key: requestStateKey,\n ttlSeconds: 120,\n // One process can serve several PATs, so the principal is the token's hash.\n principal: createHash('sha256')\n .update(accessToken)\n .digest('hex'),\n },\n confirmation: {\n enabledTools: CURRENT_ELICITATION_TOOLS.filter(\n (tool) => !skipElicitations?.includes(tool)\n ),\n },\n secretCollection,\n },\n }),\n { legacy: 'stateless', onerror: console.error }\n );\n request.signal.addEventListener('abort', () => handler.close(), {\n once: true,\n });\n return handler.fetch(request);\n },\n },\n { onerror: console.error }\n )\n );\n\n server.listen(port, '127.0.0.1');\n await once(server, 'listening');\n const address = server.address();\n if (!address || typeof address === 'string') {\n throw new Error('expected a TCP address');\n }\n\n return {\n url: `http://127.0.0.1:${address.port}/mcp`,\n close: async () => {\n server.close();\n server.closeAllConnections();\n await once(server, 'close');\n },\n };\n}\n\nexport type LocalHttpEntry = Awaited<ReturnType<typeof startLocalHttpEntry>>;\n","/**\n * Parses a delimited list of items into an array,\n * trimming whitespace and filtering out empty items.\n *\n * Default delimiter is a comma (`,`).\n */\nexport function parseList(list: string, delimiter = ','): string[] {\n const items = list.split(delimiter).map((feature) => feature.trim());\n return items.filter((feature) => feature !== '');\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/mcp/mcp/packages/mcp-server-supabase/dist/cli.cjs","../src/cli.ts","../src/transports/local-http-entry.ts","../src/transports/util.ts"],"names":["parseList","list","delimiter","feature","querySchema","z","value","CURRENT_ELICITATION_TOOLS","describeRequest","body","messages","client","method","protocolVersion","elicitation","message","isJSONRPCRequest","isJSONRPCNotification","isSpecType"],"mappings":"AAAA;AACA,6qBAAoE,wDAAyC,wDAAyC,gCAA6B,gCAA6B,4BCAtL,2DACC,gCCFa,gCACnB,4BACQ,kDACC,sDAYvB,4BACW,SCVFA,CAAAA,CAAUC,CAAAA,CAAcC,CAAAA,CAAY,GAAA,CAAe,CAEjE,OADcD,CAAAA,CAAK,KAAA,CAAMC,CAAS,CAAA,CAAE,GAAA,CAAKC,CAAAA,EAAYA,CAAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CACtD,MAAA,CAAQA,CAAAA,EAAYA,CAAAA,GAAY,EAAE,CACjD,CDyBA,IAAMC,CAAAA,CAAcC,KAAAA,CAAE,MAAA,CAAO,CAC3B,WAAA,CAAaA,KAAAA,CAAE,MAAA,CAAO,CAAA,CAAE,QAAA,CAAS,CAAA,CACjC,SAAA,CAAWA,KAAAA,CAAE,UAAA,CAAW,CAAA,CAAE,OAAA,CAAQ,CAAA,CAAK,CAAA,CACvC,iBAAA,CAAmBA,KAAAA,CAAE,UAAA,CAAW,CAAA,CAAE,OAAA,CAAQ,CAAA,CAAK,CAAA,CAC/C,QAAA,CAAUA,KAAAA,CACP,MAAA,CAAO,CAAA,CACP,SAAA,CAAWC,CAAAA,EAAUN,CAAAA,CAAUM,CAAK,CAAC,CAAA,CACrC,QAAA,CAAS,CAAA,CACZ,iBAAA,CAAmBD,KAAAA,CAChB,MAAA,CAAO,CAAA,CACP,SAAA,CAAWC,CAAAA,EAAUN,CAAAA,CAAUM,CAAK,CAAC,CAAA,CACrC,QAAA,CAAS,CAAA,CACT,IAAA,CAAKD,KAAAA,CAAE,KAAA,CAAMA,KAAAA,CAAE,IAAA,CAAKE,mBAAyB,CAAC,CAAA,CAAE,QAAA,CAAS,CAAC,CAC/D,CAAC,CAAA,CAGM,SAASC,CAAAA,CAAgBC,CAAAA,CAAuB,CACrD,IAAMC,CAAAA,CAAsB,KAAA,CAAM,OAAA,CAAQD,CAAI,CAAA,CAAIA,CAAAA,CAAO,CAACA,CAAI,CAAA,CAC1DE,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACJ,GAAA,CAAA,IAAWC,EAAAA,GAAWL,CAAAA,CAAU,CAC9B,EAAA,CAAI,CAACM,sCAAAA,CAAwB,CAAA,EAAK,CAACC,2CAAAA,CAA6B,CAAA,CAAG,QAAA,CACnEL,CAAAA,GAAWM,kBAAAA,CAAW,eAAA,CAAgBH,CAAO,CAAA,CACzC,CAAA,EAAA","file":"/home/runner/work/mcp/mcp/packages/mcp-server-supabase/dist/cli.cjs","sourcesContent":[null,"#!/usr/bin/env node\nimport { parseArgs } from 'node:util';\nimport { serveStdio } from '@modelcontextprotocol/server/stdio';\n\nimport packageJson from '../package.json' with { type: 'json' };\nimport { createSupabaseApiPlatform } from './platform/api-platform.js';\nimport { createSupabaseMcpServer } from './server.js';\nimport { startLocalHttpEntry } from './transports/local-http-entry.js';\nimport { parseList } from './transports/util.js';\nimport { dashboardUrlForApiUrl, parseFeatureGroups } from './util.js';\n\nconst { version } = packageJson;\n\nasync function main() {\n const {\n values: {\n ['access-token']: cliAccessToken,\n ['project-ref']: projectId,\n ['read-only']: readOnly,\n ['api-url']: apiUrl,\n ['content-api-url']: cliContentApiUrl,\n ['secret-url-template']: secretUrlTemplate,\n ['version']: showVersion,\n ['features']: cliFeatures,\n ['http']: http,\n ['port']: cliPort,\n },\n } = parseArgs({\n options: {\n ['access-token']: {\n type: 'string',\n },\n ['project-ref']: {\n type: 'string',\n },\n ['read-only']: {\n type: 'boolean',\n default: false,\n },\n ['api-url']: {\n type: 'string',\n },\n ['content-api-url']: {\n type: 'string',\n },\n ['secret-url-template']: {\n type: 'string',\n },\n ['version']: {\n type: 'boolean',\n },\n ['features']: {\n type: 'string',\n },\n ['http']: {\n type: 'boolean',\n default: false,\n },\n ['port']: {\n type: 'string',\n default: '3111',\n },\n },\n });\n\n if (showVersion) {\n console.log(version);\n process.exit(0);\n }\n\n if (secretUrlTemplate !== undefined && !http) {\n console.error('--secret-url-template requires --http.');\n process.exitCode = 1;\n return;\n }\n\n const features = cliFeatures ? parseList(cliFeatures) : undefined;\n\n const contentApiUrl =\n cliContentApiUrl ?? process.env.SUPABASE_CONTENT_API_URL;\n\n if (http) {\n try {\n const entry = await startLocalHttpEntry({\n port: Number(cliPort),\n apiUrl,\n contentApiUrl,\n secretUrlTemplate,\n });\n console.error(`Supabase MCP server listening on ${entry.url}`);\n } catch (error) {\n console.error(error);\n process.exitCode = 1;\n }\n return;\n }\n\n const accessToken = cliAccessToken ?? process.env.SUPABASE_ACCESS_TOKEN;\n\n if (!accessToken) {\n console.error(\n 'Please provide a personal access token (PAT) with the --access-token flag or set the SUPABASE_ACCESS_TOKEN environment variable'\n );\n process.exit(1);\n }\n\n const platform = createSupabaseApiPlatform({\n accessToken,\n apiUrl,\n });\n\n if (features) {\n parseFeatureGroups(platform, features);\n }\n\n // `serveStdio` reports transport startup and out-of-band wire errors only\n // through `onerror`, and swallows them otherwise, so this keeps the stderr\n // output the previous awaited `server.connect()` got from `main().catch`.\n serveStdio(\n () =>\n createSupabaseMcpServer({\n platform,\n projectId,\n readOnly,\n features,\n contentApiUrl,\n dashboardUrl: dashboardUrlForApiUrl(apiUrl),\n }),\n { onerror: console.error }\n );\n}\n\nmain().catch(console.error);\n","import { createHash, randomBytes } from 'node:crypto';\nimport { once } from 'node:events';\nimport { createServer } from 'node:http';\nimport { toNodeHandler } from '@modelcontextprotocol/node';\nimport {\n CLIENT_CAPABILITIES_META_KEY,\n CLIENT_INFO_META_KEY,\n createMcpHandler,\n hostHeaderValidationResponse,\n type Implementation,\n isJSONRPCNotification,\n isJSONRPCRequest,\n isSpecType,\n localhostAllowedHostnames,\n PROTOCOL_VERSION_META_KEY,\n} from '@modelcontextprotocol/server';\nimport { z } from 'zod/v4';\n\nimport { createSupabaseApiPlatform } from '../platform/api-platform.js';\nimport { createSupabaseMcpServer } from '../server.js';\nimport { assertValidConnectUrlTemplate } from '../tools/secret-tools.js';\nimport { CURRENT_ELICITATION_TOOLS } from '../types.js';\nimport { dashboardUrlForApiUrl, parseFeatureGroups } from '../util.js';\nimport { parseList } from './util.js';\n\nexport type LocalHttpEntryOptions = {\n port: number;\n apiUrl?: string;\n contentApiUrl?: string;\n secretUrlTemplate?: string;\n log?: (line: string) => void;\n};\n\n// https://supabase.com/docs/guides/ai-tools/mcp#configuration-options\nconst querySchema = z.object({\n project_ref: z.string().optional(),\n read_only: z.stringbool().default(false),\n experimental_apps: z.stringbool().default(false),\n features: z\n .string()\n .transform((value) => parseList(value))\n .optional(),\n skip_elicitations: z\n .string()\n .transform((value) => parseList(value))\n .optional()\n .pipe(z.array(z.enum(CURRENT_ELICITATION_TOOLS)).optional()),\n});\n\n/** e.g. `tools/call create_branch claude-code/2.1.260 (2026-07-28)` */\nexport function describeRequest(body: unknown): string {\n const messages: unknown[] = Array.isArray(body) ? body : [body];\n let client: Implementation | undefined;\n let method: string | undefined;\n let protocolVersion: string | undefined;\n let elicitation: string | undefined;\n for (const message of messages) {\n if (!isJSONRPCRequest(message) && !isJSONRPCNotification(message)) continue;\n method ??= isSpecType.CallToolRequest(message)\n ? `${message.method} ${message.params.name}`\n : message.method;\n const meta = message.params?._meta;\n const metaClient = meta?.[CLIENT_INFO_META_KEY];\n if (isSpecType.Implementation(metaClient)) client ??= metaClient;\n const metaVersion = meta?.[PROTOCOL_VERSION_META_KEY];\n if (typeof metaVersion === 'string') protocolVersion ??= metaVersion;\n if (isSpecType.InitializeRequest(message)) {\n client ??= message.params.clientInfo;\n protocolVersion ??= message.params.protocolVersion;\n elicitation ??=\n JSON.stringify(message.params.capabilities.elicitation) ?? 'absent';\n } else if (\n isSpecType.CallToolRequest(message) &&\n (message.params.name === 'create_edge_function_secret' ||\n (CURRENT_ELICITATION_TOOLS as readonly string[]).includes(\n message.params.name\n ))\n ) {\n const capabilities = meta?.[CLIENT_CAPABILITIES_META_KEY] as\n | { elicitation?: unknown }\n | undefined;\n elicitation ??= JSON.stringify(capabilities?.elicitation) ?? 'absent';\n }\n }\n const name = client\n ? [client.name, client.version].filter(Boolean).join('/')\n : 'unknown';\n const description = [\n (method ?? 'unknown').padEnd(28),\n name.padEnd(24),\n `(${protocolVersion ?? 'legacy'})`,\n ].join(' ');\n return elicitation === undefined\n ? description\n : `${description} elicitation=${elicitation}`;\n}\n\nexport async function startLocalHttpEntry({\n port,\n apiUrl,\n contentApiUrl,\n secretUrlTemplate,\n log = (line) =>\n console.error(`[${new Date().toLocaleTimeString('en-GB')}] ${line}`),\n}: LocalHttpEntryOptions) {\n const dashboardUrl = dashboardUrlForApiUrl(apiUrl);\n if (secretUrlTemplate === undefined) {\n switch (new URL(apiUrl ?? 'https://api.supabase.com').origin) {\n case 'https://api.supabase.com':\n case 'https://api.supabase.green':\n secretUrlTemplate = `${dashboardUrl}/mcp/secrets?ref={ref}&name={name}`;\n break;\n default:\n throw new Error(\n 'A custom --api-url requires an explicit --secret-url-template.'\n );\n }\n }\n assertValidConnectUrlTemplate(secretUrlTemplate);\n const secretCollection = { connectUrlTemplate: secretUrlTemplate };\n const requestStateKey = randomBytes(32);\n const allowedHostnames = localhostAllowedHostnames();\n\n const server = createServer(\n toNodeHandler(\n {\n fetch: async (request) => {\n const rejected = hostHeaderValidationResponse(\n request,\n allowedHostnames\n );\n if (rejected) return rejected;\n\n const accessToken = request.headers\n .get('authorization')\n ?.match(/^Bearer (.+)$/i)?.[1];\n if (!accessToken) {\n return Response.json(\n { error: 'missing bearer token' },\n { status: 401 }\n );\n }\n\n const url = new URL(request.url);\n // Hosted query parsing turns repeated or bracketed skips into\n // non-string values. Reject those before flattening query parameters.\n let skipCount = 0;\n for (const key of url.searchParams.keys()) {\n if (key === 'skip_elicitations') skipCount++;\n if (skipCount > 1 || /^skip_elicitations\\[[^[\\]]*\\]/.test(key)) {\n return Response.json(\n { error: 'skip_elicitations must be a single CSV string' },\n { status: 400 }\n );\n }\n }\n const query = querySchema.safeParse(\n Object.fromEntries(url.searchParams)\n );\n if (!query.success) {\n return Response.json(\n { error: z.prettifyError(query.error) },\n { status: 400 }\n );\n }\n const {\n project_ref: projectId,\n read_only: readOnly,\n experimental_apps: experimentalApps,\n features,\n skip_elicitations: skipElicitations,\n } = query.data;\n\n log(\n describeRequest(\n await request\n .clone()\n .json()\n .catch(() => undefined)\n )\n );\n\n const platform = createSupabaseApiPlatform({ accessToken, apiUrl });\n if (features) parseFeatureGroups(platform, features);\n const handler = createMcpHandler(\n () =>\n createSupabaseMcpServer({\n platform,\n projectId,\n readOnly,\n features,\n experimentalApps,\n contentApiUrl,\n dashboardUrl,\n elicitation: {\n requestState: {\n key: requestStateKey,\n // One process can serve several PATs, so the principal is the token's hash.\n principal: createHash('sha256')\n .update(accessToken)\n .digest('hex'),\n },\n confirmation: {\n enabledTools: CURRENT_ELICITATION_TOOLS.filter(\n (tool) => !skipElicitations?.includes(tool)\n ),\n ttlSeconds: 600,\n },\n secretCollection: secretCollection && {\n ...secretCollection,\n ttlSeconds: 120,\n },\n },\n }),\n { legacy: 'stateless', onerror: console.error }\n );\n request.signal.addEventListener('abort', () => handler.close(), {\n once: true,\n });\n return handler.fetch(request);\n },\n },\n { onerror: console.error }\n )\n );\n\n server.listen(port, '127.0.0.1');\n await once(server, 'listening');\n const address = server.address();\n if (!address || typeof address === 'string') {\n throw new Error('expected a TCP address');\n }\n\n return {\n url: `http://127.0.0.1:${address.port}/mcp`,\n close: async () => {\n server.close();\n server.closeAllConnections();\n await once(server, 'close');\n },\n };\n}\n\nexport type LocalHttpEntry = Awaited<ReturnType<typeof startLocalHttpEntry>>;\n","/**\n * Parses a delimited list of items into an array,\n * trimming whitespace and filtering out empty items.\n *\n * Default delimiter is a comma (`,`).\n */\nexport function parseList(list: string, delimiter = ','): string[] {\n const items = list.split(delimiter).map((feature) => feature.trim());\n return items.filter((feature) => feature !== '');\n}\n"]}
|
package/dist/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as S,c as
|
|
2
|
+
import{a as S,c as _,d as A,e as R,h as b}from"./chunk-WOFMZZMH.js";import{a as E}from"./chunk-JIUJWRLL.js";import{a as v}from"./chunk-BTGEP5EB.js";import"./chunk-LU6L7C36.js";import"./chunk-LL3YUIO5.js";import{parseArgs as W}from"util";import{serveStdio as X}from"@modelcontextprotocol/server/stdio";import{createHash as H,randomBytes as $}from"crypto";import{once as I}from"events";import{createServer as B}from"http";import{toNodeHandler as V}from"@modelcontextprotocol/node";import{CLIENT_CAPABILITIES_META_KEY as M,CLIENT_INFO_META_KEY as q,createMcpHandler as F,hostHeaderValidationResponse as K,isJSONRPCNotification as J,isJSONRPCRequest as z,isSpecType as C,localhostAllowedHostnames as G,PROTOCOL_VERSION_META_KEY as Y}from"@modelcontextprotocol/server";import{z as p}from"zod/v4";function g(r,c=","){return r.split(c).map(t=>t.trim()).filter(t=>t!=="")}var D=p.object({project_ref:p.string().optional(),read_only:p.stringbool().default(!1),experimental_apps:p.stringbool().default(!1),features:p.string().transform(r=>g(r)).optional(),skip_elicitations:p.string().transform(r=>g(r)).optional().pipe(p.array(p.enum(S)).optional())});function Q(r){let c=Array.isArray(r)?r:[r],i,t,l,o;for(let e of c){if(!z(e)&&!J(e))continue;t??=C.CallToolRequest(e)?`${e.method} ${e.params.name}`:e.method;let n=e.params?._meta,a=n?.[q];C.Implementation(a)&&(i??=a);let s=n?.[Y];if(typeof s=="string"&&(l??=s),C.InitializeRequest(e))i??=e.params.clientInfo,l??=e.params.protocolVersion,o??=JSON.stringify(e.params.capabilities.elicitation)??"absent";else if(C.CallToolRequest(e)&&(e.params.name==="create_edge_function_secret"||S.includes(e.params.name))){let f=n?.[M];o??=JSON.stringify(f?.elicitation)??"absent"}}let u=i?[i.name,i.version].filter(Boolean).join("/"):"unknown",m=[(t??"unknown").padEnd(28),u.padEnd(24),`(${l??"legacy"})`].join(" ");return o===void 0?m:`${m} elicitation=${o}`}async function P({port:r,apiUrl:c,contentApiUrl:i,secretUrlTemplate:t,log:l=o=>console.error(`[${new Date().toLocaleTimeString("en-GB")}] ${o}`)}){let o=_(c);if(t===void 0)switch(new URL(c??"https://api.supabase.com").origin){case"https://api.supabase.com":case"https://api.supabase.green":t=`${o}/mcp/secrets?ref={ref}&name={name}`;break;default:throw new Error("A custom --api-url requires an explicit --secret-url-template.")}R(t);let u={connectUrlTemplate:t},m=$(32),e=G(),n=B(V({fetch:async s=>{let f=K(s,e);if(f)return f;let d=s.headers.get("authorization")?.match(/^Bearer (.+)$/i)?.[1];if(!d)return Response.json({error:"missing bearer token"},{status:401});let y=new URL(s.url),w=0;for(let h of y.searchParams.keys())if(h==="skip_elicitations"&&w++,w>1||/^skip_elicitations\[[^[\]]*\]/.test(h))return Response.json({error:"skip_elicitations must be a single CSV string"},{status:400});let T=D.safeParse(Object.fromEntries(y.searchParams));if(!T.success)return Response.json({error:p.prettifyError(T.error)},{status:400});let{project_ref:N,read_only:U,experimental_apps:j,features:k,skip_elicitations:x}=T.data;l(Q(await s.clone().json().catch(()=>{})));let L=E({accessToken:d,apiUrl:c});k&&A(L,k);let O=F(()=>b({platform:L,projectId:N,readOnly:U,features:k,experimentalApps:j,contentApiUrl:i,dashboardUrl:o,elicitation:{requestState:{key:m,principal:H("sha256").update(d).digest("hex")},confirmation:{enabledTools:S.filter(h=>!x?.includes(h)),ttlSeconds:600},secretCollection:u&&{...u,ttlSeconds:120}}}),{legacy:"stateless",onerror:console.error});return s.signal.addEventListener("abort",()=>O.close(),{once:!0}),O.fetch(s)}},{onerror:console.error}));n.listen(r,"127.0.0.1"),await I(n,"listening");let a=n.address();if(!a||typeof a=="string")throw new Error("expected a TCP address");return{url:`http://127.0.0.1:${a.port}/mcp`,close:async()=>{n.close(),n.closeAllConnections(),await I(n,"close")}}}var{version:Z}=v;async function ee(){let{values:{["access-token"]:r,["project-ref"]:c,["read-only"]:i,["api-url"]:t,["content-api-url"]:l,["secret-url-template"]:o,["version"]:u,["features"]:m,["http"]:e,["port"]:n}}=W({options:{"access-token":{type:"string"},"project-ref":{type:"string"},"read-only":{type:"boolean",default:!1},"api-url":{type:"string"},"content-api-url":{type:"string"},"secret-url-template":{type:"string"},version:{type:"boolean"},features:{type:"string"},http:{type:"boolean",default:!1},port:{type:"string",default:"3111"}}});if(u&&(console.log(Z),process.exit(0)),o!==void 0&&!e){console.error("--secret-url-template requires --http."),process.exitCode=1;return}let a=m?g(m):void 0,s=l??process.env.SUPABASE_CONTENT_API_URL;if(e){try{let y=await P({port:Number(n),apiUrl:t,contentApiUrl:s,secretUrlTemplate:o});console.error(`Supabase MCP server listening on ${y.url}`)}catch(y){console.error(y),process.exitCode=1}return}let f=r??process.env.SUPABASE_ACCESS_TOKEN;f||(console.error("Please provide a personal access token (PAT) with the --access-token flag or set the SUPABASE_ACCESS_TOKEN environment variable"),process.exit(1));let d=E({accessToken:f,apiUrl:t});a&&A(d,a),X(()=>b({platform:d,projectId:c,readOnly:i,features:a,contentApiUrl:s,dashboardUrl:_(t)}),{onerror:console.error})}ee().catch(console.error);
|
|
3
3
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../src/transports/local-http-entry.ts","../src/transports/util.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from 'node:util';\nimport { serveStdio } from '@modelcontextprotocol/server/stdio';\n\nimport packageJson from '../package.json' with { type: 'json' };\nimport { createSupabaseApiPlatform } from './platform/api-platform.js';\nimport { createSupabaseMcpServer } from './server.js';\nimport { startLocalHttpEntry } from './transports/local-http-entry.js';\nimport { parseList } from './transports/util.js';\nimport { dashboardUrlForApiUrl, parseFeatureGroups } from './util.js';\n\nconst { version } = packageJson;\n\nasync function main() {\n const {\n values: {\n ['access-token']: cliAccessToken,\n ['project-ref']: projectId,\n ['read-only']: readOnly,\n ['api-url']: apiUrl,\n ['content-api-url']: cliContentApiUrl,\n ['secret-url-template']: secretUrlTemplate,\n ['version']: showVersion,\n ['features']: cliFeatures,\n ['http']: http,\n ['port']: cliPort,\n },\n } = parseArgs({\n options: {\n ['access-token']: {\n type: 'string',\n },\n ['project-ref']: {\n type: 'string',\n },\n ['read-only']: {\n type: 'boolean',\n default: false,\n },\n ['api-url']: {\n type: 'string',\n },\n ['content-api-url']: {\n type: 'string',\n },\n ['secret-url-template']: {\n type: 'string',\n },\n ['version']: {\n type: 'boolean',\n },\n ['features']: {\n type: 'string',\n },\n ['http']: {\n type: 'boolean',\n default: false,\n },\n ['port']: {\n type: 'string',\n default: '3111',\n },\n },\n });\n\n if (showVersion) {\n console.log(version);\n process.exit(0);\n }\n\n if (secretUrlTemplate !== undefined && !http) {\n console.error('--secret-url-template requires --http.');\n process.exitCode = 1;\n return;\n }\n\n const features = cliFeatures ? parseList(cliFeatures) : undefined;\n\n const contentApiUrl =\n cliContentApiUrl ?? process.env.SUPABASE_CONTENT_API_URL;\n\n if (http) {\n try {\n const entry = await startLocalHttpEntry({\n port: Number(cliPort),\n apiUrl,\n contentApiUrl,\n secretUrlTemplate,\n });\n console.error(`Supabase MCP server listening on ${entry.url}`);\n } catch (error) {\n console.error(error);\n process.exitCode = 1;\n }\n return;\n }\n\n const accessToken = cliAccessToken ?? process.env.SUPABASE_ACCESS_TOKEN;\n\n if (!accessToken) {\n console.error(\n 'Please provide a personal access token (PAT) with the --access-token flag or set the SUPABASE_ACCESS_TOKEN environment variable'\n );\n process.exit(1);\n }\n\n const platform = createSupabaseApiPlatform({\n accessToken,\n apiUrl,\n });\n\n if (features) {\n parseFeatureGroups(platform, features);\n }\n\n // `serveStdio` reports transport startup and out-of-band wire errors only\n // through `onerror`, and swallows them otherwise, so this keeps the stderr\n // output the previous awaited `server.connect()` got from `main().catch`.\n serveStdio(\n () =>\n createSupabaseMcpServer({\n platform,\n projectId,\n readOnly,\n features,\n contentApiUrl,\n dashboardUrl: dashboardUrlForApiUrl(apiUrl),\n }),\n { onerror: console.error }\n );\n}\n\nmain().catch(console.error);\n","import { createHash, randomBytes } from 'node:crypto';\nimport { once } from 'node:events';\nimport { createServer } from 'node:http';\nimport { toNodeHandler } from '@modelcontextprotocol/node';\nimport {\n CLIENT_CAPABILITIES_META_KEY,\n CLIENT_INFO_META_KEY,\n createMcpHandler,\n hostHeaderValidationResponse,\n type Implementation,\n isJSONRPCNotification,\n isJSONRPCRequest,\n isSpecType,\n localhostAllowedHostnames,\n PROTOCOL_VERSION_META_KEY,\n} from '@modelcontextprotocol/server';\nimport { z } from 'zod/v4';\n\nimport { createSupabaseApiPlatform } from '../platform/api-platform.js';\nimport { createSupabaseMcpServer } from '../server.js';\nimport { assertValidConnectUrlTemplate } from '../tools/secret-tools.js';\nimport { CURRENT_ELICITATION_TOOLS } from '../types.js';\nimport { dashboardUrlForApiUrl, parseFeatureGroups } from '../util.js';\nimport { parseList } from './util.js';\n\nexport type LocalHttpEntryOptions = {\n port: number;\n apiUrl?: string;\n contentApiUrl?: string;\n secretUrlTemplate?: string;\n log?: (line: string) => void;\n};\n\n// https://supabase.com/docs/guides/ai-tools/mcp#configuration-options\nconst querySchema = z.object({\n project_ref: z.string().optional(),\n read_only: z.stringbool().default(false),\n features: z\n .string()\n .transform((value) => parseList(value))\n .optional(),\n skip_elicitations: z\n .string()\n .transform((value) => parseList(value))\n .optional()\n .pipe(z.array(z.enum(CURRENT_ELICITATION_TOOLS)).optional()),\n});\n\n/** e.g. `tools/call create_branch claude-code/2.1.260 (2026-07-28)` */\nexport function describeRequest(body: unknown): string {\n const messages: unknown[] = Array.isArray(body) ? body : [body];\n let client: Implementation | undefined;\n let method: string | undefined;\n let protocolVersion: string | undefined;\n let elicitation: string | undefined;\n for (const message of messages) {\n if (!isJSONRPCRequest(message) && !isJSONRPCNotification(message)) continue;\n method ??= isSpecType.CallToolRequest(message)\n ? `${message.method} ${message.params.name}`\n : message.method;\n const meta = message.params?._meta;\n const metaClient = meta?.[CLIENT_INFO_META_KEY];\n if (isSpecType.Implementation(metaClient)) client ??= metaClient;\n const metaVersion = meta?.[PROTOCOL_VERSION_META_KEY];\n if (typeof metaVersion === 'string') protocolVersion ??= metaVersion;\n if (isSpecType.InitializeRequest(message)) {\n client ??= message.params.clientInfo;\n protocolVersion ??= message.params.protocolVersion;\n elicitation ??=\n JSON.stringify(message.params.capabilities.elicitation) ?? 'absent';\n } else if (\n isSpecType.CallToolRequest(message) &&\n (message.params.name === 'create_edge_function_secret' ||\n (CURRENT_ELICITATION_TOOLS as readonly string[]).includes(\n message.params.name\n ))\n ) {\n const capabilities = meta?.[CLIENT_CAPABILITIES_META_KEY] as\n | { elicitation?: unknown }\n | undefined;\n elicitation ??= JSON.stringify(capabilities?.elicitation) ?? 'absent';\n }\n }\n const name = client\n ? [client.name, client.version].filter(Boolean).join('/')\n : 'unknown';\n const description = [\n (method ?? 'unknown').padEnd(28),\n name.padEnd(24),\n `(${protocolVersion ?? 'legacy'})`,\n ].join(' ');\n return elicitation === undefined\n ? description\n : `${description} elicitation=${elicitation}`;\n}\n\nexport async function startLocalHttpEntry({\n port,\n apiUrl,\n contentApiUrl,\n secretUrlTemplate,\n log = (line) =>\n console.error(`[${new Date().toLocaleTimeString('en-GB')}] ${line}`),\n}: LocalHttpEntryOptions) {\n const dashboardUrl = dashboardUrlForApiUrl(apiUrl);\n if (secretUrlTemplate === undefined) {\n switch (new URL(apiUrl ?? 'https://api.supabase.com').origin) {\n case 'https://api.supabase.com':\n case 'https://api.supabase.green':\n secretUrlTemplate = `${dashboardUrl}/mcp/secrets?ref={ref}&name={name}`;\n break;\n default:\n throw new Error(\n 'A custom --api-url requires an explicit --secret-url-template.'\n );\n }\n }\n assertValidConnectUrlTemplate(secretUrlTemplate);\n const secretCollection = { connectUrlTemplate: secretUrlTemplate };\n const requestStateKey = randomBytes(32);\n const allowedHostnames = localhostAllowedHostnames();\n\n const server = createServer(\n toNodeHandler(\n {\n fetch: async (request) => {\n const rejected = hostHeaderValidationResponse(\n request,\n allowedHostnames\n );\n if (rejected) return rejected;\n\n const accessToken = request.headers\n .get('authorization')\n ?.match(/^Bearer (.+)$/i)?.[1];\n if (!accessToken) {\n return Response.json(\n { error: 'missing bearer token' },\n { status: 401 }\n );\n }\n\n const url = new URL(request.url);\n // Hosted query parsing turns repeated or bracketed skips into\n // non-string values. Reject those before flattening query parameters.\n let skipCount = 0;\n for (const key of url.searchParams.keys()) {\n if (key === 'skip_elicitations') skipCount++;\n if (skipCount > 1 || /^skip_elicitations\\[[^[\\]]*\\]/.test(key)) {\n return Response.json(\n { error: 'skip_elicitations must be a single CSV string' },\n { status: 400 }\n );\n }\n }\n const query = querySchema.safeParse(\n Object.fromEntries(url.searchParams)\n );\n if (!query.success) {\n return Response.json(\n { error: z.prettifyError(query.error) },\n { status: 400 }\n );\n }\n const {\n project_ref: projectId,\n read_only: readOnly,\n features,\n skip_elicitations: skipElicitations,\n } = query.data;\n\n log(\n describeRequest(\n await request\n .clone()\n .json()\n .catch(() => undefined)\n )\n );\n\n const platform = createSupabaseApiPlatform({ accessToken, apiUrl });\n if (features) parseFeatureGroups(platform, features);\n const handler = createMcpHandler(\n () =>\n createSupabaseMcpServer({\n platform,\n projectId,\n readOnly,\n features,\n contentApiUrl,\n dashboardUrl,\n elicitation: {\n requestState: {\n key: requestStateKey,\n ttlSeconds: 120,\n // One process can serve several PATs, so the principal is the token's hash.\n principal: createHash('sha256')\n .update(accessToken)\n .digest('hex'),\n },\n confirmation: {\n enabledTools: CURRENT_ELICITATION_TOOLS.filter(\n (tool) => !skipElicitations?.includes(tool)\n ),\n },\n secretCollection,\n },\n }),\n { legacy: 'stateless', onerror: console.error }\n );\n request.signal.addEventListener('abort', () => handler.close(), {\n once: true,\n });\n return handler.fetch(request);\n },\n },\n { onerror: console.error }\n )\n );\n\n server.listen(port, '127.0.0.1');\n await once(server, 'listening');\n const address = server.address();\n if (!address || typeof address === 'string') {\n throw new Error('expected a TCP address');\n }\n\n return {\n url: `http://127.0.0.1:${address.port}/mcp`,\n close: async () => {\n server.close();\n server.closeAllConnections();\n await once(server, 'close');\n },\n };\n}\n\nexport type LocalHttpEntry = Awaited<ReturnType<typeof startLocalHttpEntry>>;\n","/**\n * Parses a delimited list of items into an array,\n * trimming whitespace and filtering out empty items.\n *\n * Default delimiter is a comma (`,`).\n */\nexport function parseList(list: string, delimiter = ','): string[] {\n const items = list.split(delimiter).map((feature) => feature.trim());\n return items.filter((feature) => feature !== '');\n}\n"],"mappings":";4MACA,OAAS,aAAAA,MAAiB,OAC1B,OAAS,cAAAC,MAAkB,qCCF3B,OAAS,cAAAC,EAAY,eAAAC,MAAmB,SACxC,OAAS,QAAAC,MAAY,SACrB,OAAS,gBAAAC,MAAoB,OAC7B,OAAS,iBAAAC,MAAqB,6BAC9B,OACE,gCAAAC,EACA,wBAAAC,EACA,oBAAAC,EACA,gCAAAC,EAEA,yBAAAC,EACA,oBAAAC,EACA,cAAAC,EACA,6BAAAC,EACA,6BAAAC,MACK,+BACP,OAAS,KAAAC,MAAS,SCVX,SAASC,EAAUC,EAAcC,EAAY,IAAe,CAEjE,OADcD,EAAK,MAAMC,CAAS,EAAE,IAAKC,GAAYA,EAAQ,KAAK,CAAC,EACtD,OAAQA,GAAYA,IAAY,EAAE,CACjD,CDyBA,IAAMC,EAAcC,EAAE,OAAO,CAC3B,YAAaA,EAAE,OAAO,EAAE,SAAS,EACjC,UAAWA,EAAE,WAAW,EAAE,QAAQ,EAAK,EACvC,SAAUA,EACP,OAAO,EACP,UAAWC,GAAUC,EAAUD,CAAK,CAAC,EACrC,SAAS,EACZ,kBAAmBD,EAChB,OAAO,EACP,UAAWC,GAAUC,EAAUD,CAAK,CAAC,EACrC,SAAS,EACT,KAAKD,EAAE,MAAMA,EAAE,KAAKG,CAAyB,CAAC,EAAE,SAAS,CAAC,CAC/D,CAAC,EAGM,SAASC,EAAgBC,EAAuB,CACrD,IAAMC,EAAsB,MAAM,QAAQD,CAAI,EAAIA,EAAO,C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AAAC,EACA,SAAAS,EACA,cAAAE,EACA,aAAcU,EAAsBpB,CAAM,CAC5C,CAAC,EACH,CAAE,QAAS,QAAQ,KAAM,CAC3B,CACF,CAEAJ,EAAK,EAAE,MAAM,QAAQ,KAAK","names":["parseArgs","serveStdio","createHash","randomBytes","once","createServer","toNodeHandler","CLIENT_CAPABILITIES_META_KEY","CLIENT_INFO_META_KEY","createMcpHandler","hostHeaderValidationResponse","isJSONRPCNotification","isJSONRPCRequest","isSpecType","localhostAllowedHostnames","PROTOCOL_VERSION_META_KEY","z","parseList","list","delimiter","feature","querySchema","z","value","parseList","CURRENT_ELICITATION_TOOLS","describeRequest","body","messages","client","method","protocolVersion","elicitation","message","isJSONRPCRequest","isJSONRPCNotification","isSpecType","meta","metaClient","CLIENT_INFO_META_KEY","metaVersion","PROTOCOL_VERSION_META_KEY","capabilities","CLIENT_CAPABILITIES_META_KEY","name","description","startLocalHttpEntry","port","apiUrl","contentApiUrl","secretUrlTemplate","log","line","dashboardUrl","dashboardUrlForApiUrl","assertValidConnectUrlTemplate","secretCollection","requestStateKey","randomBytes","allowedHostnames","localhostAllowedHostnames","server","createServer","toNodeHandler","request","rejected","hostHeaderValidationResponse","accessToken","url","skipCount","key","query","projectId","readOnly","features","skipElicitations","platform","createSupabaseApiPlatform","parseFeatureGroups","handler","createMcpHandler","createSupabaseMcpServer","createHash","tool","once","address","version","package_default","main","cliAccessToken","projectId","readOnly","apiUrl","cliContentApiUrl","secretUrlTemplate","showVersion","cliFeatures","http","cliPort","parseArgs","features","parseList","contentApiUrl","entry","startLocalHttpEntry","error","accessToken","platform","createSupabaseApiPlatform","parseFeatureGroups","serveStdio","createSupabaseMcpServer","dashboardUrlForApiUrl"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/transports/local-http-entry.ts","../src/transports/util.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from 'node:util';\nimport { serveStdio } from '@modelcontextprotocol/server/stdio';\n\nimport packageJson from '../package.json' with { type: 'json' };\nimport { createSupabaseApiPlatform } from './platform/api-platform.js';\nimport { createSupabaseMcpServer } from './server.js';\nimport { startLocalHttpEntry } from './transports/local-http-entry.js';\nimport { parseList } from './transports/util.js';\nimport { dashboardUrlForApiUrl, parseFeatureGroups } from './util.js';\n\nconst { version } = packageJson;\n\nasync function main() {\n const {\n values: {\n ['access-token']: cliAccessToken,\n ['project-ref']: projectId,\n ['read-only']: readOnly,\n ['api-url']: apiUrl,\n ['content-api-url']: cliContentApiUrl,\n ['secret-url-template']: secretUrlTemplate,\n ['version']: showVersion,\n ['features']: cliFeatures,\n ['http']: http,\n ['port']: cliPort,\n },\n } = parseArgs({\n options: {\n ['access-token']: {\n type: 'string',\n },\n ['project-ref']: {\n type: 'string',\n },\n ['read-only']: {\n type: 'boolean',\n default: false,\n },\n ['api-url']: {\n type: 'string',\n },\n ['content-api-url']: {\n type: 'string',\n },\n ['secret-url-template']: {\n type: 'string',\n },\n ['version']: {\n type: 'boolean',\n },\n ['features']: {\n type: 'string',\n },\n ['http']: {\n type: 'boolean',\n default: false,\n },\n ['port']: {\n type: 'string',\n default: '3111',\n },\n },\n });\n\n if (showVersion) {\n console.log(version);\n process.exit(0);\n }\n\n if (secretUrlTemplate !== undefined && !http) {\n console.error('--secret-url-template requires --http.');\n process.exitCode = 1;\n return;\n }\n\n const features = cliFeatures ? parseList(cliFeatures) : undefined;\n\n const contentApiUrl =\n cliContentApiUrl ?? process.env.SUPABASE_CONTENT_API_URL;\n\n if (http) {\n try {\n const entry = await startLocalHttpEntry({\n port: Number(cliPort),\n apiUrl,\n contentApiUrl,\n secretUrlTemplate,\n });\n console.error(`Supabase MCP server listening on ${entry.url}`);\n } catch (error) {\n console.error(error);\n process.exitCode = 1;\n }\n return;\n }\n\n const accessToken = cliAccessToken ?? process.env.SUPABASE_ACCESS_TOKEN;\n\n if (!accessToken) {\n console.error(\n 'Please provide a personal access token (PAT) with the --access-token flag or set the SUPABASE_ACCESS_TOKEN environment variable'\n );\n process.exit(1);\n }\n\n const platform = createSupabaseApiPlatform({\n accessToken,\n apiUrl,\n });\n\n if (features) {\n parseFeatureGroups(platform, features);\n }\n\n // `serveStdio` reports transport startup and out-of-band wire errors only\n // through `onerror`, and swallows them otherwise, so this keeps the stderr\n // output the previous awaited `server.connect()` got from `main().catch`.\n serveStdio(\n () =>\n createSupabaseMcpServer({\n platform,\n projectId,\n readOnly,\n features,\n contentApiUrl,\n dashboardUrl: dashboardUrlForApiUrl(apiUrl),\n }),\n { onerror: console.error }\n );\n}\n\nmain().catch(console.error);\n","import { createHash, randomBytes } from 'node:crypto';\nimport { once } from 'node:events';\nimport { createServer } from 'node:http';\nimport { toNodeHandler } from '@modelcontextprotocol/node';\nimport {\n CLIENT_CAPABILITIES_META_KEY,\n CLIENT_INFO_META_KEY,\n createMcpHandler,\n hostHeaderValidationResponse,\n type Implementation,\n isJSONRPCNotification,\n isJSONRPCRequest,\n isSpecType,\n localhostAllowedHostnames,\n PROTOCOL_VERSION_META_KEY,\n} from '@modelcontextprotocol/server';\nimport { z } from 'zod/v4';\n\nimport { createSupabaseApiPlatform } from '../platform/api-platform.js';\nimport { createSupabaseMcpServer } from '../server.js';\nimport { assertValidConnectUrlTemplate } from '../tools/secret-tools.js';\nimport { CURRENT_ELICITATION_TOOLS } from '../types.js';\nimport { dashboardUrlForApiUrl, parseFeatureGroups } from '../util.js';\nimport { parseList } from './util.js';\n\nexport type LocalHttpEntryOptions = {\n port: number;\n apiUrl?: string;\n contentApiUrl?: string;\n secretUrlTemplate?: string;\n log?: (line: string) => void;\n};\n\n// https://supabase.com/docs/guides/ai-tools/mcp#configuration-options\nconst querySchema = z.object({\n project_ref: z.string().optional(),\n read_only: z.stringbool().default(false),\n experimental_apps: z.stringbool().default(false),\n features: z\n .string()\n .transform((value) => parseList(value))\n .optional(),\n skip_elicitations: z\n .string()\n .transform((value) => parseList(value))\n .optional()\n .pipe(z.array(z.enum(CURRENT_ELICITATION_TOOLS)).optional()),\n});\n\n/** e.g. `tools/call create_branch claude-code/2.1.260 (2026-07-28)` */\nexport function describeRequest(body: unknown): string {\n const messages: unknown[] = Array.isArray(body) ? body : [body];\n let client: Implementation | undefined;\n let method: string | undefined;\n let protocolVersion: string | undefined;\n let elicitation: string | undefined;\n for (const message of messages) {\n if (!isJSONRPCRequest(message) && !isJSONRPCNotification(message)) continue;\n method ??= isSpecType.CallToolRequest(message)\n ? `${message.method} ${message.params.name}`\n : message.method;\n const meta = message.params?._meta;\n const metaClient = meta?.[CLIENT_INFO_META_KEY];\n if (isSpecType.Implementation(metaClient)) client ??= metaClient;\n const metaVersion = meta?.[PROTOCOL_VERSION_META_KEY];\n if (typeof metaVersion === 'string') protocolVersion ??= metaVersion;\n if (isSpecType.InitializeRequest(message)) {\n client ??= message.params.clientInfo;\n protocolVersion ??= message.params.protocolVersion;\n elicitation ??=\n JSON.stringify(message.params.capabilities.elicitation) ?? 'absent';\n } else if (\n isSpecType.CallToolRequest(message) &&\n (message.params.name === 'create_edge_function_secret' ||\n (CURRENT_ELICITATION_TOOLS as readonly string[]).includes(\n message.params.name\n ))\n ) {\n const capabilities = meta?.[CLIENT_CAPABILITIES_META_KEY] as\n | { elicitation?: unknown }\n | undefined;\n elicitation ??= JSON.stringify(capabilities?.elicitation) ?? 'absent';\n }\n }\n const name = client\n ? [client.name, client.version].filter(Boolean).join('/')\n : 'unknown';\n const description = [\n (method ?? 'unknown').padEnd(28),\n name.padEnd(24),\n `(${protocolVersion ?? 'legacy'})`,\n ].join(' ');\n return elicitation === undefined\n ? description\n : `${description} elicitation=${elicitation}`;\n}\n\nexport async function startLocalHttpEntry({\n port,\n apiUrl,\n contentApiUrl,\n secretUrlTemplate,\n log = (line) =>\n console.error(`[${new Date().toLocaleTimeString('en-GB')}] ${line}`),\n}: LocalHttpEntryOptions) {\n const dashboardUrl = dashboardUrlForApiUrl(apiUrl);\n if (secretUrlTemplate === undefined) {\n switch (new URL(apiUrl ?? 'https://api.supabase.com').origin) {\n case 'https://api.supabase.com':\n case 'https://api.supabase.green':\n secretUrlTemplate = `${dashboardUrl}/mcp/secrets?ref={ref}&name={name}`;\n break;\n default:\n throw new Error(\n 'A custom --api-url requires an explicit --secret-url-template.'\n );\n }\n }\n assertValidConnectUrlTemplate(secretUrlTemplate);\n const secretCollection = { connectUrlTemplate: secretUrlTemplate };\n const requestStateKey = randomBytes(32);\n const allowedHostnames = localhostAllowedHostnames();\n\n const server = createServer(\n toNodeHandler(\n {\n fetch: async (request) => {\n const rejected = hostHeaderValidationResponse(\n request,\n allowedHostnames\n );\n if (rejected) return rejected;\n\n const accessToken = request.headers\n .get('authorization')\n ?.match(/^Bearer (.+)$/i)?.[1];\n if (!accessToken) {\n return Response.json(\n { error: 'missing bearer token' },\n { status: 401 }\n );\n }\n\n const url = new URL(request.url);\n // Hosted query parsing turns repeated or bracketed skips into\n // non-string values. Reject those before flattening query parameters.\n let skipCount = 0;\n for (const key of url.searchParams.keys()) {\n if (key === 'skip_elicitations') skipCount++;\n if (skipCount > 1 || /^skip_elicitations\\[[^[\\]]*\\]/.test(key)) {\n return Response.json(\n { error: 'skip_elicitations must be a single CSV string' },\n { status: 400 }\n );\n }\n }\n const query = querySchema.safeParse(\n Object.fromEntries(url.searchParams)\n );\n if (!query.success) {\n return Response.json(\n { error: z.prettifyError(query.error) },\n { status: 400 }\n );\n }\n const {\n project_ref: projectId,\n read_only: readOnly,\n experimental_apps: experimentalApps,\n features,\n skip_elicitations: skipElicitations,\n } = query.data;\n\n log(\n describeRequest(\n await request\n .clone()\n .json()\n .catch(() => undefined)\n )\n );\n\n const platform = createSupabaseApiPlatform({ accessToken, apiUrl });\n if (features) parseFeatureGroups(platform, features);\n const handler = createMcpHandler(\n () =>\n createSupabaseMcpServer({\n platform,\n projectId,\n readOnly,\n features,\n experimentalApps,\n contentApiUrl,\n dashboardUrl,\n elicitation: {\n requestState: {\n key: requestStateKey,\n // One process can serve several PATs, so the principal is the token's hash.\n principal: createHash('sha256')\n .update(accessToken)\n .digest('hex'),\n },\n confirmation: {\n enabledTools: CURRENT_ELICITATION_TOOLS.filter(\n (tool) => !skipElicitations?.includes(tool)\n ),\n ttlSeconds: 600,\n },\n secretCollection: secretCollection && {\n ...secretCollection,\n ttlSeconds: 120,\n },\n },\n }),\n { legacy: 'stateless', onerror: console.error }\n );\n request.signal.addEventListener('abort', () => handler.close(), {\n once: true,\n });\n return handler.fetch(request);\n },\n },\n { onerror: console.error }\n )\n );\n\n server.listen(port, '127.0.0.1');\n await once(server, 'listening');\n const address = server.address();\n if (!address || typeof address === 'string') {\n throw new Error('expected a TCP address');\n }\n\n return {\n url: `http://127.0.0.1:${address.port}/mcp`,\n close: async () => {\n server.close();\n server.closeAllConnections();\n await once(server, 'close');\n },\n };\n}\n\nexport type LocalHttpEntry = Awaited<ReturnType<typeof startLocalHttpEntry>>;\n","/**\n * Parses a delimited list of items into an array,\n * trimming whitespace and filtering out empty items.\n *\n * Default delimiter is a comma (`,`).\n */\nexport function parseList(list: string, delimiter = ','): string[] {\n const items = list.split(delimiter).map((feature) => feature.trim());\n return items.filter((feature) => feature !== '');\n}\n"],"mappings":";4MACA,OAAS,aAAAA,MAAiB,OAC1B,OAAS,cAAAC,MAAkB,qCCF3B,OAAS,cAAAC,EAAY,eAAAC,MAAmB,SACxC,OAAS,QAAAC,MAAY,SACrB,OAAS,gBAAAC,MAAoB,OAC7B,OAAS,iBAAAC,MAAqB,6BAC9B,OACE,gCAAAC,EACA,wBAAAC,EACA,oBAAAC,EACA,gCAAAC,EAEA,yBAAAC,EACA,oBAAAC,EACA,cAAAC,EACA,6BAAAC,EACA,6BAAAC,MACK,+BACP,OAAS,KAAAC,MAAS,SCVX,SAASC,EAAUC,EAAcC,EAAY,IAAe,CAEjE,OADcD,EAAK,MAAMC,CAAS,EAAE,IAAKC,GAAYA,EAAQ,KAAK,CAAC,EACtD,OAAQA,GAAYA,IAAY,EAAE,CACjD,CDyBA,IAAMC,EAAcC,EAAE,OAAO,CAC3B,YAAaA,EAAE,OAAO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IAAMM,EAAQ,MAAMC,EAAoB,CACtC,KAAM,OAAON,CAAO,EACpB,OAAAN,EACA,cAAAU,EACA,kBAAAR,CACF,CAAC,EACD,QAAQ,MAAM,oCAAoCS,EAAM,GAAG,EAAE,CAC/D,OAASE,EAAO,CACd,QAAQ,MAAMA,CAAK,EACnB,QAAQ,SAAW,CACrB,CACA,MACF,CAEA,IAAMC,EAAcjB,GAAkB,QAAQ,IAAI,sBAE7CiB,IACH,QAAQ,MACN,iIACF,EACA,QAAQ,KAAK,CAAC,GAGhB,IAAMC,EAAWC,EAA0B,CACzC,YAAAF,EACA,OAAAd,CACF,CAAC,EAEGQ,GACFS,EAAmBF,EAAUP,CAAQ,EAMvCU,EACE,IACEC,EAAwB,CACtB,SAAAJ,EACA,UAAAjB,EACA,SAAAC,EACA,SAAAS,EACA,cAAAE,EACA,aAAcU,EAAsBpB,CAAM,CAC5C,CAAC,EACH,CAAE,QAAS,QAAQ,KAAM,CAC3B,CACF,CAEAJ,GAAK,EAAE,MAAM,QAAQ,KAAK","names":["parseArgs","serveStdio","createHash","randomBytes","once","createServer","toNodeHandler","CLIENT_CAPABILITIES_META_KEY","CLIENT_INFO_META_KEY","createMcpHandler","hostHeaderValidationResponse","isJSONRPCNotification","isJSONRPCRequest","isSpecType","localhostAllowedHostnames","PROTOCOL_VERSION_META_KEY","z","parseList","list","delimiter","feature","querySchema","z","value","parseList","CURRENT_ELICITATION_TOOLS","describeRequest","body","messages","client","method","protocolVersion","elicitation","message","isJSONRPCRequest","isJSONRPCNotification","isSpecType","meta","metaClient","CLIENT_INFO_META_KEY","metaVersion","PROTOCOL_VERSION_META_KEY","capabilities","CLIENT_CAPABILITIES_META_KEY","name","description","startLocalHttpEntry","port","apiUrl","contentApiUrl","secretUrlTemplate","log","line","dashboardUrl","dashboardUrlForApiUrl","assertValidConnectUrlTemplate","secretCollection","requestStateKey","randomBytes","allowedHostnames","localhostAllowedHostnames","server","createServer","toNodeHandler","request","rejected","hostHeaderValidationResponse","accessToken","url","skipCount","key","query","projectId","readOnly","experimentalApps","features","skipElicitations","platform","createSupabaseApiPlatform","parseFeatureGroups","handler","createMcpHandler","createSupabaseMcpServer","createHash","tool","once","address","version","package_default","main","cliAccessToken","projectId","readOnly","apiUrl","cliContentApiUrl","secretUrlTemplate","showVersion","cliFeatures","http","cliPort","parseArgs","features","parseList","contentApiUrl","entry","startLocalHttpEntry","error","accessToken","platform","createSupabaseApiPlatform","parseFeatureGroups","serveStdio","createSupabaseMcpServer","dashboardUrlForApiUrl"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkDP5DAOXIcjs = require('./chunk-DP5DAOXI.cjs');var _chunkTK2UZS5Xcjs = require('./chunk-TK2UZS5X.cjs');require('./chunk-6FWRABME.cjs');var _mcputils = require('@supabase/mcp-utils');var _server = require('@modelcontextprotocol/server');function i(o){return _server.createMcpHandler.call(void 0, ()=>_chunkDP5DAOXIcjs.h.call(void 0, o),{legacy:"reject"})}var O=_chunkTK2UZS5Xcjs.a.version;exports.CURRENT_ELICITATION_TOOLS = _chunkDP5DAOXIcjs.a; exports.CURRENT_FEATURE_GROUPS = _chunkDP5DAOXIcjs.b; exports.ToolCallerError = _mcputils.ToolCallerError; exports.createFeedbackOperations = _chunkTK2UZS5Xcjs.h; exports.createSupabaseMcpHandler = i; exports.createSupabaseMcpServer = _chunkDP5DAOXIcjs.h; exports.createToolSchemas = _chunkDP5DAOXIcjs.g; exports.isToolCallerError = _mcputils.isToolCallerError; exports.supabaseMcpToolSchemas = _chunkDP5DAOXIcjs.f; exports.version = O;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/mcp/mcp/packages/mcp-server-supabase/dist/index.cjs","../src/
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/mcp/mcp/packages/mcp-server-supabase/dist/index.cjs","../src/index.ts","../src/transports/http.ts"],"names":["createSupabaseMcpHandler","options","createMcpHandler","createSupabaseMcpServer","version","package_default"],"mappings":"AAAA,iIAA+D,wDAAgD,gCAA6B,+CCgBrI,sDChB0B,SASjBA,CAAAA,CAAyBC,CAAAA,CAAmC,CAC1E,OAAOC,sCAAAA,CAAiB,CAAA,EAAMC,iCAAAA,CAA+B,CAAA,CAAG,CAC9D,MAAA,CAAQ,QACV,CAAC,CACH,CDqBO,IAAMC,CAAAA,CAAUC,mBAAAA,CAAY,OAAA,CAAA,6eAAA","file":"/home/runner/work/mcp/mcp/packages/mcp-server-supabase/dist/index.cjs","sourcesContent":[null,"import packageJson from '../package.json' with { type: 'json' };\n\nexport type {\n ObservationContext,\n ObservationEnd,\n ObservationFact,\n ObservedMethod,\n ObservedTool,\n ConfirmationFeature,\n RequestObservation,\n RequestObserver,\n} from './observation.js';\nexport {\n isToolCallerError,\n ToolCallerError,\n type ToolCallerErrorKind,\n} from '@supabase/mcp-utils';\nexport type { ToolCallCallback } from '@supabase/mcp-utils';\nexport {\n createFeedbackOperations,\n type FeedbackOperationsOptions,\n} from './platform/feedback.js';\nexport type { FeedbackOperations, SupabasePlatform } from './platform/index.js';\nexport {\n createSupabaseMcpServer,\n type SupabaseMcpServerOptions,\n} from './server.js';\nexport { createSupabaseMcpHandler } from './transports/http.js';\nexport {\n CURRENT_ELICITATION_TOOLS,\n CURRENT_FEATURE_GROUPS,\n type ElicitationToolName,\n type FeatureGroup,\n} from './types.js';\nexport const version = packageJson.version;\n\nexport {\n createToolSchemas,\n supabaseMcpToolSchemas,\n} from './tools/tool-schemas.js';\n","import { createMcpHandler } from '@modelcontextprotocol/server';\n\nimport {\n createSupabaseMcpServer,\n type SupabaseMcpServerOptions,\n} from '../server.js';\n\n// Modern protocol only: created with `legacy: 'reject'`, so a client that\n// speaks just the 2025-era protocol gets an HTTP 400 instead of being served.\nexport function createSupabaseMcpHandler(options: SupabaseMcpServerOptions) {\n return createMcpHandler(() => createSupabaseMcpServer(options), {\n legacy: 'reject',\n });\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ObservationContext as ObservationContext$1, RequestObservation as RequestObservation$1, RequestObserver as RequestObserver$1, ToolCallCallback } from '@supabase/mcp-utils';
|
|
2
|
-
export { ObservationEnd, ObservedMethod, ToolCallCallback } from '@supabase/mcp-utils';
|
|
2
|
+
export { ObservationEnd, ObservedMethod, ToolCallCallback, ToolCallerError, ToolCallerErrorKind, isToolCallerError } from '@supabase/mcp-utils';
|
|
3
3
|
import { z } from 'zod/v4';
|
|
4
4
|
import { FeedbackOperations, SupabasePlatform } from './platform/index.cjs';
|
|
5
5
|
import * as _modelcontextprotocol_server from '@modelcontextprotocol/server';
|
|
@@ -11,17 +11,17 @@ declare const CURRENT_FEATURE_GROUPS: readonly ["docs", "account", "database", "
|
|
|
11
11
|
declare const featureGroupSchema: z.ZodPipe<z.ZodUnion<readonly [z.ZodEnum<{
|
|
12
12
|
debug: "debug";
|
|
13
13
|
}>, z.ZodEnum<{
|
|
14
|
-
storage: "storage";
|
|
15
|
-
database: "database";
|
|
16
|
-
feedback: "feedback";
|
|
17
14
|
docs: "docs";
|
|
18
15
|
account: "account";
|
|
16
|
+
database: "database";
|
|
19
17
|
debugging: "debugging";
|
|
20
18
|
development: "development";
|
|
21
19
|
functions: "functions";
|
|
22
20
|
branching: "branching";
|
|
21
|
+
storage: "storage";
|
|
23
22
|
notebooks: "notebooks";
|
|
24
|
-
|
|
23
|
+
feedback: "feedback";
|
|
24
|
+
}>]>, z.ZodTransform<"docs" | "account" | "database" | "debugging" | "development" | "functions" | "branching" | "storage" | "notebooks" | "feedback", "debug" | "docs" | "account" | "database" | "debugging" | "development" | "functions" | "branching" | "storage" | "notebooks" | "feedback">>;
|
|
25
25
|
type FeatureGroup = z.infer<typeof featureGroupSchema>;
|
|
26
26
|
|
|
27
27
|
type ObservedTool = ElicitationToolName | 'other';
|
|
@@ -76,19 +76,6 @@ type ObservationContext = ObservationContext$1<ObservedTool>;
|
|
|
76
76
|
type RequestObservation = RequestObservation$1<ObservationFact>;
|
|
77
77
|
type RequestObserver = RequestObserver$1<ObservedTool, ObservationFact>;
|
|
78
78
|
|
|
79
|
-
declare const toolCallerErrorBrand: unique symbol;
|
|
80
|
-
/**
|
|
81
|
-
* A tool error caused by the caller's input, comparable to an HTTP 4xx.
|
|
82
|
-
*/
|
|
83
|
-
declare class ToolCallerError extends Error {
|
|
84
|
-
[toolCallerErrorBrand]: true;
|
|
85
|
-
constructor(message: string, options?: ErrorOptions);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Checks the global symbol brand so errors from another installed copy of this package still match.
|
|
89
|
-
*/
|
|
90
|
-
declare function isToolCallerError(error: unknown): error is ToolCallerError;
|
|
91
|
-
|
|
92
79
|
declare const FEEDBACK_ENVIRONMENTS: {
|
|
93
80
|
production: {
|
|
94
81
|
url: string;
|
|
@@ -129,6 +116,11 @@ type SupabaseMcpServerOptions = {
|
|
|
129
116
|
* Executes database queries in read-only mode if true.
|
|
130
117
|
*/
|
|
131
118
|
readOnly?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Enables MCP Apps: interactive views for supported tools. Experimental, off
|
|
121
|
+
* by default.
|
|
122
|
+
*/
|
|
123
|
+
experimentalApps?: boolean;
|
|
132
124
|
/**
|
|
133
125
|
* Features to enable.
|
|
134
126
|
* Options: 'account', 'branching', 'database', 'debugging', 'development', 'docs', 'feedback', 'functions', 'notebooks', 'storage'
|
|
@@ -157,8 +149,6 @@ type SupabaseMcpServerOptions = {
|
|
|
157
149
|
key: string | Uint8Array;
|
|
158
150
|
/** The authenticated principal `requestState` is bound to. */
|
|
159
151
|
principal: string;
|
|
160
|
-
/** How long a minted `requestState` stays valid, in seconds. */
|
|
161
|
-
ttlSeconds?: number;
|
|
162
152
|
};
|
|
163
153
|
/**
|
|
164
154
|
* Form confirmation for the listed cost, destructive SQL and notebook
|
|
@@ -170,6 +160,8 @@ type SupabaseMcpServerOptions = {
|
|
|
170
160
|
confirmation?: {
|
|
171
161
|
/** Tools that accept a confirmation elicitation. Empty disables all forms. */
|
|
172
162
|
enabledTools: readonly ElicitationToolName[];
|
|
163
|
+
/** How long a confirmation `requestState` stays valid, in seconds. Defaults to 600. */
|
|
164
|
+
ttlSeconds?: number;
|
|
173
165
|
};
|
|
174
166
|
/**
|
|
175
167
|
* URL-mode secret collection for `create_edge_function_secret`. Requires
|
|
@@ -184,6 +176,8 @@ type SupabaseMcpServerOptions = {
|
|
|
184
176
|
* Example: `https://supabase.com/dashboard/mcp/secrets?ref={ref}&name={name}`.
|
|
185
177
|
*/
|
|
186
178
|
connectUrlTemplate: string;
|
|
179
|
+
/** How long a secret-collection `requestState` stays valid, in seconds. Defaults to 600. */
|
|
180
|
+
ttlSeconds?: number;
|
|
187
181
|
};
|
|
188
182
|
};
|
|
189
183
|
};
|
|
@@ -257,7 +251,7 @@ declare const accountToolDefs: {
|
|
|
257
251
|
};
|
|
258
252
|
};
|
|
259
253
|
readonly get_project: {
|
|
260
|
-
readonly description: "Gets details for a Supabase project.";
|
|
254
|
+
readonly description: "Gets details for a Supabase project. `status` is `ACTIVE_HEALTHY` when the project is ready for database tools; other values such as `COMING_UP`, `RESTORING`, or `INACTIVE` (paused) mean database calls will fail or time out.";
|
|
261
255
|
readonly parameters: z.ZodObject<{
|
|
262
256
|
id: z.ZodString;
|
|
263
257
|
}, z.core.$strip>;
|
|
@@ -332,7 +326,7 @@ declare const accountToolDefs: {
|
|
|
332
326
|
};
|
|
333
327
|
};
|
|
334
328
|
readonly create_project: {
|
|
335
|
-
readonly description: "Creates a new Supabase project, which can add to the organization's bill. The user must agree to any nonzero quoted cost before the project is created. Unless `confirm_cost_id` is required, call this tool without it and without asking for cost confirmation in chat first. The server handles cost confirmation, or returns instructions for obtaining a confirmation ID. If it requests an ID, follow those instructions and retry with it. A project quoted at $0 may be created without a cost-confirmation form. Always ask the user which organization to create the project in. The project can take a few minutes to initialize
|
|
329
|
+
readonly description: "Creates a new Supabase project, which can add to the organization's bill. The user must agree to any nonzero quoted cost before the project is created. Unless `confirm_cost_id` is required, call this tool without it and without asking for cost confirmation in chat first. The server handles cost confirmation, or returns instructions for obtaining a confirmation ID. If it requests an ID, follow those instructions and retry with it. A project quoted at $0 may be created without a cost-confirmation form. Always ask the user which organization to create the project in. The project can take a few minutes to initialize. Call `get_project`, waiting a few seconds between checks, until `status` is `ACTIVE_HEALTHY` before running SQL, migrations, or other database tools against it. If `status` becomes `INIT_FAILED` or `REMOVED`, stop and tell the user.";
|
|
336
330
|
readonly parameters: z.ZodObject<{
|
|
337
331
|
name: z.ZodString;
|
|
338
332
|
region: z.ZodEnum<{
|
|
@@ -686,18 +680,18 @@ declare const databaseToolDefs: {
|
|
|
686
680
|
|
|
687
681
|
declare const debuggingToolDefs: {
|
|
688
682
|
readonly get_logs: {
|
|
689
|
-
readonly description: "Gets logs for a Supabase project by service type. When the user asks about a specific time range, always pass iso_timestamp_start and iso_timestamp_end to match it; otherwise each call defaults to the last 24 hours and will return logs from a wider window than intended. The window
|
|
683
|
+
readonly description: "Gets logs for a Supabase project by service type. When the user asks about a specific time range, always pass iso_timestamp_start and iso_timestamp_end to match it; otherwise each call defaults to the last 24 hours and will return logs from a wider window than intended. The window must be 24 hours or less and iso_timestamp_start must be before iso_timestamp_end; other windows are rejected. If you pass only iso_timestamp_start, the end defaults to now, so for a past time range pass both timestamps. For a longer range, make one call per 24-hour slice. Edge Function logs are split by kind: `edge-function` returns invocation/request logs, while `edge-function-runtime` returns console output from inside the function. Query one service first, then correlate with other services by timestamp or error anchors. Do not poll get_logs in a loop.";
|
|
690
684
|
readonly parameters: z.ZodObject<{
|
|
691
685
|
project_id: z.ZodString;
|
|
692
686
|
service: z.ZodEnum<{
|
|
693
|
-
auth: "auth";
|
|
694
|
-
realtime: "realtime";
|
|
695
687
|
storage: "storage";
|
|
696
688
|
api: "api";
|
|
697
689
|
"branch-action": "branch-action";
|
|
698
690
|
postgres: "postgres";
|
|
699
691
|
"edge-function": "edge-function";
|
|
700
692
|
"edge-function-runtime": "edge-function-runtime";
|
|
693
|
+
auth: "auth";
|
|
694
|
+
realtime: "realtime";
|
|
701
695
|
}>;
|
|
702
696
|
iso_timestamp_start: z.ZodOptional<z.ZodISODateTime>;
|
|
703
697
|
iso_timestamp_end: z.ZodOptional<z.ZodISODateTime>;
|
|
@@ -934,7 +928,7 @@ ${string}`;
|
|
|
934
928
|
|
|
935
929
|
declare const feedbackToolDefs: {
|
|
936
930
|
readonly submit_feedback: {
|
|
937
|
-
readonly description: "Sends feedback about Supabase tools to the Supabase team. Use it when the user asks, or when you hit a bug
|
|
931
|
+
readonly description: "Sends feedback about Supabase tools or documentation to the Supabase team. Use it when the user asks, or when you hit a bug, a missing capability, or a wrong docs page. Ask the user before sending feedback they didn't request. Never include secrets, personal data, or database contents. Keep it to 1000 characters or fewer. Show the user the returned delete token.";
|
|
938
932
|
readonly parameters: z.ZodObject<{
|
|
939
933
|
feedback: z.ZodString;
|
|
940
934
|
project_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
@@ -982,11 +976,11 @@ declare const notebookToolDefs: {
|
|
|
982
976
|
text: z.ZodString;
|
|
983
977
|
}, z.core.$strict>, z.ZodObject<{
|
|
984
978
|
type: z.ZodLiteral<"database">;
|
|
979
|
+
title: z.ZodOptional<z.ZodString>;
|
|
985
980
|
view: z.ZodOptional<z.ZodEnum<{
|
|
986
981
|
table: "table";
|
|
987
982
|
chart: "chart";
|
|
988
983
|
}>>;
|
|
989
|
-
title: z.ZodOptional<z.ZodString>;
|
|
990
984
|
sql: z.ZodString;
|
|
991
985
|
row_limit: z.ZodNumber;
|
|
992
986
|
database_identifier: z.ZodOptional<z.ZodString>;
|
|
@@ -1008,11 +1002,11 @@ declare const notebookToolDefs: {
|
|
|
1008
1002
|
}, z.core.$strict>>;
|
|
1009
1003
|
}, z.core.$strict>, z.ZodObject<{
|
|
1010
1004
|
type: z.ZodLiteral<"log">;
|
|
1005
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1011
1006
|
view: z.ZodOptional<z.ZodEnum<{
|
|
1012
1007
|
table: "table";
|
|
1013
1008
|
chart: "chart";
|
|
1014
1009
|
}>>;
|
|
1015
|
-
title: z.ZodOptional<z.ZodString>;
|
|
1016
1010
|
sql: z.ZodString;
|
|
1017
1011
|
time_range: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1018
1012
|
type: z.ZodLiteral<"absolute">;
|
|
@@ -1050,8 +1044,8 @@ declare const notebookToolDefs: {
|
|
|
1050
1044
|
}, z.core.$strip>;
|
|
1051
1045
|
}, z.core.$strip>;
|
|
1052
1046
|
readonly outputSchema: z.ZodObject<{
|
|
1053
|
-
name: z.ZodString;
|
|
1054
1047
|
id: z.ZodString;
|
|
1048
|
+
name: z.ZodString;
|
|
1055
1049
|
updated_at: z.ZodString;
|
|
1056
1050
|
url: z.ZodString;
|
|
1057
1051
|
}, z.core.$strip>;
|
|
@@ -1160,8 +1154,8 @@ declare const notebookToolDefs: {
|
|
|
1160
1154
|
notebook_id: z.ZodString;
|
|
1161
1155
|
}, z.core.$strip>;
|
|
1162
1156
|
readonly outputSchema: z.ZodObject<{
|
|
1163
|
-
name: z.ZodString;
|
|
1164
1157
|
id: z.ZodString;
|
|
1158
|
+
name: z.ZodString;
|
|
1165
1159
|
}, z.core.$strip>;
|
|
1166
1160
|
readonly annotations: {
|
|
1167
1161
|
readonly title: "Delete notebook";
|
|
@@ -1338,11 +1332,11 @@ declare const supabaseMcpToolSchemas: {
|
|
|
1338
1332
|
text: z.ZodString;
|
|
1339
1333
|
}, z.core.$strict>, z.ZodObject<{
|
|
1340
1334
|
type: z.ZodLiteral<"database">;
|
|
1335
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1341
1336
|
view: z.ZodOptional<z.ZodEnum<{
|
|
1342
1337
|
table: "table";
|
|
1343
1338
|
chart: "chart";
|
|
1344
1339
|
}>>;
|
|
1345
|
-
title: z.ZodOptional<z.ZodString>;
|
|
1346
1340
|
sql: z.ZodString;
|
|
1347
1341
|
row_limit: z.ZodNumber;
|
|
1348
1342
|
database_identifier: z.ZodOptional<z.ZodString>;
|
|
@@ -1364,11 +1358,11 @@ declare const supabaseMcpToolSchemas: {
|
|
|
1364
1358
|
}, z.core.$strict>>;
|
|
1365
1359
|
}, z.core.$strict>, z.ZodObject<{
|
|
1366
1360
|
type: z.ZodLiteral<"log">;
|
|
1361
|
+
title: z.ZodOptional<z.ZodString>;
|
|
1367
1362
|
view: z.ZodOptional<z.ZodEnum<{
|
|
1368
1363
|
table: "table";
|
|
1369
1364
|
chart: "chart";
|
|
1370
1365
|
}>>;
|
|
1371
|
-
title: z.ZodOptional<z.ZodString>;
|
|
1372
1366
|
sql: z.ZodString;
|
|
1373
1367
|
time_range: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1374
1368
|
type: z.ZodLiteral<"absolute">;
|
|
@@ -1406,8 +1400,8 @@ declare const supabaseMcpToolSchemas: {
|
|
|
1406
1400
|
}, z.core.$strip>;
|
|
1407
1401
|
}, z.core.$strip>;
|
|
1408
1402
|
outputSchema: z.ZodObject<{
|
|
1409
|
-
name: z.ZodString;
|
|
1410
1403
|
id: z.ZodString;
|
|
1404
|
+
name: z.ZodString;
|
|
1411
1405
|
updated_at: z.ZodString;
|
|
1412
1406
|
url: z.ZodString;
|
|
1413
1407
|
}, z.core.$strip>;
|
|
@@ -1519,8 +1513,8 @@ declare const supabaseMcpToolSchemas: {
|
|
|
1519
1513
|
notebook_id: z.ZodString;
|
|
1520
1514
|
}, z.core.$strip>;
|
|
1521
1515
|
outputSchema: z.ZodObject<{
|
|
1522
|
-
name: z.ZodString;
|
|
1523
1516
|
id: z.ZodString;
|
|
1517
|
+
name: z.ZodString;
|
|
1524
1518
|
}, z.core.$strip>;
|
|
1525
1519
|
annotations: {
|
|
1526
1520
|
readonly title: "Delete notebook";
|
|
@@ -1809,14 +1803,14 @@ declare const supabaseMcpToolSchemas: {
|
|
|
1809
1803
|
inputSchema: z.ZodObject<{
|
|
1810
1804
|
project_id: z.ZodString;
|
|
1811
1805
|
service: z.ZodEnum<{
|
|
1812
|
-
auth: "auth";
|
|
1813
|
-
realtime: "realtime";
|
|
1814
1806
|
storage: "storage";
|
|
1815
1807
|
api: "api";
|
|
1816
1808
|
"branch-action": "branch-action";
|
|
1817
1809
|
postgres: "postgres";
|
|
1818
1810
|
"edge-function": "edge-function";
|
|
1819
1811
|
"edge-function-runtime": "edge-function-runtime";
|
|
1812
|
+
auth: "auth";
|
|
1813
|
+
realtime: "realtime";
|
|
1820
1814
|
}>;
|
|
1821
1815
|
iso_timestamp_start: z.ZodOptional<z.ZodISODateTime>;
|
|
1822
1816
|
iso_timestamp_end: z.ZodOptional<z.ZodISODateTime>;
|
|
@@ -2464,4 +2458,4 @@ declare function createToolSchemas<const Features extends readonly FeatureGroup[
|
|
|
2464
2458
|
|
|
2465
2459
|
declare const version: string;
|
|
2466
2460
|
|
|
2467
|
-
export { CURRENT_ELICITATION_TOOLS, CURRENT_FEATURE_GROUPS, type ConfirmationFeature, type ElicitationToolName, type FeatureGroup, FeedbackOperations, type FeedbackOperationsOptions, type ObservationContext, type ObservationFact, type ObservedTool, type RequestObservation, type RequestObserver, type SupabaseMcpServerOptions, SupabasePlatform,
|
|
2461
|
+
export { CURRENT_ELICITATION_TOOLS, CURRENT_FEATURE_GROUPS, type ConfirmationFeature, type ElicitationToolName, type FeatureGroup, FeedbackOperations, type FeedbackOperationsOptions, type ObservationContext, type ObservationFact, type ObservedTool, type RequestObservation, type RequestObserver, type SupabaseMcpServerOptions, SupabasePlatform, createFeedbackOperations, createSupabaseMcpHandler, createSupabaseMcpServer, createToolSchemas, supabaseMcpToolSchemas, version };
|