• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase-community / supabase-mcp / 16727694595

04 Aug 2025 03:41PM UTC coverage: 96.357% (+0.03%) from 96.328%
16727694595

push

github

web-flow
Merge pull request #119 from supabase-community/charis/user-agent

fix: add user-agent string to content api requests

225 of 244 branches covered (92.21%)

Branch coverage included in aggregate %.

17 of 17 new or added lines in 3 files covered. (100.0%)

2076 of 2144 relevant lines covered (96.83%)

34.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.5
/packages/mcp-server-supabase/src/management-api/index.ts
1
import createClient, {
2✔
2
  type Client,
3
  type FetchResponse,
4
  type ParseAsResponse,
5
} from 'openapi-fetch';
6
import type {
7
  MediaType,
8
  ResponseObjectMap,
9
  SuccessResponse,
10
} from 'openapi-typescript-helpers';
11
import { z } from 'zod';
12
import type { paths } from './types.js';
13

14
export function createManagementApiClient(
2✔
15
  baseUrl: string,
143✔
16
  accessToken: string,
143✔
17
  headers: Record<string, string> = {}
143✔
18
) {
143✔
19
  return createClient<paths>({
143✔
20
    baseUrl,
143✔
21
    headers: {
143✔
22
      Authorization: `Bearer ${accessToken}`,
143✔
23
      ...headers,
143✔
24
    },
143✔
25
  });
143✔
26
}
143✔
27

28
export type ManagementApiClient = Client<paths>;
29

30
export type SuccessResponseType<
31
  T extends Record<string | number, any>,
32
  Options,
33
  Media extends MediaType,
34
> = {
35
  data: ParseAsResponse<SuccessResponse<ResponseObjectMap<T>, Media>, Options>;
36
  error?: never;
37
  response: Response;
38
};
39

40
const errorSchema = z.object({
2✔
41
  message: z.string(),
2✔
42
});
2✔
43

44
export function assertSuccess<
2✔
45
  T extends Record<string | number, any>,
46
  Options,
47
  Media extends MediaType,
48
>(
49
  response: FetchResponse<T, Options, Media>,
100✔
50
  fallbackMessage: string
100✔
51
): asserts response is SuccessResponseType<T, Options, Media> {
100✔
52
  if ('error' in response) {
100✔
53
    if (response.response.status === 401) {
7✔
54
      throw new Error(
1✔
55
        'Unauthorized. Please provide a valid access token to the MCP server via the --access-token flag or SUPABASE_ACCESS_TOKEN.'
1✔
56
      );
1✔
57
    }
1✔
58

59
    const { data: errorContent } = errorSchema.safeParse(response.error);
6✔
60

61
    if (errorContent) {
6✔
62
      throw new Error(errorContent.message);
6✔
63
    }
6!
64

65
    throw new Error(fallbackMessage);
×
66
  }
×
67
}
100✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc