{"version":3,"sources":["/home/runner/work/supabase-mcp/supabase-mcp/packages/mcp-server-supabase/dist/index.cjs","../src/tools/tool-schemas.ts","../src/index.ts"],"names":["defsToSchemas","defs","name","inputSchema","_","rest","supabaseMcpToolSchemas","accountToolDefs","branchingToolDefs","databaseToolDefs","debuggingToolDefs","developmentToolDefs","docsToolDefs","edgeFunctionToolDefs","storageToolDefs","FEATURE_TOOL_MAP","PROJECT_SCOPED_OVERRIDES","writeToolSet","entry","createToolSchemas","options","enabledFeatures","CURRENT_FEATURE_GROUPS","projectScoped","readOnly","result","feature","toolNames","toolName","version","package_default"],"mappings":"AAAA,yuBAAwF,wDAAyC,gCAA6B,SCyBrJA,CAAAA,CAAwCC,CAAAA,CAA2B,CAC1E,OAAO,MAAA,CAAO,WAAA,CACZ,MAAA,CAAO,OAAA,CAAQA,CAAI,CAAA,CAAE,GAAA,CACnB,CAAC,CAACC,CAAAA,CAAM,CAAE,UAAA,CAAYC,CAAAA,CAAa,WAAA,CAAaC,CAAAA,CAAG,GAAGC,CAAK,CAAC,CAAA,CAAA,EAAM,CAChEH,CAAAA,CACA,CAAE,WAAA,CAAAC,CAAAA,CAAa,GAAGE,CAAK,CACzB,CACF,CACF,CACF,CAyBO,IAAMC,CAAAA,CAAyB,CACpC,GAAGN,CAAAA,CAAcO,mBAAe,CAAA,CAChC,GAAGP,CAAAA,CAAcQ,mBAAiB,CAAA,CAClC,GAAGR,CAAAA,CAAcS,mBAAgB,CAAA,CACjC,GAAGT,CAAAA,CAAcU,mBAAiB,CAAA,CAClC,GAAGV,CAAAA,CAAcW,mBAAmB,CAAA,CACpC,GAAGX,CAAAA,CAAcY,mBAAY,CAAA,CAC7B,GAAGZ,CAAAA,CAAca,mBAAoB,CAAA,CACrC,GAAGb,CAAAA,CAAcc,mBAAe,CAClC,CAAA,CASMC,CAAAA,CAAmB,CACvB,IAAA,CAAM,MAAA,CAAO,IAAA,CAAKH,mBAAY,CAAA,CAC9B,OAAA,CAAS,MAAA,CAAO,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AAA,SAAYE,qBACvB,CAAA,CACMC,CAAAA,kCAAgBH,CAAAA,6BAAS,eAAA,SAAiB,CAAA,GAAA,CAC1CI,CAAAA,kCAAWJ,CAAAA,6BAAS,UAAA,SAAY,CAAA,GAAA,CAEhCK,CAAAA,CAAsC,CAAC,CAAA,CAE7C,GAAA,CAAA,GAAW,CAACC,CAAAA,CAASC,CAAS,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQZ,CAAgB,CAAA,CAChE,EAAA,CAAKM,CAAAA,CAAgB,GAAA,CAAIK,CAAO,CAAA,EAC5B,CAAA,CAAAH,CAAAA,EAAiBG,CAAAA,GAAY,SAAA,CAAA,CAEjC,GAAA,CAAA,IAAWE,EAAAA,GAAYD,CAAAA,CACjBH,CAAAA,EAAYP,CAAAA,CAAa,GAAA,CAAIW,CAAQ,CAAA,EAAA,CAErCL,CAAAA,EAAiBK,EAAAA,GAAYZ,CAAAA,CAC/BS,CAAAA,CAAOG,CAAQ,CAAA,CAAIZ,CAAAA,CAAyBY,CAAQ,CAAA,CAEpDH,CAAAA,CAAOG,CAAQ,CAAA,CAAItB,CAAAA,CAAuBsB,CAAQ,CAAA,CAAA,CAKxD,OAAOH,CACT,CCpQO,IAAMI,CAAAA,CAAUC,mBAAAA,CAAY,OAAA,CAAA,oMAAA","file":"/home/runner/work/supabase-mcp/supabase-mcp/packages/mcp-server-supabase/dist/index.cjs","sourcesContent":[null,"import type { z } from 'zod/v4';\nimport { CURRENT_FEATURE_GROUPS, type FeatureGroup } from '../types.js';\nimport { accountToolDefs } from './account-tools.js';\nimport { branchingToolDefs } from './branching-tools.js';\nimport { databaseToolDefs } from './database-operation-tools.js';\nimport { debuggingToolDefs } from './debugging-tools.js';\nimport { developmentToolDefs } from './development-tools.js';\nimport { docsToolDefs } from './docs-tools.js';\nimport { edgeFunctionToolDefs } from './edge-function-tools.js';\nimport { storageToolDefs } from './storage-tools.js';\nimport type { ToolDefs } from './util.js';\n\ntype DefsToSchemas = {\n [K in keyof T]: {\n inputSchema: T[K]['parameters'];\n outputSchema: T[K]['outputSchema'];\n annotations: T[K]['annotations'];\n readOnlyBehavior: T[K] extends {\n readOnlyBehavior: infer R extends 'exclude' | 'adapt';\n }\n ? R\n : undefined;\n };\n};\n\nfunction defsToSchemas(defs: T): DefsToSchemas {\n return Object.fromEntries(\n Object.entries(defs).map(\n ([name, { parameters: inputSchema, description: _, ...rest }]) => [\n name,\n { inputSchema, ...rest },\n ]\n )\n ) as DefsToSchemas;\n}\n\ntype SchemaEntry = {\n inputSchema: z.ZodObject;\n outputSchema: z.ZodObject;\n annotations: ToolDefs[string]['annotations'];\n readOnlyBehavior?: 'exclude' | 'adapt';\n};\n\n/**\n * All Supabase MCP tool schemas (input + output pairs).\n *\n * Pass to AI SDK's `mcpClient.tools()` `schemas` option to get typed tool\n * inputs and outputs:\n * https://ai-sdk.dev/docs/ai-sdk-core/mcp-tools#typed-tool-outputs\n *\n * @example\n * ```typescript\n * import { supabaseMcpToolSchemas } from '@supabase/mcp-server-supabase';\n *\n * const tools = await mcpClient.tools({\n * schemas: supabaseMcpToolSchemas,\n * });\n * ```\n */\nexport const supabaseMcpToolSchemas = {\n ...defsToSchemas(accountToolDefs),\n ...defsToSchemas(branchingToolDefs),\n ...defsToSchemas(databaseToolDefs),\n ...defsToSchemas(debuggingToolDefs),\n ...defsToSchemas(developmentToolDefs),\n ...defsToSchemas(docsToolDefs),\n ...defsToSchemas(edgeFunctionToolDefs),\n ...defsToSchemas(storageToolDefs),\n} satisfies Record;\n\n/**\n * Maps each feature group to its tool names.\n * Derived from the per-file tool defs so that adding a tool to a file\n * automatically includes it in the feature group.\n *\n * Used by {@link createToolSchemas} to filter tools by feature.\n */\nconst FEATURE_TOOL_MAP = {\n docs: Object.keys(docsToolDefs) as readonly (keyof typeof docsToolDefs)[],\n account: Object.keys(\n accountToolDefs\n ) as readonly (keyof typeof accountToolDefs)[],\n database: Object.keys(\n databaseToolDefs\n ) as readonly (keyof typeof databaseToolDefs)[],\n debugging: Object.keys(\n debuggingToolDefs\n ) as readonly (keyof typeof debuggingToolDefs)[],\n development: Object.keys(\n developmentToolDefs\n ) as readonly (keyof typeof developmentToolDefs)[],\n functions: Object.keys(\n edgeFunctionToolDefs\n ) as readonly (keyof typeof edgeFunctionToolDefs)[],\n branching: Object.keys(\n branchingToolDefs\n ) as readonly (keyof typeof branchingToolDefs)[],\n storage: Object.keys(\n storageToolDefs\n ) as readonly (keyof typeof storageToolDefs)[],\n} satisfies Record<\n FeatureGroup,\n readonly (keyof typeof supabaseMcpToolSchemas)[]\n>;\n\n/**\n * Schemas with `project_id` omitted from input schemas.\n * Computed dynamically: any tool whose inputSchema has a `project_id`\n * key gets an override with that key omitted.\n *\n * Account tools also appear here but are excluded entirely in\n * project-scoped mode (matching server behavior).\n *\n * Used by {@link createToolSchemas} when `projectScoped` is true.\n */\nconst PROJECT_SCOPED_OVERRIDES: Record =\n Object.fromEntries(\n Object.entries(supabaseMcpToolSchemas)\n .filter(([, { inputSchema }]) => 'project_id' in inputSchema.shape)\n .map(([name, { inputSchema, ...rest }]) => [\n name,\n {\n inputSchema: (inputSchema as z.ZodObject).omit({\n project_id: true,\n }),\n ...rest,\n },\n ])\n );\n\n/**\n * Tools excluded entirely in read-only mode.\n * Derived from tool defs: any tool with `readOnlyHint: false` and no\n * `readOnlyBehavior: 'adapt'` annotation.\n */\nconst writeToolSet = new Set(\n Object.entries(supabaseMcpToolSchemas)\n .filter(\n ([, entry]) =>\n entry.annotations.readOnlyHint === false &&\n entry.readOnlyBehavior !== 'adapt'\n )\n .map(([name]) => name)\n);\n\ntype AllSchemas = typeof supabaseMcpToolSchemas;\n\n/** Tool names whose inputSchema contains `project_id`. */\ntype ProjectScopedToolName = {\n [K in keyof AllSchemas]: 'project_id' extends keyof z.infer<\n AllSchemas[K]['inputSchema']\n >\n ? K\n : never;\n}[keyof AllSchemas];\n\ntype ProjectScopedSchemas = {\n [K in ProjectScopedToolName]: {\n inputSchema: AllSchemas[K]['inputSchema'] extends z.ZodObject\n ? z.ZodObject>\n : never;\n outputSchema: AllSchemas[K]['outputSchema'];\n annotations: AllSchemas[K]['annotations'];\n };\n};\n\ntype ToolNameForFeature =\n (typeof FEATURE_TOOL_MAP)[Feature][number];\n\ntype AccountToolName = ToolNameForFeature<'account'>;\ntype WriteToolName = {\n [K in keyof AllSchemas]: AllSchemas[K]['annotations'] extends {\n readOnlyHint: false;\n }\n ? AllSchemas[K] extends { readOnlyBehavior: 'adapt' }\n ? never\n : K\n : never;\n}[keyof AllSchemas];\n\n/**\n * Computes the set of tool names available for a given configuration.\n *\n * - Resolves feature groups to their tool names\n * - Excludes account tools when project-scoped\n * - Excludes write-only tools when read-only\n */\ntype AvailableToolNames<\n Feature extends FeatureGroup,\n ProjectScoped extends boolean,\n ReadOnly extends boolean,\n> = Exclude<\n ToolNameForFeature,\n | (ProjectScoped extends true ? AccountToolName : never)\n | (ReadOnly extends true ? WriteToolName : never)\n>;\n\n/**\n * Computes the tool schemas for a given configuration.\n *\n * When `ProjectScoped` is `true`, tools with `project_id` use the\n * project-scoped override (with `project_id` omitted from the input\n * schema). All other tools use their original schemas.\n */\ntype ToolSchemasFor<\n Feature extends FeatureGroup,\n ProjectScoped extends boolean,\n ReadOnly extends boolean,\n> = Pick<\n ProjectScoped extends true\n ? Omit & ProjectScopedSchemas\n : AllSchemas,\n AvailableToolNames & keyof AllSchemas\n>;\n\n/**\n * Creates a dynamically scoped tool schema map for use with AI SDK's\n * `mcpClient.tools()`.\n *\n * Mirrors the server's dynamic tool behavior:\n * - `features` controls which tool groups are included\n * - `projectScoped` omits `project_id` from input schemas and excludes\n * account tools (matching server behavior when `projectId` is set)\n * - `readOnly` excludes mutating tools\n *\n * @example\n * ```typescript\n * import { createToolSchemas } from '@supabase/mcp-server-supabase';\n *\n * // Project-scoped with specific features\n * const schemas = createToolSchemas({\n * features: ['database', 'docs'],\n * projectScoped: true,\n * });\n *\n * const tools = await mcpClient.tools({ schemas });\n * ```\n */\nexport function createToolSchemas<\n const Features extends\n readonly FeatureGroup[] = typeof CURRENT_FEATURE_GROUPS,\n const ProjectScoped extends boolean = false,\n const ReadOnly extends boolean = false,\n>(options?: {\n features?: Features;\n projectScoped?: ProjectScoped;\n readOnly?: ReadOnly;\n}): ToolSchemasFor {\n const enabledFeatures = new Set(\n options?.features ?? CURRENT_FEATURE_GROUPS\n );\n const projectScoped = options?.projectScoped ?? false;\n const readOnly = options?.readOnly ?? false;\n\n const result: Record = {};\n\n for (const [feature, toolNames] of Object.entries(FEATURE_TOOL_MAP)) {\n if (!enabledFeatures.has(feature)) continue;\n if (projectScoped && feature === 'account') continue;\n\n for (const toolName of toolNames) {\n if (readOnly && writeToolSet.has(toolName)) continue;\n\n if (projectScoped && toolName in PROJECT_SCOPED_OVERRIDES) {\n result[toolName] = PROJECT_SCOPED_OVERRIDES[toolName]!;\n } else {\n result[toolName] = supabaseMcpToolSchemas[toolName];\n }\n }\n }\n\n return result as ToolSchemasFor;\n}\n","import packageJson from '../package.json' with { type: 'json' };\n\nexport type { ToolCallCallback } from '@supabase/mcp-utils';\nexport type { SupabasePlatform } from './platform/index.js';\nexport {\n createSupabaseMcpServer,\n type SupabaseMcpServerOptions,\n} from './server.js';\nexport {\n CURRENT_FEATURE_GROUPS,\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"]}