Skip to content

Commit 1dce40d

Browse files
committed
fix format
1 parent 060633c commit 1dce40d

File tree

6 files changed

+114
-99
lines changed

6 files changed

+114
-99
lines changed

packages/mcp-server-supabase/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
"test:coverage": "vitest --coverage",
1919
"generate:management-api-types": "openapi-typescript https://api.supabase.com/api/v1-json -o ./src/management-api/types.ts"
2020
},
21-
"files": [
22-
"dist/**/*"
23-
],
21+
"files": ["dist/**/*"],
2422
"bin": {
2523
"mcp-server-supabase": "./dist/transports/stdio.js"
2624
},

packages/mcp-server-supabase/src/transports/http.ts

Lines changed: 73 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
import { Hono } from 'hono';
22
import { createSupabaseMcpServer } from '../server.js';
33
import { StatelessHttpServerTransport } from '@supabase/mcp-utils';
4-
import { ProxyOAuthServerProvider } from '@modelcontextprotocol/sdk/server/auth/providers/proxyProvider.js';
5-
import { mcpAuthMetadataRouter } from '@modelcontextprotocol/sdk/server/auth/router.js';
64
import { serve } from '@hono/node-server';
75
import { createSupabaseApiPlatform } from '../platform/api-platform.js';
86
import { cors } from 'hono/cors';
97

108
const managementApiUrl =
119
process.env.SUPABASE_API_URL ?? 'https://api.supabase.com';
1210

13-
const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000
11+
const port = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000;
1412

1513
const app = new Hono();
1614

1715
//
18-
app.use(cors(
19-
{
16+
app.use(
17+
cors({
2018
origin: ['dev', 'test'].includes((process.env.ENV ?? '').toLowerCase())
2119
? '*'
2220
: 'https://api.supabase.io/mcp',
23-
}
24-
))
21+
})
22+
);
2523

