Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 40 additions & 17 deletions packages/mcp-server-supabase/src/management-api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2940,13 +2940,18 @@ export interface components {
/** @enum {string} */
status: "stored" | "applied";
};
/** @example {
* "root_key": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
* } */
PgsodiumConfigResponse: {
/** @description The pgsodium root key: 32 bytes, hex-encoded (64 characters). */
root_key: string;
};
/** @example {
* "root_key": "MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWY="
* "root_key": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
* } */
UpdatePgsodiumConfigBody: {
/** @description The pgsodium root key: 32 bytes, hex-encoded (64 characters). */
root_key: string;
};
PostgrestConfigWithJWTSecretResponse: {
Expand Down Expand Up @@ -3039,6 +3044,22 @@ export interface components {
status: "not-used" | "custom-domain-used" | "active";
custom_domain?: string;
};
PlanGateErrorBody: {
/** @description Human-readable explanation of the plan gate */
message: string;
/** @description Present on entitlement denials. Other errors with this status code (validation, billing state) carry only message. */
error?: {
/**
* @description Machine-readable marker for plan-gated denials
* @enum {string}
*/
code: "entitlement_required";
/** @description Entitlement feature key that failed the check */
feature: string;
/** @description Billing page URL for the organization, present when the org is resolvable */
upgrade_url?: string;
};
};
/** @example {
* "vanity_subdomain": "acme-prod"
* } */
Expand Down Expand Up @@ -4780,7 +4801,6 @@ export interface components {
CreateProviderResponse: {
id: string;
saml?: {
id: string;
entity_id: string;
metadata_url?: string;
metadata_xml?: string;
Expand All @@ -4798,7 +4818,6 @@ export interface components {
name_id_format?: "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" | "urn:oasis:names:tc:SAML:2.0:nameid-format:transient" | "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" | "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent";
};
domains?: {
id: string;
domain?: string;
created_at?: string;
updated_at?: string;
Expand All @@ -4810,7 +4829,6 @@ export interface components {
items: {
id: string;
saml?: {
id: string;
entity_id: string;
metadata_url?: string;
metadata_xml?: string;
Expand All @@ -4828,7 +4846,6 @@ export interface components {
name_id_format?: "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" | "urn:oasis:names:tc:SAML:2.0:nameid-format:transient" | "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" | "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent";
};
domains?: {
id: string;
domain?: string;
created_at?: string;
updated_at?: string;
Expand All @@ -4840,7 +4857,6 @@ export interface components {
GetProviderResponse: {
id: string;
saml?: {
id: string;
entity_id: string;
metadata_url?: string;
metadata_xml?: string;
Expand All @@ -4858,7 +4874,6 @@ export interface components {
name_id_format?: "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" | "urn:oasis:names:tc:SAML:2.0:nameid-format:transient" | "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" | "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent";
};
domains?: {
id: string;
domain?: string;
created_at?: string;
updated_at?: string;
Expand Down Expand Up @@ -4893,7 +4908,6 @@ export interface components {
UpdateProviderResponse: {
id: string;
saml?: {
id: string;
entity_id: string;
metadata_url?: string;
metadata_xml?: string;
Expand All @@ -4911,7 +4925,6 @@ export interface components {
name_id_format?: "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" | "urn:oasis:names:tc:SAML:2.0:nameid-format:transient" | "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" | "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent";
};
domains?: {
id: string;
domain?: string;
created_at?: string;
updated_at?: string;
Expand All @@ -4922,7 +4935,6 @@ export interface components {
DeleteProviderResponse: {
id: string;
saml?: {
id: string;
entity_id: string;
metadata_url?: string;
metadata_xml?: string;
Expand All @@ -4940,7 +4952,6 @@ export interface components {
name_id_format?: "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified" | "urn:oasis:names:tc:SAML:2.0:nameid-format:transient" | "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" | "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent";
};
domains?: {
id: string;
domain?: string;
created_at?: string;
updated_at?: string;
Expand Down Expand Up @@ -7940,7 +7951,9 @@ export interface operations {
headers: {
[name: string]: unknown;
};
content?: never;
content: {
"application/json": components["schemas"]["PlanGateErrorBody"];
};
};
/** @description Unauthorized */
401: {
Expand Down Expand Up @@ -8049,7 +8062,9 @@ export interface operations {
headers: {
[name: string]: unknown;
};
content?: never;
content: {
"application/json": components["schemas"]["PlanGateErrorBody"];
};
};
/** @description Unauthorized */
401: {
Expand Down Expand Up @@ -8110,7 +8125,9 @@ export interface operations {
headers: {
[name: string]: unknown;
};
content?: never;
content: {
"application/json": components["schemas"]["PlanGateErrorBody"];
};
};
/** @description Unauthorized */
401: {
Expand Down Expand Up @@ -8430,7 +8447,9 @@ export interface operations {
headers: {
[name: string]: unknown;
};
content?: never;
content: {
"application/json": components["schemas"]["PlanGateErrorBody"];
};
};
/** @description Forbidden action */
403: {
Expand Down Expand Up @@ -12909,7 +12928,9 @@ export interface operations {
headers: {
[name: string]: unknown;
};
content?: never;
content: {
"application/json": components["schemas"]["PlanGateErrorBody"];
};
};
/** @description Forbidden action */
403: {
Expand Down Expand Up @@ -12984,7 +13005,9 @@ export interface operations {
headers: {
[name: string]: unknown;
};
content?: never;
content: {
"application/json": components["schemas"]["PlanGateErrorBody"];
};
};
/** @description Forbidden action */
403: {
Expand Down
26 changes: 26 additions & 0 deletions packages/mcp-server-supabase/src/platform/api-platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
deployEdgeFunctionOptionsSchema,
executeSqlOptionsSchema,
getLogsOptionsSchema,
queryLogsOptionsSchema,
resetBranchOptionsSchema,
type AccountOperations,
type ApiKey,
Expand All @@ -38,6 +39,7 @@ import {
type EdgeFunctionWithBody,
type ExecuteSqlOptions,
type GetLogsOptions,
type QueryLogsOptions,
type ResetBranchOptions,
type StorageConfig,
type StorageOperations,
Expand Down Expand Up @@ -277,6 +279,30 @@ export function createSupabaseApiPlatform(

return response.data;
},
async queryLogs(projectId: string, options: QueryLogsOptions) {
const { sql, iso_timestamp_start, iso_timestamp_end } =
queryLogsOptionsSchema.parse(options);

const response = await managementApiClient.GET(
'/v1/projects/{ref}/analytics/endpoints/logs',
{
params: {
path: {
ref: projectId,
},
query: {
sql,
iso_timestamp_start,
iso_timestamp_end,
},
},
}
);

assertSuccess(response, 'Failed to query logs');

return response.data;
},
async getSecurityAdvisors(projectId: string) {
const response = await managementApiClient.GET(
'/v1/projects/{ref}/advisors/security',
Expand Down
8 changes: 8 additions & 0 deletions packages/mcp-server-supabase/src/platform/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ export const getLogsOptionsSchema = z.object({
iso_timestamp_end: z.string().optional(),
});

export const queryLogsOptionsSchema = z.object({
sql: z.string().min(1),
iso_timestamp_start: z.string().optional(),
iso_timestamp_end: z.string().optional(),
});

export const generateTypescriptTypesResultSchema = z.object({
types: z.string(),
});
Expand All @@ -172,6 +178,7 @@ export type ListMigrationsResult = z.infer<typeof migrationSchema>;

export type LogsService = z.infer<typeof logsServiceSchema>;
export type GetLogsOptions = z.infer<typeof getLogsOptionsSchema>;
export type QueryLogsOptions = z.infer<typeof queryLogsOptionsSchema>;
export type GenerateTypescriptTypesResult = z.infer<
typeof generateTypescriptTypesResultSchema
>;
Expand Down Expand Up @@ -212,6 +219,7 @@ export type EdgeFunctionsOperations = {

export type DebuggingOperations = {
getLogs(projectId: string, options: GetLogsOptions): Promise<unknown>;
queryLogs(projectId: string, options: QueryLogsOptions): Promise<unknown>;
getSecurityAdvisors(projectId: string): Promise<unknown>;
getPerformanceAdvisors(projectId: string): Promise<unknown>;
};
Expand Down
Loading
Loading