Skip to content

Commit 894e2d6

Browse files
committed
feat: advisor unit tests
1 parent 4d92cc0 commit 894e2d6

File tree

3 files changed

+96
-2
lines changed

3 files changed

+96
-2
lines changed

packages/mcp-server-supabase/src/server.test.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,60 @@ describe('tools', () => {
993993
}
994994
});
995995

996+
test('get security advisors', async () => {
997+
const { callTool } = await setup();
998+
999+
const org = await createOrganization({
1000+
name: 'My Org',
1001+
plan: 'free',
1002+
allowed_release_channels: ['ga'],
1003+
});
1004+
1005+
const project = await createProject({
1006+
name: 'Project 1',
1007+
region: 'us-east-1',
1008+
organization_id: org.id,
1009+
});
1010+
project.status = 'ACTIVE_HEALTHY';
1011+
1012+
const result = await callTool({
1013+
name: 'get_advisors',
1014+
arguments: {
1015+
project_id: project.id,
1016+
type: 'security',
1017+
},
1018+
});
1019+
1020+
expect(result).toEqual({ lints: [] });
1021+
});
1022+
1023+
test('get performance advisors', async () => {
1024+
const { callTool } = await setup();
1025+
1026+
const org = await createOrganization({
1027+
name: 'My Org',
1028+
plan: 'free',
1029+
allowed_release_channels: ['ga'],
1030+
});
1031+
1032+
const project = await createProject({
1033+
name: 'Project 1',
1034+
region: 'us-east-1',
1035+
organization_id: org.id,
1036+
});
1037+
project.status = 'ACTIVE_HEALTHY';
1038+
1039+
const result = await callTool({
1040+
name: 'get_advisors',
1041+
arguments: {
1042+
project_id: project.id,
1043+
type: 'performance',
1044+
},
1045+
});
1046+
1047+
expect(result).toEqual({ lints: [] });
1048+
});
1049+
9961050
test('get logs for invalid service type', async () => {
9971051
const { callTool } = await setup();
9981052

packages/mcp-server-supabase/src/tools/debugging-tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export function getDebuggingTools({
5050
}),
5151
get_advisors: injectableTool({
5252
description:
53-
"Gets a list of advisory notices for the Supabase project. Use this to check for security vulnerabilities or performance improvements. It's recommended to run this tool regularly, especially after making DDL changes to the database since it will catch things like missing RLS policies.",
53+
"Gets a list of advisory notices for the Supabase project. Use this to check for security vulnerabilities or performance improvements. Include the remediation URL as a clickable link so that the user can reference the issue themselves. It's recommended to run this tool regularly, especially after making DDL changes to the database since it will catch things like missing RLS policies.",
5454
parameters: z.object({
5555
project_id: z.string(),
5656
type: z

packages/mcp-server-supabase/test/mocks.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ export const mockManagementApi = [
417417
*/
418418
http.get<{ projectId: string }, { sql: string }>(
419419
`${API_URL}/v1/projects/:projectId/analytics/endpoints/logs.all`,
420-
async ({ params, request }) => {
420+
async ({ params }) => {
421421
const project = mockProjects.get(params.projectId);
422422
if (!project) {
423423
return HttpResponse.json(
@@ -430,6 +430,46 @@ export const mockManagementApi = [
430430
}
431431
),
432432

433+
/**
434+
* Get security advisors for a project
435+
*/
436+
http.get<{ projectId: string }, { sql: string }>(
437+
`${API_URL}/v1/projects/:projectId/advisors/security`,
438+
async ({ params }) => {
439+
const project = mockProjects.get(params.projectId);
440+
if (!project) {
441+
return HttpResponse.json(
442+
{ message: 'Project not found' },
443+
{ status: 404 }
444+
);
445+
}
446+
447+
return HttpResponse.json({
448+
lints: [],
449+
});
450+
}
451+
),
452+
453+
/**
454+
* Get performance advisors for a project
455+
*/
456+
http.get<{ projectId: string }, { sql: string }>(
457+
`${API_URL}/v1/projects/:projectId/advisors/performance`,
458+
async ({ params }) => {
459+
const project = mockProjects.get(params.projectId);
460+
if (!project) {
461+
return HttpResponse.json(
462+
{ message: 'Project not found' },
463+
{ status: 404 }
464+
);
465+
}
466+
467+
return HttpResponse.json({
468+
lints: [],
469+
});
470+
}
471+
),
472+
433473
/**
434474
* Create a new branch for a project
435475
*/

0 commit comments

Comments
 (0)