Skip to content

Commit 0822b2b

Browse files
authored
Merge pull request #78 from supabase-community/feat/platform-abstraction
Platform abstraction
2 parents 73c8eeb + 1bccc02 commit 0822b2b

22 files changed

+1652
-711
lines changed

package-lock.json

Lines changed: 703 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/mcp-server-supabase/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,23 @@
2121
"dist/**/*"
2222
],
2323
"bin": {
24-
"mcp-server-supabase": "./dist/stdio.js"
24+
"mcp-server-supabase": "./dist/transports/stdio.js"
2525
},
2626
"exports": {
2727
".": {
2828
"import": "./dist/index.js",
2929
"types": "./dist/index.d.ts",
3030
"default": "./dist/index.cjs"
31+
},
32+
"./platform": {
33+
"import": "./dist/platform/index.js",
34+
"types": "./dist/platform/index.d.ts",
35+
"default": "./dist/platform/index.cjs"
3136
}
3237
},
3338
"dependencies": {
3439
"@deno/eszip": "^0.84.0",
35-
"@modelcontextprotocol/sdk": "^1.4.1",
40+
"@modelcontextprotocol/sdk": "^1.11.0",
3641
"@supabase/mcp-utils": "0.2.0",
3742
"common-tags": "^1.8.2",
3843
"openapi-fetch": "^0.13.5",
Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
import { codeBlock } from 'common-tags';
2-
import { fileURLToPath } from 'node:url';
3-
import { extractFiles } from './eszip.js';
4-
import {
5-
assertSuccess,
6-
type ManagementApiClient,
7-
} from './management-api/index.js';
82

93
/**
104
* Gets the deployment ID for an Edge Function.
@@ -40,96 +34,3 @@ export const edgeFunctionExample = codeBlock`
4034
});
4135
});
4236
`;
43-
44-
/**
45-
* Fetches a full Edge Function from the Supabase Management API.
46-
47-
* - Includes both function metadata and the contents of each file.
48-
* - Normalizes file paths to be relative to the project root.
49-
*/
50-
export async function getFullEdgeFunction(
51-
managementApiClient: ManagementApiClient,
52-
projectId: string,
53-
functionSlug: string
54-
) {
55-
const functionResponse = await managementApiClient.GET(
56-
'/v1/projects/{ref}/functions/{function_slug}',
57-
{
58-
params: {
59-
path: {
60-
ref: projectId,
61-
function_slug: functionSlug,
62-
},
63-
},
64-
}
65-
);
66-
67-
if (functionResponse.error) {
68-
return {
69-
data: undefined,
70-
error: functionResponse.error as { message: string },
71-
};
72-
}
73-
74-
assertSuccess(functionResponse, 'Failed to fetch Edge Function');
75-
76-
const edgeFunction = functionResponse.data;
77-
78-
const deploymentId = getDeploymentId(
79-
projectId,
80-
edgeFunction.id,
81-
edgeFunction.version
82-
);
83-
84-
const pathPrefix = getPathPrefix(deploymentId);
85-
86-
const entrypoint_path = edgeFunction.entrypoint_path
87-
? fileURLToPath(edgeFunction.entrypoint_path, { windows: false }).replace(
88-
pathPrefix,
89-
''
90-
)
91-
: undefined;
92-
93-
const import_map_path = edgeFunction.import_map_path
94-
? fileURLToPath(edgeFunction.import_map_path, { windows: false }).replace(
95-
pathPrefix,
96-
''
97-
)
98-
: undefined;
99-
100-
const eszipResponse = await managementApiClient.GET(
101-
'/v1/projects/{ref}/functions/{function_slug}/body',
102-
{
103-
params: {
104-
path: {
105-
ref: projectId,
106-
function_slug: functionSlug,
107-
},
108-
},
109-
parseAs: 'arrayBuffer',
110-
}
111-
);
112-
113-
assertSuccess(eszipResponse, 'Failed to fetch Edge Function eszip bundle');
114-
115-
const extractedFiles = await extractFiles(
116-
new Uint8Array(eszipResponse.data),
117-
pathPrefix
118-
);
119-
120-
const files = await Promise.all(
121-
extractedFiles.map(async (file) => ({
122-
name: file.name,
123-
content: await file.text(),
124-
}))
125-
);
126-
127-
const normalizedFunction = {
128-
...edgeFunction,
129-
entrypoint_path,
130-
import_map_path,
131-
files,
132-
};
133-
134-
return { data: normalizedFunction, error: undefined };
135-
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
export * from './platform/api-platform.js';
2+
export type { SupabasePlatform } from './platform/index.js';
13
export * from './server.js';

0 commit comments

Comments
 (0)