@supabase/mcp-server-supabase 0.1.0-dev.1
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-5UWVQOB5.cjs +2 -0
- package/dist/chunk-5UWVQOB5.cjs.map +1 -0
- package/dist/chunk-7LUZJGP3.js +2 -0
- package/dist/chunk-7LUZJGP3.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +37 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/sse.cjs +3 -0
- package/dist/sse.cjs.map +1 -0
- package/dist/sse.d.cts +1 -0
- package/dist/sse.d.ts +1 -0
- package/dist/sse.js +3 -0
- package/dist/sse.js.map +1 -0
- package/dist/stdio.cjs +3 -0
- package/dist/stdio.cjs.map +1 -0
- package/dist/stdio.d.cts +1 -0
- package/dist/stdio.d.ts +1 -0
- package/dist/stdio.js +3 -0
- package/dist/stdio.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _base = require('@gregnr/postgres-meta/base');var _mcputils = require('@supabase/mcp-utils');var _zod = require('zod');var c="0.1.0-dev.1";var _openapifetch = require('openapi-fetch'); var _openapifetch2 = _interopRequireDefault(_openapifetch);function l(i,p,a={}){return _openapifetch2.default.call(void 0, {baseUrl:i,headers:{"Content-Type":"application/json",Authorization:`Bearer ${p}`,...a}})}function z(i){let p=_nullishCoalesce(i.platform.apiUrl, () => ("https://api.supabase.com")),a;async function d(e,r){let s=await a.POST("/v1/projects/{ref}/database/query",{params:{path:{ref:e}},body:{query:r}});if(!s.response.ok)throw new Error("Failed to execute SQL query");return s.data}function u(e){return new (0, _base.PostgresMetaBase)({query:async r=>{try{let s=await d(e,r);return _base.wrapResult.call(void 0, s)}catch(s){return _base.wrapError.call(void 0, s,r)}},end:async()=>{}})}return _mcputils.createMcpServer.call(void 0, {name:"supabase",version:c,onInitialize(e){a=l(p,i.platform.accessToken,{"User-Agent":`supabase-mcp/${c} (${e.name}/${e.version})`})},tools:{get_projects:_mcputils.tool.call(void 0, {description:"Gets all Supabase projects for the user.",parameters:_zod.z.object({}),execute:async()=>{let e=await a.GET("/v1/projects");if(!e.response.ok)throw new Error("Failed to fetch projects");return e.data}}),get_organizations:_mcputils.tool.call(void 0, {description:"Gets all organizations for the user.",parameters:_zod.z.object({}),execute:async()=>{let e=await a.GET("/v1/organizations");if(!e.response.ok)throw new Error("Failed to fetch organizations");return e.data}}),get_organization:_mcputils.tool.call(void 0, {description:"Gets an organization by ID.",parameters:_zod.z.object({id:_zod.z.string().describe("The organization ID")}),execute:async({id:e})=>{let r=await a.GET("/v1/organizations/{slug}",{params:{path:{slug:e}}});if(!r.response.ok)throw new Error("Failed to fetch organization");return r.data}}),get_tables:_mcputils.tool.call(void 0, {description:"Gets all tables in a schema.",parameters:_zod.z.object({projectId:_zod.z.string(),schemas:_zod.z.optional(_zod.z.array(_zod.z.string())).describe("Optional list of schemas to include. Defaults to all schemas.")}),execute:async({projectId:e,schemas:r})=>{let s=u(e),{data:o,error:m}=await s.tables.list({includedSchemas:r});if(m)throw new Error(`Error fetching tables: ${m.message}`);return o}}),get_extensions:_mcputils.tool.call(void 0, {description:"Gets all extensions in the database.",parameters:_zod.z.object({projectId:_zod.z.string()}),execute:async({projectId:e})=>{let r=u(e),{data:s,error:o}=await r.extensions.list();if(o)throw new Error(`Error fetching extensions: ${o.message}`);return s}}),apply_migration:_mcputils.tool.call(void 0, {description:"Applies a migration to the database. Use this when executing DDL operations.",parameters:_zod.z.object({projectId:_zod.z.string(),name:_zod.z.string().describe("The name of the migration in snake_case"),query:_zod.z.string().describe("The SQL query to apply")}),execute:async({projectId:e,name:r,query:s})=>{let o=await a.POST("/v1/projects/{ref}/database/migrations",{params:{path:{ref:e}},body:{name:r,query:s}});if(!o.response.ok)throw new Error("Failed to apply migration");return o.data}}),execute_sql:_mcputils.tool.call(void 0, {description:"Executes raw SQL in the Postgres database. Use `applyMigration` instead for DDL operations.",parameters:_zod.z.object({projectId:_zod.z.string(),query:_zod.z.string().describe("The SQL query to execute")}),execute:async({query:e,projectId:r})=>await d(r,e)}),get_project_url:_mcputils.tool.call(void 0, {description:"Gets the API URL for a project.",parameters:_zod.z.object({projectId:_zod.z.string()}),execute:async({projectId:e})=>`https://${e}.supabase.co`}),get_anon_key:_mcputils.tool.call(void 0, {description:"Gets the anonymous API key for a project.",parameters:_zod.z.object({projectId:_zod.z.string()}),execute:async({projectId:e})=>{let r=await a.GET("/v1/projects/{ref}/api-keys",{params:{path:{ref:e},query:{reveal:!1}}});if(!r.response.ok)throw new Error("Failed to fetch API keys");let s=_optionalChain([r, 'access', _ => _.data, 'optionalAccess', _2 => _2.find, 'call', _3 => _3(o=>o.name==="anon")]);if(!s)throw new Error("Anonymous key not found");return s.api_key}}),generate_typescript_types:_mcputils.tool.call(void 0, {description:"Generates TypeScript types for a project.",parameters:_zod.z.object({projectId:_zod.z.string()}),execute:async({projectId:e})=>{let r=await a.GET("/v1/projects/{ref}/types/typescript",{params:{path:{ref:e}}});if(!r.response.ok)throw new Error("Failed to fetch TypeScript types");return r.data}})}})}exports.a = z;
|
|
2
|
+
//# sourceMappingURL=chunk-5UWVQOB5.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server.ts","../package.json","../src/management-api/index.ts"],"names":["version","createManagementApiClient","baseUrl","accessToken","headers","createClient"],"mappings":"AAAA,m0BAIO,+CAC+B,0BACpB,ICJhBA,CAAAA,CAAW,aAAA,CCFb,yGAA0C,SAG1BC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAAkC,CAAC,CAAA,CACnC,CACA,OAAOC,oCAAAA,CACL,OAAA,CAAAH,CAAAA,CACA,OAAA,CAAS,CACP,cAAA,CAAgB,kBAAA,CAChB,aAAA,CAAe,CAAA,OAAA,EAAUC,CAAW,CAAA,CAAA","file":"/Users/grichardson/Documents/dev/supabase/mcp-server-supabase/packages/mcp-server-supabase/dist/chunk-5UWVQOB5.cjs","sourcesContent":["import {\n PostgresMetaBase,\n wrapError,\n wrapResult,\n} from '@gregnr/postgres-meta/base';\nimport { createMcpServer, tool } from '@supabase/mcp-utils';\nimport { z } from 'zod';\nimport { version } from '../package.json';\nimport {\n createManagementApiClient,\n type ManagementApiClient,\n} from './management-api/index.js';\n\nexport type SupabasePlatformOptions = {\n apiUrl?: string;\n accessToken: string;\n};\n\nexport type SupabaseMcpServerOptions = {\n platform: SupabasePlatformOptions;\n};\n\n/**\n * Creates an MCP server for interacting with Supabase.\n */\nexport function createSupabaseMcpServer(options: SupabaseMcpServerOptions) {\n const managementApiUrl =\n options.platform.apiUrl ?? 'https://api.supabase.com';\n\n let managementApiClient: ManagementApiClient;\n\n async function executeSql<T>(projectId: string, query: string): Promise<T[]> {\n const response = await managementApiClient.POST(\n '/v1/projects/{ref}/database/query',\n {\n params: {\n path: {\n ref: projectId,\n },\n },\n body: {\n query,\n },\n }\n );\n\n if (!response.response.ok) {\n throw new Error('Failed to execute SQL query');\n }\n\n return response.data as unknown as T[];\n }\n\n function createPGMeta(projectId: string) {\n return new PostgresMetaBase({\n query: async (sql) => {\n try {\n const res = await executeSql(projectId, sql);\n return wrapResult<any[]>(res);\n } catch (error) {\n return wrapError(error, sql);\n }\n },\n end: async () => {},\n });\n }\n\n const server = createMcpServer({\n name: 'supabase',\n version,\n onInitialize(clientInfo) {\n managementApiClient = createManagementApiClient(\n managementApiUrl,\n options.platform.accessToken,\n {\n 'User-Agent': `supabase-mcp/${version} (${clientInfo.name}/${clientInfo.version})`,\n }\n );\n },\n\n // Note: tools are intentionally snake_case to align better with most MCP clients\n tools: {\n get_projects: tool({\n description: 'Gets all Supabase projects for the user.',\n parameters: z.object({}),\n execute: async () => {\n const response = await managementApiClient.GET('/v1/projects');\n\n if (!response.response.ok) {\n throw new Error(`Failed to fetch projects`);\n }\n\n return response.data;\n },\n }),\n get_organizations: tool({\n description: 'Gets all organizations for the user.',\n parameters: z.object({}),\n execute: async () => {\n const response = await managementApiClient.GET('/v1/organizations');\n\n if (!response.response.ok) {\n throw new Error('Failed to fetch organizations');\n }\n\n return response.data;\n },\n }),\n get_organization: tool({\n description: 'Gets an organization by ID.',\n parameters: z.object({\n id: z.string().describe('The organization ID'),\n }),\n execute: async ({ id: organizationId }) => {\n const response = await managementApiClient.GET(\n '/v1/organizations/{slug}',\n {\n params: {\n path: {\n slug: organizationId,\n },\n },\n }\n );\n\n if (!response.response.ok) {\n throw new Error('Failed to fetch organization');\n }\n\n return response.data;\n },\n }),\n get_tables: tool({\n description: 'Gets all tables in a schema.',\n parameters: z.object({\n projectId: z.string(),\n schemas: z\n .optional(z.array(z.string()))\n .describe(\n 'Optional list of schemas to include. Defaults to all schemas.'\n ),\n }),\n execute: async ({ projectId, schemas }) => {\n const pgMeta = createPGMeta(projectId);\n const { data, error } = await pgMeta.tables.list({\n includedSchemas: schemas,\n });\n\n if (error) {\n throw new Error(`Error fetching tables: ${error.message}`);\n }\n return data;\n },\n }),\n get_extensions: tool({\n description: 'Gets all extensions in the database.',\n parameters: z.object({\n projectId: z.string(),\n }),\n execute: async ({ projectId }) => {\n const pgMeta = createPGMeta(projectId);\n const { data, error } = await pgMeta.extensions.list();\n\n if (error) {\n throw new Error(`Error fetching extensions: ${error.message}`);\n }\n return data;\n },\n }),\n apply_migration: tool({\n description:\n 'Applies a migration to the database. Use this when executing DDL operations.',\n parameters: z.object({\n projectId: z.string(),\n name: z.string().describe('The name of the migration in snake_case'),\n query: z.string().describe('The SQL query to apply'),\n }),\n execute: async ({ projectId, name, query }) => {\n const response = await managementApiClient.POST(\n '/v1/projects/{ref}/database/migrations',\n {\n params: {\n path: {\n ref: projectId,\n },\n },\n body: {\n name,\n query,\n },\n } as any // TODO: remove once API spec updated to include body\n );\n\n if (!response.response.ok) {\n throw new Error('Failed to apply migration');\n }\n\n return response.data;\n },\n }),\n execute_sql: tool({\n description:\n 'Executes raw SQL in the Postgres database. Use `applyMigration` instead for DDL operations.',\n parameters: z.object({\n projectId: z.string(),\n query: z.string().describe('The SQL query to execute'),\n }),\n execute: async ({ query, projectId }) => {\n return await executeSql(projectId, query);\n },\n }),\n get_project_url: tool({\n description: 'Gets the API URL for a project.',\n parameters: z.object({\n projectId: z.string(),\n }),\n execute: async ({ projectId }) => {\n return `https://${projectId}.supabase.co`;\n },\n }),\n get_anon_key: tool({\n description: 'Gets the anonymous API key for a project.',\n parameters: z.object({\n projectId: z.string(),\n }),\n execute: async ({ projectId }) => {\n const response = await managementApiClient.GET(\n '/v1/projects/{ref}/api-keys',\n {\n params: {\n path: {\n ref: projectId,\n },\n query: {\n reveal: false,\n },\n },\n }\n );\n\n if (!response.response.ok) {\n throw new Error('Failed to fetch API keys');\n }\n\n const anonKey = response.data?.find((key) => key.name === 'anon');\n\n if (!anonKey) {\n throw new Error('Anonymous key not found');\n }\n\n return anonKey.api_key;\n },\n }),\n generate_typescript_types: tool({\n description: 'Generates TypeScript types for a project.',\n parameters: z.object({\n projectId: z.string(),\n }),\n execute: async ({ projectId }) => {\n const response = await managementApiClient.GET(\n '/v1/projects/{ref}/types/typescript',\n {\n params: {\n path: {\n ref: projectId,\n },\n },\n }\n );\n\n if (!response.response.ok) {\n throw new Error('Failed to fetch TypeScript types');\n }\n\n return response.data;\n },\n }),\n },\n });\n\n return server;\n}\n","{\n \"name\": \"@supabase/mcp-server-supabase\",\n \"version\": \"0.1.0-dev.1\",\n \"description\": \"MCP server for interacting with Supabase\",\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"types\": \"dist/index.d.ts\",\n \"sideEffects\": false,\n \"scripts\": {\n \"build\": \"tsup --clean\",\n \"prepublishOnly\": \"npm run build\",\n \"test\": \"vitest\",\n \"generate:management-api-types\": \"openapi-typescript https://api.supabase.com/api/v1-json -o ./src/management-api/types.ts\"\n },\n \"files\": [\n \"dist/**/*\"\n ],\n \"bin\": {\n \"mcp-server-supabase\": \"./dist/stdio.js\"\n },\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"dependencies\": {\n \"@gregnr/postgres-meta\": \"^0.82.0-dev.2\",\n \"@modelcontextprotocol/sdk\": \"^1.4.1\",\n \"@supabase/mcp-utils\": \"0.1.1\",\n \"open\": \"^10.1.0\",\n \"openapi-fetch\": \"^0.13.4\",\n \"postgres\": \"^3.4.5\",\n \"zod\": \"^3.24.1\",\n \"zod-to-json-schema\": \"^3.24.1\"\n },\n \"devDependencies\": {\n \"@electric-sql/pglite\": \"^0.2.17\",\n \"@total-typescript/tsconfig\": \"^1.0.4\",\n \"@types/node\": \"^22.8.6\",\n \"msw\": \"^2.7.3\",\n \"openapi-typescript\": \"^7.5.0\",\n \"prettier\": \"^3.3.3\",\n \"tsup\": \"^8.3.5\",\n \"tsx\": \"^4.19.2\",\n \"typescript\": \"^5.6.3\",\n \"vitest\": \"^2.1.4\"\n }\n}\n","import createClient, { type Client } from 'openapi-fetch';\nimport type { paths } from './types.js';\n\nexport function createManagementApiClient(\n baseUrl: string,\n accessToken: string,\n headers: Record<string, string> = {}\n) {\n return createClient<paths>({\n baseUrl,\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n ...headers,\n },\n });\n}\n\nexport type ManagementApiClient = Client<paths>;\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{PostgresMetaBase as f,wrapError as h,wrapResult as b}from"@gregnr/postgres-meta/base";import{createMcpServer as w,tool as n}from"@supabase/mcp-utils";import{z as t}from"zod";var c="0.1.0-dev.1";import y from"openapi-fetch";function l(i,p,a={}){return y({baseUrl:i,headers:{"Content-Type":"application/json",Authorization:`Bearer ${p}`,...a}})}function z(i){let p=i.platform.apiUrl??"https://api.supabase.com",a;async function d(e,r){let s=await a.POST("/v1/projects/{ref}/database/query",{params:{path:{ref:e}},body:{query:r}});if(!s.response.ok)throw new Error("Failed to execute SQL query");return s.data}function u(e){return new f({query:async r=>{try{let s=await d(e,r);return b(s)}catch(s){return h(s,r)}},end:async()=>{}})}return w({name:"supabase",version:c,onInitialize(e){a=l(p,i.platform.accessToken,{"User-Agent":`supabase-mcp/${c} (${e.name}/${e.version})`})},tools:{get_projects:n({description:"Gets all Supabase projects for the user.",parameters:t.object({}),execute:async()=>{let e=await a.GET("/v1/projects");if(!e.response.ok)throw new Error("Failed to fetch projects");return e.data}}),get_organizations:n({description:"Gets all organizations for the user.",parameters:t.object({}),execute:async()=>{let e=await a.GET("/v1/organizations");if(!e.response.ok)throw new Error("Failed to fetch organizations");return e.data}}),get_organization:n({description:"Gets an organization by ID.",parameters:t.object({id:t.string().describe("The organization ID")}),execute:async({id:e})=>{let r=await a.GET("/v1/organizations/{slug}",{params:{path:{slug:e}}});if(!r.response.ok)throw new Error("Failed to fetch organization");return r.data}}),get_tables:n({description:"Gets all tables in a schema.",parameters:t.object({projectId:t.string(),schemas:t.optional(t.array(t.string())).describe("Optional list of schemas to include. Defaults to all schemas.")}),execute:async({projectId:e,schemas:r})=>{let s=u(e),{data:o,error:m}=await s.tables.list({includedSchemas:r});if(m)throw new Error(`Error fetching tables: ${m.message}`);return o}}),get_extensions:n({description:"Gets all extensions in the database.",parameters:t.object({projectId:t.string()}),execute:async({projectId:e})=>{let r=u(e),{data:s,error:o}=await r.extensions.list();if(o)throw new Error(`Error fetching extensions: ${o.message}`);return s}}),apply_migration:n({description:"Applies a migration to the database. Use this when executing DDL operations.",parameters:t.object({projectId:t.string(),name:t.string().describe("The name of the migration in snake_case"),query:t.string().describe("The SQL query to apply")}),execute:async({projectId:e,name:r,query:s})=>{let o=await a.POST("/v1/projects/{ref}/database/migrations",{params:{path:{ref:e}},body:{name:r,query:s}});if(!o.response.ok)throw new Error("Failed to apply migration");return o.data}}),execute_sql:n({description:"Executes raw SQL in the Postgres database. Use `applyMigration` instead for DDL operations.",parameters:t.object({projectId:t.string(),query:t.string().describe("The SQL query to execute")}),execute:async({query:e,projectId:r})=>await d(r,e)}),get_project_url:n({description:"Gets the API URL for a project.",parameters:t.object({projectId:t.string()}),execute:async({projectId:e})=>`https://${e}.supabase.co`}),get_anon_key:n({description:"Gets the anonymous API key for a project.",parameters:t.object({projectId:t.string()}),execute:async({projectId:e})=>{let r=await a.GET("/v1/projects/{ref}/api-keys",{params:{path:{ref:e},query:{reveal:!1}}});if(!r.response.ok)throw new Error("Failed to fetch API keys");let s=r.data?.find(o=>o.name==="anon");if(!s)throw new Error("Anonymous key not found");return s.api_key}}),generate_typescript_types:n({description:"Generates TypeScript types for a project.",parameters:t.object({projectId:t.string()}),execute:async({projectId:e})=>{let r=await a.GET("/v1/projects/{ref}/types/typescript",{params:{path:{ref:e}}});if(!r.response.ok)throw new Error("Failed to fetch TypeScript types");return r.data}})}})}export{z as a};
|
|
2
|
+
//# sourceMappingURL=chunk-7LUZJGP3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server.ts","../package.json","../src/management-api/index.ts"],"sourcesContent":["import {\n PostgresMetaBase,\n wrapError,\n wrapResult,\n} from '@gregnr/postgres-meta/base';\nimport { createMcpServer, tool } from '@supabase/mcp-utils';\nimport { z } from 'zod';\nimport { version } from '../package.json';\nimport {\n createManagementApiClient,\n type ManagementApiClient,\n} from './management-api/index.js';\n\nexport type SupabasePlatformOptions = {\n apiUrl?: string;\n accessToken: string;\n};\n\nexport type SupabaseMcpServerOptions = {\n platform: SupabasePlatformOptions;\n};\n\n/**\n * Creates an MCP server for interacting with Supabase.\n */\nexport function createSupabaseMcpServer(options: SupabaseMcpServerOptions) {\n const managementApiUrl =\n options.platform.apiUrl ?? 'https://api.supabase.com';\n\n let managementApiClient: ManagementApiClient;\n\n async function executeSql<T>(projectId: string, query: string): Promise<T[]> {\n const response = await managementApiClient.POST(\n '/v1/projects/{ref}/database/query',\n {\n params: {\n path: {\n ref: projectId,\n },\n },\n body: {\n query,\n },\n }\n );\n\n if (!response.response.ok) {\n throw new Error('Failed to execute SQL query');\n }\n\n return response.data as unknown as T[];\n }\n\n function createPGMeta(projectId: string) {\n return new PostgresMetaBase({\n query: async (sql) => {\n try {\n const res = await executeSql(projectId, sql);\n return wrapResult<any[]>(res);\n } catch (error) {\n return wrapError(error, sql);\n }\n },\n end: async () => {},\n });\n }\n\n const server = createMcpServer({\n name: 'supabase',\n version,\n onInitialize(clientInfo) {\n managementApiClient = createManagementApiClient(\n managementApiUrl,\n options.platform.accessToken,\n {\n 'User-Agent': `supabase-mcp/${version} (${clientInfo.name}/${clientInfo.version})`,\n }\n );\n },\n\n // Note: tools are intentionally snake_case to align better with most MCP clients\n tools: {\n get_projects: tool({\n description: 'Gets all Supabase projects for the user.',\n parameters: z.object({}),\n execute: async () => {\n const response = await managementApiClient.GET('/v1/projects');\n\n if (!response.response.ok) {\n throw new Error(`Failed to fetch projects`);\n }\n\n return response.data;\n },\n }),\n get_organizations: tool({\n description: 'Gets all organizations for the user.',\n parameters: z.object({}),\n execute: async () => {\n const response = await managementApiClient.GET('/v1/organizations');\n\n if (!response.response.ok) {\n throw new Error('Failed to fetch organizations');\n }\n\n return response.data;\n },\n }),\n get_organization: tool({\n description: 'Gets an organization by ID.',\n parameters: z.object({\n id: z.string().describe('The organization ID'),\n }),\n execute: async ({ id: organizationId }) => {\n const response = await managementApiClient.GET(\n '/v1/organizations/{slug}',\n {\n params: {\n path: {\n slug: organizationId,\n },\n },\n }\n );\n\n if (!response.response.ok) {\n throw new Error('Failed to fetch organization');\n }\n\n return response.data;\n },\n }),\n get_tables: tool({\n description: 'Gets all tables in a schema.',\n parameters: z.object({\n projectId: z.string(),\n schemas: z\n .optional(z.array(z.string()))\n .describe(\n 'Optional list of schemas to include. Defaults to all schemas.'\n ),\n }),\n execute: async ({ projectId, schemas }) => {\n const pgMeta = createPGMeta(projectId);\n const { data, error } = await pgMeta.tables.list({\n includedSchemas: schemas,\n });\n\n if (error) {\n throw new Error(`Error fetching tables: ${error.message}`);\n }\n return data;\n },\n }),\n get_extensions: tool({\n description: 'Gets all extensions in the database.',\n parameters: z.object({\n projectId: z.string(),\n }),\n execute: async ({ projectId }) => {\n const pgMeta = createPGMeta(projectId);\n const { data, error } = await pgMeta.extensions.list();\n\n if (error) {\n throw new Error(`Error fetching extensions: ${error.message}`);\n }\n return data;\n },\n }),\n apply_migration: tool({\n description:\n 'Applies a migration to the database. Use this when executing DDL operations.',\n parameters: z.object({\n projectId: z.string(),\n name: z.string().describe('The name of the migration in snake_case'),\n query: z.string().describe('The SQL query to apply'),\n }),\n execute: async ({ projectId, name, query }) => {\n const response = await managementApiClient.POST(\n '/v1/projects/{ref}/database/migrations',\n {\n params: {\n path: {\n ref: projectId,\n },\n },\n body: {\n name,\n query,\n },\n } as any // TODO: remove once API spec updated to include body\n );\n\n if (!response.response.ok) {\n throw new Error('Failed to apply migration');\n }\n\n return response.data;\n },\n }),\n execute_sql: tool({\n description:\n 'Executes raw SQL in the Postgres database. Use `applyMigration` instead for DDL operations.',\n parameters: z.object({\n projectId: z.string(),\n query: z.string().describe('The SQL query to execute'),\n }),\n execute: async ({ query, projectId }) => {\n return await executeSql(projectId, query);\n },\n }),\n get_project_url: tool({\n description: 'Gets the API URL for a project.',\n parameters: z.object({\n projectId: z.string(),\n }),\n execute: async ({ projectId }) => {\n return `https://${projectId}.supabase.co`;\n },\n }),\n get_anon_key: tool({\n description: 'Gets the anonymous API key for a project.',\n parameters: z.object({\n projectId: z.string(),\n }),\n execute: async ({ projectId }) => {\n const response = await managementApiClient.GET(\n '/v1/projects/{ref}/api-keys',\n {\n params: {\n path: {\n ref: projectId,\n },\n query: {\n reveal: false,\n },\n },\n }\n );\n\n if (!response.response.ok) {\n throw new Error('Failed to fetch API keys');\n }\n\n const anonKey = response.data?.find((key) => key.name === 'anon');\n\n if (!anonKey) {\n throw new Error('Anonymous key not found');\n }\n\n return anonKey.api_key;\n },\n }),\n generate_typescript_types: tool({\n description: 'Generates TypeScript types for a project.',\n parameters: z.object({\n projectId: z.string(),\n }),\n execute: async ({ projectId }) => {\n const response = await managementApiClient.GET(\n '/v1/projects/{ref}/types/typescript',\n {\n params: {\n path: {\n ref: projectId,\n },\n },\n }\n );\n\n if (!response.response.ok) {\n throw new Error('Failed to fetch TypeScript types');\n }\n\n return response.data;\n },\n }),\n },\n });\n\n return server;\n}\n","{\n \"name\": \"@supabase/mcp-server-supabase\",\n \"version\": \"0.1.0-dev.1\",\n \"description\": \"MCP server for interacting with Supabase\",\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"main\": \"dist/index.cjs\",\n \"types\": \"dist/index.d.ts\",\n \"sideEffects\": false,\n \"scripts\": {\n \"build\": \"tsup --clean\",\n \"prepublishOnly\": \"npm run build\",\n \"test\": \"vitest\",\n \"generate:management-api-types\": \"openapi-typescript https://api.supabase.com/api/v1-json -o ./src/management-api/types.ts\"\n },\n \"files\": [\n \"dist/**/*\"\n ],\n \"bin\": {\n \"mcp-server-supabase\": \"./dist/stdio.js\"\n },\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"dependencies\": {\n \"@gregnr/postgres-meta\": \"^0.82.0-dev.2\",\n \"@modelcontextprotocol/sdk\": \"^1.4.1\",\n \"@supabase/mcp-utils\": \"0.1.1\",\n \"open\": \"^10.1.0\",\n \"openapi-fetch\": \"^0.13.4\",\n \"postgres\": \"^3.4.5\",\n \"zod\": \"^3.24.1\",\n \"zod-to-json-schema\": \"^3.24.1\"\n },\n \"devDependencies\": {\n \"@electric-sql/pglite\": \"^0.2.17\",\n \"@total-typescript/tsconfig\": \"^1.0.4\",\n \"@types/node\": \"^22.8.6\",\n \"msw\": \"^2.7.3\",\n \"openapi-typescript\": \"^7.5.0\",\n \"prettier\": \"^3.3.3\",\n \"tsup\": \"^8.3.5\",\n \"tsx\": \"^4.19.2\",\n \"typescript\": \"^5.6.3\",\n \"vitest\": \"^2.1.4\"\n }\n}\n","import createClient, { type Client } from 'openapi-fetch';\nimport type { paths } from './types.js';\n\nexport function createManagementApiClient(\n baseUrl: string,\n accessToken: string,\n headers: Record<string, string> = {}\n) {\n return createClient<paths>({\n baseUrl,\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n ...headers,\n },\n });\n}\n\nexport type ManagementApiClient = Client<paths>;\n"],"mappings":"AAAA,OACE,oBAAAA,EACA,aAAAC,EACA,cAAAC,MACK,6BACP,OAAS,mBAAAC,EAAiB,QAAAC,MAAY,sBACtC,OAAS,KAAAC,MAAS,MCJhB,IAAAC,EAAW,cCFb,OAAOC,MAAmC,gBAGnC,SAASC,EACdC,EACAC,EACAC,EAAkC,CAAC,EACnC,CACA,OAAOJ,EAAoB,CACzB,QAAAE,EACA,QAAS,CACP,eAAgB,mBAChB,cAAe,UAAUC,CAAW,GACpC,GAAGC,CACL,CACF,CAAC,CACH,CFSO,SAASC,EAAwBC,EAAmC,CACzE,IAAMC,EACJD,EAAQ,SAAS,QAAU,2BAEzBE,EAEJ,eAAeC,EAAcC,EAAmBC,EAA6B,CAC3E,IAAMC,EAAW,MAAMJ,EAAoB,KACzC,oCACA,CACE,OAAQ,CACN,KAAM,CACJ,IAAKE,CACP,CACF,EACA,KAAM,CACJ,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QAAS,MAAO,CAAE,UAAAf,CAAU,IAAM,CAChC,IAAME,EAAW,MAAMJ,EAAoB,IACzC,sCACA,CACE,OAAQ,CACN,KAAM,CACJ,IAAKE,CACP,CACF,CACF,CACF,EAEA,GAAI,CAACE,EAAS,SAAS,GACrB,MAAM,IAAI,MAAM,kCAAkC,EAGpD,OAAOA,EAAS,IAClB,CACF,CAAC,CACH,CACF,CAAC,CAGH","names":["PostgresMetaBase","wrapError","wrapResult","createMcpServer","tool","z","version","createClient","createManagementApiClient","baseUrl","accessToken","headers","createSupabaseMcpServer","options","managementApiUrl","managementApiClient","executeSql","projectId","query","response","createPGMeta","PostgresMetaBase","sql","res","wrapResult","error","wrapError","createMcpServer","version","clientInfo","createManagementApiClient","tool","z","organizationId","schemas","pgMeta","data","name","anonKey","key"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/grichardson/Documents/dev/supabase/mcp-server-supabase/packages/mcp-server-supabase/dist/index.cjs"],"names":[],"mappings":"AAAA,iIAAwC,sDAAqC","file":"/Users/grichardson/Documents/dev/supabase/mcp-server-supabase/packages/mcp-server-supabase/dist/index.cjs"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as _modelcontextprotocol_sdk_server_index_js from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
|
|
3
|
+
type SupabasePlatformOptions = {
|
|
4
|
+
apiUrl?: string;
|
|
5
|
+
accessToken: string;
|
|
6
|
+
};
|
|
7
|
+
type SupabaseMcpServerOptions = {
|
|
8
|
+
platform: SupabasePlatformOptions;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Creates an MCP server for interacting with Supabase.
|
|
12
|
+
*/
|
|
13
|
+
declare function createSupabaseMcpServer(options: SupabaseMcpServerOptions): _modelcontextprotocol_sdk_server_index_js.Server<{
|
|
14
|
+
method: string;
|
|
15
|
+
params?: {
|
|
16
|
+
[x: string]: unknown;
|
|
17
|
+
_meta?: {
|
|
18
|
+
[x: string]: unknown;
|
|
19
|
+
progressToken?: string | number | undefined;
|
|
20
|
+
} | undefined;
|
|
21
|
+
} | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
method: string;
|
|
24
|
+
params?: {
|
|
25
|
+
[x: string]: unknown;
|
|
26
|
+
_meta?: {
|
|
27
|
+
[x: string]: unknown;
|
|
28
|
+
} | undefined;
|
|
29
|
+
} | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
[x: string]: unknown;
|
|
32
|
+
_meta?: {
|
|
33
|
+
[x: string]: unknown;
|
|
34
|
+
} | undefined;
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
export { type SupabaseMcpServerOptions, type SupabasePlatformOptions, createSupabaseMcpServer };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as _modelcontextprotocol_sdk_server_index_js from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
|
|
3
|
+
type SupabasePlatformOptions = {
|
|
4
|
+
apiUrl?: string;
|
|
5
|
+
accessToken: string;
|
|
6
|
+
};
|
|
7
|
+
type SupabaseMcpServerOptions = {
|
|
8
|
+
platform: SupabasePlatformOptions;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Creates an MCP server for interacting with Supabase.
|
|
12
|
+
*/
|
|
13
|
+
declare function createSupabaseMcpServer(options: SupabaseMcpServerOptions): _modelcontextprotocol_sdk_server_index_js.Server<{
|
|
14
|
+
method: string;
|
|
15
|
+
params?: {
|
|
16
|
+
[x: string]: unknown;
|
|
17
|
+
_meta?: {
|
|
18
|
+
[x: string]: unknown;
|
|
19
|
+
progressToken?: string | number | undefined;
|
|
20
|
+
} | undefined;
|
|
21
|
+
} | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
method: string;
|
|
24
|
+
params?: {
|
|
25
|
+
[x: string]: unknown;
|
|
26
|
+
_meta?: {
|
|
27
|
+
[x: string]: unknown;
|
|
28
|
+
} | undefined;
|
|
29
|
+
} | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
[x: string]: unknown;
|
|
32
|
+
_meta?: {
|
|
33
|
+
[x: string]: unknown;
|
|
34
|
+
} | undefined;
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
export { type SupabaseMcpServerOptions, type SupabasePlatformOptions, createSupabaseMcpServer };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/sse.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict"; 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 _chunk5UWVQOB5cjs = require('./chunk-5UWVQOB5.cjs');var _ssejs = require('@modelcontextprotocol/sdk/server/sse.js');var _http = require('http');var a=process.env.PORT?Number(process.env.PORT):8080;async function d(){let t;new (0, _http.Server)(async(r,e)=>{switch(r.url){case"/sse":{if(r.method!=="GET"){e.writeHead(405),e.end();return}let n=_optionalChain([r, 'access', _ => _.headers, 'access', _2 => _2.authorization, 'optionalAccess', _3 => _3.replace, 'call', _4 => _4("Bearer ","")]);if(!n){e.writeHead(401),e.end("Unauthorized");return}let s=_chunk5UWVQOB5cjs.a.call(void 0, {platform:{accessToken:n}});t=new (0, _ssejs.SSEServerTransport)("/messages",e),await s.connect(t);break}case"/messages":{if(r.method!=="POST"){e.writeHead(405),e.end();return}t&&t.handlePostMessage(r,e);break}default:e.writeHead(404),e.end();return}}).listen(a,()=>{console.log(`Server is listening on port ${a}`)})}d().catch(console.error);
|
|
3
|
+
//# sourceMappingURL=sse.cjs.map
|
package/dist/sse.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/grichardson/Documents/dev/supabase/mcp-server-supabase/packages/mcp-server-supabase/dist/sse.cjs","../src/sse.ts"],"names":["port","main","transport","Server","req","res","accessToken","server","createSupabaseMcpServer","SSEServerTransport"],"mappings":"AAAA;AACA,ykBAAwC,gECCL,4BACZ,IAGjBA,CAAAA,CAAO,OAAA,CAAQ,GAAA,CAAI,IAAA,CAAO,MAAA,CAAO,OAAA,CAAQ,GAAA,CAAI,IAAI,CAAA,CAAI,IAAA,CAE3D,MAAA,SAAeC,CAAAA,CAAAA,CAAO,CACpB,IAAIC,CAAAA,CAEe,IAAIC,iBAAAA,CAAO,KAAA,CAAOC,CAAAA,CAAKC,CAAAA,CAAAA,EAAQ,CAChD,MAAA,CAAQD,CAAAA,CAAI,GAAA,CAAK,CACf,IAAK,MAAA,CAAQ,CACX,EAAA,CAAIA,CAAAA,CAAI,MAAA,GAAW,KAAA,CAAO,CACxBC,CAAAA,CAAI,SAAA,CAAU,GAAG,CAAA,CACjBA,CAAAA,CAAI,GAAA,CAAI,CAAA,CACR,MACF,CAIA,IAAMC,CAAAA,iBAFOF,CAAAA,mBAAI,OAAA,qBAAQ,aAAA,6BAEC,OAAA,mBAAQ,SAAA,CAAW,EAAE,GAAA,CAE/C,EAAA,CAAI,CAACE,CAAAA,CAAa,CAChBD,CAAAA,CAAI,SAAA,CAAU,GAAG,CAAA,CACjBA,CAAAA,CAAI,GAAA,CAAI,cAAc,CAAA,CACtB,MACF,CAEA,IAAME,CAAAA,CAASC,iCAAAA,CACb,QAAA,CAAU,CACR,WAAA,CAAAF,CACF,CACF,CAAC,CAAA,CAEDJ,CAAAA,CAAY,IAAIO,8BAAAA,CAAmB,WAAA,CAAaJ,CAAG,CAAA,CAEnD,MAAME,CAAAA,CAAO,OAAA,CAAQL,CAAS,CAAA,CAC9B,KACF,CACA,IAAK,WAAA,CAAa,CAChB,EAAA,CAAIE,CAAAA,CAAI,MAAA,GAAW,MAAA,CAAQ,CACzBC,CAAAA,CAAI,SAAA,CAAU,GAAG,CAAA,CACjBA,CAAAA,CAAI,GAAA,CAAI,CAAA,CACR,MACF,CACIH,CAAAA,EACFA,CAAAA,CAAU,iBAAA,CAAkBE,CAAAA,CAAKC,CAAG,CAAA,CAEtC,KACF,CACA,OAAA,CACEA,CAAAA,CAAI,SAAA,CAAU,GAAG,CAAA,CACjBA,CAAAA,CAAI,GAAA,CAAI,CAAA,CACR,MACJ,CACF,CAAC,CAAA,CAEU,MAAA,CAAOL,CAAAA,CAAM,CAAA,CAAA,EAAM,CAC5B,OAAA,CAAQ,GAAA,CAAI,CAAA,4BAAA,EAA+BA,CAAI,CAAA,CAAA","file":"/Users/grichardson/Documents/dev/supabase/mcp-server-supabase/packages/mcp-server-supabase/dist/sse.cjs","sourcesContent":[null,"#!/usr/bin/env node\n\nimport { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';\nimport { Server } from 'node:http';\nimport { createSupabaseMcpServer } from './server.js';\n\nconst port = process.env.PORT ? Number(process.env.PORT) : 8080;\n\nasync function main() {\n let transport: SSEServerTransport | undefined;\n\n const httpServer = new Server(async (req, res) => {\n switch (req.url) {\n case '/sse': {\n if (req.method !== 'GET') {\n res.writeHead(405);\n res.end();\n return;\n }\n\n const auth = req.headers['authorization'];\n\n const accessToken = auth?.replace('Bearer ', '');\n\n if (!accessToken) {\n res.writeHead(401);\n res.end('Unauthorized');\n return;\n }\n\n const server = createSupabaseMcpServer({\n platform: {\n accessToken,\n },\n });\n\n transport = new SSEServerTransport('/messages', res);\n\n await server.connect(transport);\n break;\n }\n case '/messages': {\n if (req.method !== 'POST') {\n res.writeHead(405);\n res.end();\n return;\n }\n if (transport) {\n transport.handlePostMessage(req, res);\n }\n break;\n }\n default:\n res.writeHead(404);\n res.end();\n return;\n }\n });\n\n httpServer.listen(port, () => {\n console.log(`Server is listening on port ${port}`);\n });\n}\n\nmain().catch(console.error);\n"]}
|
package/dist/sse.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/sse.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/sse.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as o}from"./chunk-7LUZJGP3.js";import{SSEServerTransport as c}from"@modelcontextprotocol/sdk/server/sse.js";import{Server as i}from"node:http";var a=process.env.PORT?Number(process.env.PORT):8080;async function d(){let t;new i(async(r,e)=>{switch(r.url){case"/sse":{if(r.method!=="GET"){e.writeHead(405),e.end();return}let n=r.headers.authorization?.replace("Bearer ","");if(!n){e.writeHead(401),e.end("Unauthorized");return}let s=o({platform:{accessToken:n}});t=new c("/messages",e),await s.connect(t);break}case"/messages":{if(r.method!=="POST"){e.writeHead(405),e.end();return}t&&t.handlePostMessage(r,e);break}default:e.writeHead(404),e.end();return}}).listen(a,()=>{console.log(`Server is listening on port ${a}`)})}d().catch(console.error);
|
|
3
|
+
//# sourceMappingURL=sse.js.map
|
package/dist/sse.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sse.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { SSEServerTransport } from '@modelcontextprotocol/sdk/server/sse.js';\nimport { Server } from 'node:http';\nimport { createSupabaseMcpServer } from './server.js';\n\nconst port = process.env.PORT ? Number(process.env.PORT) : 8080;\n\nasync function main() {\n let transport: SSEServerTransport | undefined;\n\n const httpServer = new Server(async (req, res) => {\n switch (req.url) {\n case '/sse': {\n if (req.method !== 'GET') {\n res.writeHead(405);\n res.end();\n return;\n }\n\n const auth = req.headers['authorization'];\n\n const accessToken = auth?.replace('Bearer ', '');\n\n if (!accessToken) {\n res.writeHead(401);\n res.end('Unauthorized');\n return;\n }\n\n const server = createSupabaseMcpServer({\n platform: {\n accessToken,\n },\n });\n\n transport = new SSEServerTransport('/messages', res);\n\n await server.connect(transport);\n break;\n }\n case '/messages': {\n if (req.method !== 'POST') {\n res.writeHead(405);\n res.end();\n return;\n }\n if (transport) {\n transport.handlePostMessage(req, res);\n }\n break;\n }\n default:\n res.writeHead(404);\n res.end();\n return;\n }\n });\n\n httpServer.listen(port, () => {\n console.log(`Server is listening on port ${port}`);\n });\n}\n\nmain().catch(console.error);\n"],"mappings":";wCAEA,OAAS,sBAAAA,MAA0B,0CACnC,OAAS,UAAAC,MAAc,YAGvB,IAAMC,EAAO,QAAQ,IAAI,KAAO,OAAO,QAAQ,IAAI,IAAI,EAAI,KAE3D,eAAeC,GAAO,CACpB,IAAIC,EAEe,IAAIC,EAAO,MAAOC,EAAKC,IAAQ,CAChD,OAAQD,EAAI,IAAK,CACf,IAAK,OAAQ,CACX,GAAIA,EAAI,SAAW,MAAO,CACxBC,EAAI,UAAU,GAAG,EACjBA,EAAI,IAAI,EACR,MACF,CAIA,IAAMC,EAFOF,EAAI,QAAQ,eAEC,QAAQ,UAAW,EAAE,EAE/C,GAAI,CAACE,EAAa,CAChBD,EAAI,UAAU,GAAG,EACjBA,EAAI,IAAI,cAAc,EACtB,MACF,CAEA,IAAME,EAASC,EAAwB,CACrC,SAAU,CACR,YAAAF,CACF,CACF,CAAC,EAEDJ,EAAY,IAAIO,EAAmB,YAAaJ,CAAG,EAEnD,MAAME,EAAO,QAAQL,CAAS,EAC9B,KACF,CACA,IAAK,YAAa,CAChB,GAAIE,EAAI,SAAW,OAAQ,CACzBC,EAAI,UAAU,GAAG,EACjBA,EAAI,IAAI,EACR,MACF,CACIH,GACFA,EAAU,kBAAkBE,EAAKC,CAAG,EAEtC,KACF,CACA,QACEA,EAAI,UAAU,GAAG,EACjBA,EAAI,IAAI,EACR,MACJ,CACF,CAAC,EAEU,OAAOL,EAAM,IAAM,CAC5B,QAAQ,IAAI,+BAA+BA,CAAI,EAAE,CACnD,CAAC,CACH,CAEAC,EAAK,EAAE,MAAM,QAAQ,KAAK","names":["SSEServerTransport","Server","port","main","transport","Server","req","res","accessToken","server","createSupabaseMcpServer","SSEServerTransport"]}
|
package/dist/stdio.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";var _chunk5UWVQOB5cjs = require('./chunk-5UWVQOB5.cjs');var _stdiojs = require('@modelcontextprotocol/sdk/server/stdio.js');var _util = require('util');async function c(){let{values:{["access-token"]:e,["api-url"]:r}}=_util.parseArgs.call(void 0, {options:{"access-token":{type:"string"},"api-url":{type:"string"}}});e||(console.error("Please provide a personal access token (PAT) with the --access-token flag"),process.exit(1)),r||(console.error("Please provide a Supabase API URL with the --api-url flag"),process.exit(1));let s=_chunk5UWVQOB5cjs.a.call(void 0, {platform:{accessToken:e,apiUrl:r}}),a=new _stdiojs.StdioServerTransport;await s.connect(a)}c().catch(console.error);
|
|
3
|
+
//# sourceMappingURL=stdio.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/grichardson/Documents/dev/supabase/mcp-server-supabase/packages/mcp-server-supabase/dist/stdio.cjs","../src/stdio.ts"],"names":["main","accessToken","apiUrl","parseArgs","server","createSupabaseMcpServer","transport","StdioServerTransport"],"mappings":"AAAA;AACA,qEAAwC,oECCH,4BACX,MAG1B,SAAeA,CAAAA,CAAAA,CAAO,CACpB,GAAM,CACJ,MAAA,CAAQ,CAAE,CAAC,cAAc,CAAA,CAAGC,CAAAA,CAAa,CAAC,SAAS,CAAA,CAAGC,CAAO,CAC/D,CAAA,CAAIC,6BAAAA,CACF,OAAA,CAAS,CACN,cAAA,CAAiB,CAChB,IAAA,CAAM,QACR,CAAA,CACC,SAAA,CAAY,CACX,IAAA,CAAM,QACR,CACF,CACF,CAAC,CAAA,CAEIF,CAAAA,EAAAA,CACH,OAAA,CAAQ,KAAA,CACN,2EACF,CAAA,CACA,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CAAA,CAGXC,CAAAA,EAAAA,CACH,OAAA,CAAQ,KAAA,CAAM,2DAA2D,CAAA,CACzE,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,CAAA,CAGhB,IAAME,CAAAA,CAASC,iCAAAA,CACb,QAAA,CAAU,CACR,WAAA,CAAAJ,CAAAA,CACA,MAAA,CAAAC,CACF,CACF,CAAC,CAAA,CAEKI,CAAAA,CAAY,IAAIC,6BAAAA,CAEtB,MAAMH,CAAAA,CAAO,OAAA,CAAQE,CAAS,CAChC,CAEAN,CAAAA,CAAK,CAAA,CAAE,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA","file":"/Users/grichardson/Documents/dev/supabase/mcp-server-supabase/packages/mcp-server-supabase/dist/stdio.cjs","sourcesContent":[null,"#!/usr/bin/env node\n\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { parseArgs } from 'node:util';\nimport { createSupabaseMcpServer } from './server.js';\n\nasync function main() {\n const {\n values: { ['access-token']: accessToken, ['api-url']: apiUrl },\n } = parseArgs({\n options: {\n ['access-token']: {\n type: 'string',\n },\n ['api-url']: {\n type: 'string',\n },\n },\n });\n\n if (!accessToken) {\n console.error(\n 'Please provide a personal access token (PAT) with the --access-token flag'\n );\n process.exit(1);\n }\n\n if (!apiUrl) {\n console.error('Please provide a Supabase API URL with the --api-url flag');\n process.exit(1);\n }\n\n const server = createSupabaseMcpServer({\n platform: {\n accessToken,\n apiUrl,\n },\n });\n\n const transport = new StdioServerTransport();\n\n await server.connect(transport);\n}\n\nmain().catch(console.error);\n"]}
|
package/dist/stdio.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/stdio.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/stdio.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as o}from"./chunk-7LUZJGP3.js";import{StdioServerTransport as t}from"@modelcontextprotocol/sdk/server/stdio.js";import{parseArgs as n}from"node:util";async function c(){let{values:{["access-token"]:e,["api-url"]:r}}=n({options:{"access-token":{type:"string"},"api-url":{type:"string"}}});e||(console.error("Please provide a personal access token (PAT) with the --access-token flag"),process.exit(1)),r||(console.error("Please provide a Supabase API URL with the --api-url flag"),process.exit(1));let s=o({platform:{accessToken:e,apiUrl:r}}),a=new t;await s.connect(a)}c().catch(console.error);
|
|
3
|
+
//# sourceMappingURL=stdio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/stdio.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { parseArgs } from 'node:util';\nimport { createSupabaseMcpServer } from './server.js';\n\nasync function main() {\n const {\n values: { ['access-token']: accessToken, ['api-url']: apiUrl },\n } = parseArgs({\n options: {\n ['access-token']: {\n type: 'string',\n },\n ['api-url']: {\n type: 'string',\n },\n },\n });\n\n if (!accessToken) {\n console.error(\n 'Please provide a personal access token (PAT) with the --access-token flag'\n );\n process.exit(1);\n }\n\n if (!apiUrl) {\n console.error('Please provide a Supabase API URL with the --api-url flag');\n process.exit(1);\n }\n\n const server = createSupabaseMcpServer({\n platform: {\n accessToken,\n apiUrl,\n },\n });\n\n const transport = new StdioServerTransport();\n\n await server.connect(transport);\n}\n\nmain().catch(console.error);\n"],"mappings":";wCAEA,OAAS,wBAAAA,MAA4B,4CACrC,OAAS,aAAAC,MAAiB,YAG1B,eAAeC,GAAO,CACpB,GAAM,CACJ,OAAQ,CAAE,CAAC,cAAc,EAAGC,EAAa,CAAC,SAAS,EAAGC,CAAO,CAC/D,EAAIC,EAAU,CACZ,QAAS,CACN,eAAiB,CAChB,KAAM,QACR,EACC,UAAY,CACX,KAAM,QACR,CACF,CACF,CAAC,EAEIF,IACH,QAAQ,MACN,2EACF,EACA,QAAQ,KAAK,CAAC,GAGXC,IACH,QAAQ,MAAM,2DAA2D,EACzE,QAAQ,KAAK,CAAC,GAGhB,IAAME,EAASC,EAAwB,CACrC,SAAU,CACR,YAAAJ,EACA,OAAAC,CACF,CACF,CAAC,EAEKI,EAAY,IAAIC,EAEtB,MAAMH,EAAO,QAAQE,CAAS,CAChC,CAEAN,EAAK,EAAE,MAAM,QAAQ,KAAK","names":["StdioServerTransport","parseArgs","main","accessToken","apiUrl","parseArgs","server","createSupabaseMcpServer","transport","StdioServerTransport"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@supabase/mcp-server-supabase",
|
|
3
|
+
"version": "0.1.0-dev.1",
|
|
4
|
+
"description": "MCP server for interacting with Supabase",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.cjs",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsup --clean",
|
|
12
|
+
"prepublishOnly": "npm run build",
|
|
13
|
+
"test": "vitest",
|
|
14
|
+
"generate:management-api-types": "openapi-typescript https://api.supabase.com/api/v1-json -o ./src/management-api/types.ts"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/**/*"
|
|
18
|
+
],
|
|
19
|
+
"bin": {
|
|
20
|
+
"mcp-server-supabase": "./dist/stdio.js"
|
|
21
|
+
},
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.cjs"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@gregnr/postgres-meta": "^0.82.0-dev.2",
|
|
31
|
+
"@modelcontextprotocol/sdk": "^1.4.1",
|
|
32
|
+
"@supabase/mcp-utils": "0.1.1",
|
|
33
|
+
"open": "^10.1.0",
|
|
34
|
+
"openapi-fetch": "^0.13.4",
|
|
35
|
+
"postgres": "^3.4.5",
|
|
36
|
+
"zod": "^3.24.1",
|
|
37
|
+
"zod-to-json-schema": "^3.24.1"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@electric-sql/pglite": "^0.2.17",
|
|
41
|
+
"@total-typescript/tsconfig": "^1.0.4",
|
|
42
|
+
"@types/node": "^22.8.6",
|
|
43
|
+
"msw": "^2.7.3",
|
|
44
|
+
"openapi-typescript": "^7.5.0",
|
|
45
|
+
"prettier": "^3.3.3",
|
|
46
|
+
"tsup": "^8.3.5",
|
|
47
|
+
"tsx": "^4.19.2",
|
|
48
|
+
"typescript": "^5.6.3",
|
|
49
|
+
"vitest": "^2.1.4"
|
|
50
|
+
}
|
|
51
|
+
}
|