Skip to content

Commit 48e3ed1

Browse files
authored
Merge pull request #187 from supabase-community/feat/minified-graphql-schema
feat: minifiy content api graphql schema
2 parents da79165 + c021639 commit 48e3ed1

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

packages/mcp-server-supabase/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@modelcontextprotocol/sdk": "^1.18.0",
5151
"@supabase/mcp-utils": "workspace:^",
5252
"common-tags": "^1.8.2",
53+
"gqlmin": "^0.3.1",
5354
"graphql": "^16.11.0",
5455
"openapi-fetch": "^0.13.5",
5556
"zod": "^3.24.1"

packages/mcp-server-supabase/src/content-api/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import gqlmin from 'gqlmin';
12
import { z } from 'zod';
23
import { GraphQLClient, type GraphQLRequest, type QueryFn } from './graphql.js';
34

@@ -25,7 +26,8 @@ export async function createContentApiClient(
2526
loadSchema: async () => {
2627
const response = await graphqlClient.query({ query: '{ schema }' });
2728
const { schema } = contentApiSchemaResponseSchema.parse(response);
28-
return schema;
29+
const minifiedSchema = gqlmin(schema);
30+
return minifiedSchema;
2931
},
3032
async query(request: GraphQLRequest) {
3133
return graphqlClient.query(request);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from '@modelcontextprotocol/sdk/types.js';
66
import { StreamTransport } from '@supabase/mcp-utils';
77
import { codeBlock, stripIndent } from 'common-tags';
8+
import gqlmin from 'gqlmin';
89
import { setupServer } from 'msw/node';
910
import { beforeEach, describe, expect, test } from 'vitest';
1011
import {
@@ -2962,7 +2963,8 @@ describe('docs tools', () => {
29622963
throw new Error('tool description not found');
29632964
}
29642965

2965-
expect(tool.description.includes(contentApiMockSchema)).toBe(true);
2966+
const minifiedSchema = gqlmin(contentApiMockSchema);
2967+
expect(tool.description.includes(minifiedSchema)).toBe(true);
29662968
});
29672969

29682970
test('schema is only loaded when listing tools', async () => {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export function getDocsTools({ contentApiClient }: DocsToolsOptions) {
1616
return source`
1717
Search the Supabase documentation using GraphQL. Must be a valid GraphQL query.
1818
You should default to calling this even if you think you already know the answer, since the documentation is always being updated.
19-
Below is the GraphQL schema for the Supabase docs endpoint:
19+
20+
Below is the GraphQL schema for this tool:
21+
2022
${schema}
2123
`;
2224
},

pnpm-lock.yaml

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)