File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
packages/mcp-server-supabase/src Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,13 @@ export class GraphQLClient {
149
149
}
150
150
}
151
151
152
+ /**
153
+ * Sets the User-Agent header for all requests.
154
+ */
155
+ setUserAgent ( userAgent : string ) {
156
+ this . #headers[ 'User-Agent' ] = userAgent ;
157
+ }
158
+
152
159
/**
153
160
* Executes a GraphQL query against the provided URL.
154
161
*
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ const contentApiSchemaResponseSchema = z.object({
8
8
export type ContentApiClient = {
9
9
schema : string ;
10
10
query : QueryFn ;
11
+ setUserAgent : ( userAgent : string ) => void ;
11
12
} ;
12
13
13
14
export async function createContentApiClient (
@@ -32,5 +33,8 @@ export async function createContentApiClient(
32
33
async query ( request : GraphQLRequest ) {
33
34
return graphqlClient . query ( request ) ;
34
35
} ,
36
+ setUserAgent ( userAgent : string ) {
37
+ graphqlClient . setUserAgent ( userAgent ) ;
38
+ } ,
35
39
} ;
36
40
}
Original file line number Diff line number Diff line change @@ -92,7 +92,9 @@ export function createSupabaseMcpServer(options: SupabaseMcpServerOptions) {
92
92
contentApiUrl = 'https://supabase.com/docs/api/graphql' ,
93
93
} = options ;
94
94
95
- const contentApiClientPromise = createContentApiClient ( contentApiUrl ) ;
95
+ const contentApiClientPromise = createContentApiClient ( contentApiUrl , {
96
+ 'User-Agent' : `supabase-mcp/${ version } ` ,
97
+ } ) ;
96
98
97
99
const enabledFeatures = z
98
100
. set ( featureGroupSchema )
@@ -104,7 +106,15 @@ export function createSupabaseMcpServer(options: SupabaseMcpServerOptions) {
104
106
async onInitialize ( info ) {
105
107
// Note: in stateless HTTP mode, `onInitialize` will not always be called
106
108
// so we cannot rely on it for initialization. It's still useful for telemetry.
107
- await platform . init ?.( info ) ;
109
+ const { clientInfo } = info ;
110
+ const userAgent = `supabase-mcp/${ version } (${ clientInfo . name } /${ clientInfo . version } )` ;
111
+
112
+ await Promise . all ( [
113
+ platform . init ?.( info ) ,
114
+ contentApiClientPromise . then ( ( client ) =>
115
+ client . setUserAgent ( userAgent )
116
+ ) ,
117
+ ] ) ;
108
118
} ,
109
119
tools : async ( ) => {
110
120
const contentApiClient = await contentApiClientPromise ;
You can’t perform that action at this time.
0 commit comments