2624
/**
2725
* Stateless HTTP transport for the Supabase MCP server.
@@ -40,9 +38,9 @@ app.post('/mcp', async (c) => {
4038
}
4139

4240
const platform = createSupabaseApiPlatform({
43-
accessToken,
44-
apiUrl,
45-
});
41+
accessToken,
42+
apiUrl,
43+
});
4644

4745
const server = createSupabaseMcpServer({
4846
platform,
@@ -58,63 +56,82 @@ app.post('/mcp', async (c) => {
5856
// SSE notifications not supported in stateless mode
5957
app.get('/mcp', async (c) => {
6058
console.log('Received GET MCP request');
61-
c.json({
62-
jsonrpc: "2.0",
63-
error: {
64-
code: -32000,
65-
message: "Method not allowed."
59+
c.json(
60+
{
61+
jsonrpc: '2.0',
62+
error: {
63+
code: -32000,
64+
message: 'Method not allowed.',
65+
},
66+
id: null,
6667
},
67-
id: null
68-
}, 405);
68+
405
69+
);
6970
});
7071

7172
// Session termination not needed in stateless mode
7273
app.delete('/mcp', async (c) => {
7374
console.log('Received DELETE MCP request');
74-
c.json({
75-
jsonrpc: "2.0",
76-
error: {
77-
code: -32000,
78-
message: "Method not allowed."
75+
c.json(
76+
{
77+
jsonrpc: '2.0',
78+
error: {
79+
code: -32000,
80+
message: 'Method not allowed.',
81+
},
82+
id: null,
7983
},
80-
id: null
81-
}, 405);
84+
405
85+
);
8286
});
8387

84-
8588
const oauthMetadata = {
8689
issuer: `${managementApiUrl}`,
87-
authorization_endpoint: `${managementApiUrl}/v1/oauth/authorize`,
88-
token_endpoint: `${managementApiUrl}/v1/oauth/token`,
89-
registration_endpoint: `${managementApiUrl}/platform/oauth/apps/register`,
90-
token_endpoint_auth_methods_supported: ['client_secret_post'],
91-
scopes_supported: [
92-
'analytics:read', 'analytics:write',
93-
'auth:read', 'auth:write',
94-
'database:read', 'database:write',
95-
'domains:read', 'domains:write',
96-
'edge_functions:read', 'edge_functions:write',
97-
'environment:read', 'environment:write',
98-
'organizations:read', 'organizations:write',
99-
'projects:read', 'projects:write',
100-
'rest:read', 'rest:write',
101-
'secrets:read', 'secrets:write',
102-
'storage:read', 'storage:write'
103-
],
104-
response_types_supported: ['code'],
105-
response_modes_supported: ['query'],
106-
grant_types_supported: ['authorization_code', 'refresh_token'],
107-
code_challenge_methods_supported: ['S256'],
108-
}
109-
110-
const protectedResourceMetadata = {
111-
resource: `http://localhost:${port}`, // "https://api.supabase.io/mcp",
112-
authorization_servers: [oauthMetadata.issuer],
113-
scopes_supported: oauthMetadata.scopes_supported,
114-
};
115-
app.get('/.well-known/oauth-protected-resource', (c) => c.json(protectedResourceMetadata));
116-
app.get('/.well-known/oauth-authorization-server', (c) => c.json(oauthMetadata));
117-
90+
authorization_endpoint: `${managementApiUrl}/v1/oauth/authorize`,
91+
token_endpoint: `${managementApiUrl}/v1/oauth/token`,
92+
registration_endpoint: `${managementApiUrl}/platform/oauth/apps/register`,
93+
token_endpoint_auth_methods_supported: ['client_secret_post'],
94+
scopes_supported: [
95+
'analytics:read',
96+
'analytics:write',
97+
'auth:read',
98+
'auth:write',
99+
'database:read',
100+
'database:write',
101+
'domains:read',
102+
'domains:write',
103+
'edge_functions:read',
104+
'edge_functions:write',
105+
'environment:read',
106+
'environment:write',
107+
'organizations:read',
108+
'organizations:write',
109+
'projects:read',
110+
'projects:write',
111+
'rest:read',
112+
'rest:write',
113+
'secrets:read',
114+
'secrets:write',
115+
'storage:read',
116+
'storage:write',
117+
],
118+
response_types_supported: ['code'],
119+
response_modes_supported: ['query'],
120+
grant_types_supported: ['authorization_code', 'refresh_token'],
121+
code_challenge_methods_supported: ['S256'],
122+
};
123+
124+
const protectedResourceMetadata = {
125+
resource: `http://localhost:${port}`, // "https://api.supabase.io/mcp",
126+
authorization_servers: [oauthMetadata.issuer],
127+
scopes_supported: oauthMetadata.scopes_supported,
128+
};
129+
app.get('/.well-known/oauth-protected-resource', (c) =>
130+
c.json(protectedResourceMetadata)
131+
);
132+
app.get('/.well-known/oauth-authorization-server', (c) =>
133+
c.json(oauthMetadata)
134+
);
118135

119136
serve(
120137
{

packages/mcp-server-supabase/test/e2e/functions.e2e.ts

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
/// <reference types="../extensions.d.ts" />
22

3-
import { generateText, type ToolCallUnion, type ToolSet } from "ai";
4-
import { codeBlock } from "common-tags";
5-
import { describe, expect, test } from "vitest";
6-
import { createOrganization, createProject } from "../mocks.js";
7-
import { join } from "node:path/posix";
8-
import { getTestModel, setup } from "./utils.js";
9-
10-
describe("edge function e2e tests", () => {
11-
test("deploys an edge function", async () => {
3+
import { generateText, type ToolCallUnion, type ToolSet } from 'ai';
4+
import { codeBlock } from 'common-tags';
5+
import { describe, expect, test } from 'vitest';
6+
import { createOrganization, createProject } from '../mocks.js';
7+
import { join } from 'node:path/posix';
8+
import { getTestModel, setup } from './utils.js';
9+
10+
describe('edge function e2e tests', () => {
11+
test('deploys an edge function', async () => {
1212
const { client } = await setup();
1313
const model = getTestModel();
1414

1515
const org = await createOrganization({
16-
name: "My Org",
17-
plan: "free",
18-
allowed_release_channels: ["ga"],
16+
name: 'My Org',
17+
plan: 'free',
18+
allowed_release_channels: ['ga'],
1919
});
2020

2121
const project = await createProject({
22-
name: "todos-app",
23-
region: "us-east-1",
22+
name: 'todos-app',
23+
region: 'us-east-1',
2424
organization_id: org.id,
2525
});
2626

@@ -32,12 +32,12 @@ describe("edge function e2e tests", () => {
3232
tools,
3333
messages: [
3434
{
35-
role: "system",
35+
role: 'system',
3636
content:
37-
"You are a coding assistant. The current working directory is /home/user/projects/todos-app.",
37+
'You are a coding assistant. The current working directory is /home/user/projects/todos-app.',
3838
},
3939
{
40-
role: "user",
40+
role: 'user',
4141
content: `Deploy an edge function to project with ref ${project.id} that returns the current time in UTC.`,
4242
},
4343
],
@@ -48,27 +48,27 @@ describe("edge function e2e tests", () => {
4848
});
4949

5050
expect(toolCalls).toContainEqual(
51-
expect.objectContaining({ toolName: "deploy_edge_function" }),
51+
expect.objectContaining({ toolName: 'deploy_edge_function' })
5252
);
5353

5454
await expect(text).toMatchCriteria(
55-
"Confirms the successful deployment of an edge function that will return the current time in UTC. It describes steps to test the function.",
55+
'Confirms the successful deployment of an edge function that will return the current time in UTC. It describes steps to test the function.'
5656
);
5757
});
5858

59-
test("modifies an edge function", async () => {
59+
test('modifies an edge function', async () => {
6060
const { client } = await setup();
6161
const model = getTestModel();
6262

6363
const org = await createOrganization({
64-
name: "My Org",
65-
plan: "free",
66-
allowed_release_channels: ["ga"],
64+
name: 'My Org',
65+
plan: 'free',
66+
allowed_release_channels: ['ga'],
6767
});
6868

6969
const project = await createProject({
70-
name: "todos-app",
71-
region: "us-east-1",
70+
name: 'todos-app',
71+
region: 'us-east-1',
7272
organization_id: org.id,
7373
});
7474

@@ -80,14 +80,14 @@ describe("edge function e2e tests", () => {
8080

8181
const edgeFunction = await project.deployEdgeFunction(
8282
{
83-
name: "hello-world",
84-
entrypoint_path: "index.ts",
83+
name: 'hello-world',
84+
entrypoint_path: 'index.ts',
8585
},
8686
[
87-
new File([code], "index.ts", {
88-
type: "application/typescript",
87+
new File([code], 'index.ts', {
88+
type: 'application/typescript',
8989
}),
90-
],
90+
]
9191
);
9292

9393
const toolCalls: ToolCallUnion<ToolSet>[] = [];
@@ -98,12 +98,12 @@ describe("edge function e2e tests", () => {
9898
tools,
9999
messages: [
100100
{
101-
role: "system",
101+
role: 'system',
102102
content:
103-
"You are a coding assistant. The current working directory is /home/user/projects/todos-app.",
103+
'You are a coding assistant. The current working directory is /home/user/projects/todos-app.',
104104
},
105105
{
106-
role: "user",
106+
role: 'user',
107107
content: `Change my edge function (project id ${project.id}) to replace "world" with "Earth".`,
108108
},
109109
],
@@ -115,19 +115,19 @@ describe("edge function e2e tests", () => {
115115

116116
expect(toolCalls).toHaveLength(2);
117117
expect(toolCalls[0]).toEqual(
118-
expect.objectContaining({ toolName: "list_edge_functions" }),
118+
expect.objectContaining({ toolName: 'list_edge_functions' })
119119
);
120120
expect(toolCalls[1]).toEqual(
121-
expect.objectContaining({ toolName: "deploy_edge_function" }),
121+
expect.objectContaining({ toolName: 'deploy_edge_function' })
122122
);
123123

124124
await expect(text).toMatchCriteria(
125-
"Confirms the successful modification of an Edge Function.",
125+
'Confirms the successful modification of an Edge Function.'
126126
);
127127

128128
expect(edgeFunction.files).toHaveLength(1);
129129
expect(edgeFunction.files[0].name).toBe(
130-
join(edgeFunction.pathPrefix, "index.ts"),
130+
join(edgeFunction.pathPrefix, 'index.ts')
131131
);
132132
await expect(edgeFunction.files[0].text()).resolves.toEqual(codeBlock`
133133
Deno.serve(async (req: Request) => {

packages/mcp-server-supabase/tsup.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ export default defineConfig([
1717
'.sql': 'text',
1818
},
1919
},
20-
]);
20+
]);

packages/mcp-utils/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export * from './server.js';
22
export * from './stateless-http-transport.js';
33
export * from './stream-transport.js';
4-
export * from './types.js';
4+
export * from './types.js';

packages/mcp-utils/src/stateless-http-transport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,4 +271,4 @@ class JsonRpcToSseStream extends TransformStream<JSONRPCMessage, Uint8Array> {
271271
},
272272
});
273273
}
274-
}
274+
}

0 commit comments

Comments
 (0)