Skip to content

Commit 67878a0

Browse files
committed
feat: add branch action logs
1 parent fb29985 commit 67878a0

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { stripIndent } from 'common-tags';
33
export function getLogQuery(
44
service:
55
| 'api'
6+
| 'branch-action'
67
| 'postgres'
78
| 'edge-function'
89
| 'auth'
@@ -21,6 +22,12 @@ export function getLogQuery(
2122
order by timestamp desc
2223
limit ${limit}
2324
`;
25+
case 'branch-action':
26+
return stripIndent`
27+
select workflow_run, workflow_run_logs.timestamp, id, event_message from workflow_run_logs
28+
order by timestamp desc
29+
limit ${limit}
30+
`;
2431
case 'postgres':
2532
return stripIndent`
2633
select identifier, postgres_logs.timestamp, id, event_message, parsed.error_severity from postgres_logs

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ describe('tools', () => {
456456
const project = mockProjects.values().next().value!;
457457
const services = [
458458
'api',
459+
'branch-action',
459460
'postgres',
460461
'edge-function',
461462
'auth',

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ export function createSupabaseMcpServer(options: SupabaseMcpServerOptions) {
337337
service: z
338338
.enum([
339339
'api',
340+
'branch-action',
340341
'postgres',
341342
'edge-function',
342343
'auth',
@@ -346,7 +347,10 @@ export function createSupabaseMcpServer(options: SupabaseMcpServerOptions) {
346347
.describe('The service to fetch logs for'),
347348
}),
348349
execute: async ({ project_id, service }) => {
349-
const now = Date.now();
350+
const timestamp =
351+
service === 'branch-action'
352+
? new Date(Date.now() - 5 * 60 * 1000)
353+
: undefined;
350354
const response = await managementApiClient.GET(
351355
'/v1/projects/{ref}/analytics/endpoints/logs.all',
352356
{
@@ -356,6 +360,7 @@ export function createSupabaseMcpServer(options: SupabaseMcpServerOptions) {
356360
},
357361
query: {
358362
// Omitting start and end time defaults to the last minute
363+
iso_timestamp_start: timestamp?.toISOString(),
359364
sql: getLogQuery(service),
360365
},
361366
},

0 commit comments

Comments
 (0)