Skip to content

Commit 25bd3c6

Browse files
authored
Merge pull request #98 from Ngineer101/main
feat: allow enabling of specific feature groups + adds storage tools
2 parents 65e79ec + acfa755 commit 25bd3c6

File tree

12 files changed

+740
-49
lines changed

12 files changed

+740
-49
lines changed

README.md

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ The following options are available:
5353

5454
- `--read-only`: Used to restrict the server to read-only queries. Recommended by default. See [read-only mode](#read-only-mode).
5555
- `--project-ref`: Used to scope the server to a specific project. Recommended by default. If you omit this, the server will have access to all projects in your Supabase account. See [project scoped mode](#project-scoped-mode).
56+
- `--features`: Used to specify which tool groups to enable. See [feature groups](#feature-groups).
5657

5758
If you are on Windows, you will need to [prefix the command](#windows). If your MCP client doesn't accept JSON, the direct CLI command is:
5859

@@ -147,13 +148,27 @@ npx -y @supabase/mcp-server-supabase@latest --read-only
147148

148149
We recommend you enable this by default. This prevents write operations on any of your databases by executing SQL as a read-only Postgres user. Note that this flag only applies to database tools (`execute_sql` and `apply_migration`) and not to other tools like `create_project` or `create_branch`.
149150

151+
### Feature groups
152+
153+
You can enable or disable specific tool groups by passing the `--features` flag to the MCP server. This allows you to customize which tools are available to the LLM. For example, to enable only the [database](#database) and [docs](#knowledge-base) tools, you would run:
154+
155+
```shell
156+
npx -y @supabase/mcp-server-supabase@latest --features=database,docs
157+
```
158+
159+
Available groups are: [`account`](#account), [`docs`](#knowledge-base), [`database`](#database), [`debug`](#debug), [`development`](#development), [`functions`](#edge-functions), [`storage`](#storage), and [`branching`](#branching-experimental-requires-a-paid-plan).
160+
161+
If this flag is not passed, the default feature groups are: `account`, `database`, `debug`, `development`, `docs`, and `functions`.
162+
150163
## Tools
151164

152165
_**Note:** This server is pre-1.0, so expect some breaking changes between versions. Since LLMs will automatically adapt to the tools available, this shouldn't affect most users._
153166

154-
The following Supabase tools are available to the LLM:
167+
The following Supabase tools are available to the LLM, [grouped by feature](#feature-groups).
168+
169+
#### Account
155170

156-
#### Project Management
171+
Enabled by default when no `--project-ref` is passed. Use `account` to target this group of tools with the [`--features`](#feature-groups) option.
157172

158173
_**Note:** these tools will be unavailable if the server is [scoped to a project](#project-scoped-mode)._
159174

@@ -164,46 +179,66 @@ _**Note:** these tools will be unavailable if the server is [scoped to a project
164179
- `restore_project`: Restores a project.
165180
- `list_organizations`: Lists all organizations that the user is a member of.
166181
- `get_organization`: Gets details for an organization.
182+
- `get_cost`: Gets the cost of a new project or branch for an organization.
183+
- `confirm_cost`: Confirms the user's understanding of new project or branch costs. This is required to create a new project or branch.
167184

168-
#### Database Operations
185+
#### Knowledge Base
186+
187+
Enabled by default. Use `docs` to target this group of tools with the [`--features`](#feature-groups) option.
188+
189+
- `search_docs`: Searches the Supabase documentation for up-to-date information. LLMs can use this to find answers to questions or learn how to use specific features.
190+
191+
#### Database
192+
193+
Enabled by default. Use `database` to target this group of tools with the [`--features`](#feature-groups) option.
169194

170195
- `list_tables`: Lists all tables within the specified schemas.
171196
- `list_extensions`: Lists all extensions in the database.
172197
- `list_migrations`: Lists all migrations in the database.
173198
- `apply_migration`: Applies a SQL migration to the database. SQL passed to this tool will be tracked within the database, so LLMs should use this for DDL operations (schema changes).
174199
- `execute_sql`: Executes raw SQL in the database. LLMs should use this for regular queries that don't change the schema.
200+
201+
#### Debug
202+
203+
Enabled by default. Use `debug` to target this group of tools with the [`--features`](#feature-groups) option.
204+
175205
- `get_logs`: Gets logs for a Supabase project by service type (api, postgres, edge functions, auth, storage, realtime). LLMs can use this to help with debugging and monitoring service performance.
176206
- `get_advisors`: Gets a list of advisory notices for a Supabase project. LLMs can use this to check for security vulnerabilities or performance issues.
177207

178-
#### Edge Function Management
208+
#### Development
209+
210+
Enabled by default. Use `development` to target this group of tools with the [`--features`](#feature-groups) option.
211+
212+
- `get_project_url`: Gets the API URL for a project.
213+
- `get_anon_key`: Gets the anonymous API key for a project.
214+
- `generate_typescript_types`: Generates TypeScript types based on the database schema. LLMs can save this to a file and use it in their code.
215+
216+
#### Edge Functions
217+
218+
Enabled by default. Use `functions` to target this group of tools with the [`--features`](#feature-groups) option.
179219

180220
- `list_edge_functions`: Lists all Edge Functions in a Supabase project.
181221
- `deploy_edge_function`: Deploys a new Edge Function to a Supabase project. LLMs can use this to deploy new functions or update existing ones.
182222

183-
#### Project Configuration
223+
#### Storage
184224

185-
- `get_project_url`: Gets the API URL for a project.
186-
- `get_anon_key`: Gets the anonymous API key for a project.
225+
Disabled by default to reduce tool count. Use `storage` to target this group of tools with the [`--features`](#feature-groups) option.
226+
227+
- `list_storage_buckets`: Lists all storage buckets in a Supabase project.
228+
- `get_storage_config`: Gets the storage config for a Supabase project.
229+
- `update_storage_config`: Updates the storage config for a Supabase project (requires a paid plan).
187230

188231
#### Branching (Experimental, requires a paid plan)
189232

233+
Disabled by default to reduce tool count. Use `branching` to target this group of tools with the [`--features`](#feature-groups) option.
234+
190235
- `create_branch`: Creates a development branch with migrations from production branch.
191236
- `list_branches`: Lists all development branches.
192237
- `delete_branch`: Deletes a development branch.
193238
- `merge_branch`: Merges migrations and edge functions from a development branch to production.
194239
- `reset_branch`: Resets migrations of a development branch to a prior version.
195240
- `rebase_branch`: Rebases development branch on production to handle migration drift.
196241

197-
#### Development Tools
198-
199-
- `search_docs`: Searches the Supabase documentation for up-to-date information. LLMs can use this to find answers to questions or learn how to use specific features.
200-
- `generate_typescript_types`: Generates TypeScript types based on the database schema. LLMs can save this to a file and use it in their code.
201-
202-
#### Cost Confirmation
203-
204-
- `get_cost`: Gets the cost of a new project or branch for an organization.
205-
- `confirm_cost`: Confirms the user's understanding of new project or branch costs. This is required to create a new project or branch.
206-
207242
## Other MCP servers
208243

209244
### `@supabase/mcp-server-postgrest`

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ type SetupOptions = {
1313
accessToken?: string;
1414
projectId?: string;
1515
readOnly?: boolean;
16+
features?: string[];
1617
};
1718

1819
async function setup(options: SetupOptions = {}) {
19-
const { accessToken = ACCESS_TOKEN, projectId, readOnly } = options;
20+
const { accessToken = ACCESS_TOKEN, projectId, readOnly, features } = options;
2021
const clientTransport = new StreamTransport();
2122
const serverTransport = new StreamTransport();
2223

@@ -40,6 +41,7 @@ async function setup(options: SetupOptions = {}) {
4041
},
4142
projectId,
4243
readOnly,
44+
features,
4345
});
4446

4547
await server.connect(serverTransport);

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

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
type ExecuteSqlOptions,
3030
type GetLogsOptions,
3131
type ResetBranchOptions,
32+
type StorageConfig,
3233
type SupabasePlatform,
3334
} from './index.js';
3435

@@ -600,6 +601,69 @@ export function createSupabaseApiPlatform(
600601

601602
assertSuccess(response, 'Failed to rebase branch');
602603
},
604+
605+
// Storage methods
606+
async listAllBuckets(project_id: string) {
607+
const response = await managementApiClient.GET(
608+
'/v1/projects/{ref}/storage/buckets',
609+
{
610+
params: {
611+
path: {
612+
ref: project_id,
613+
},
614+
},
615+
}
616+
);
617+
618+
assertSuccess(response, 'Failed to list storage buckets');
619+
620+
return response.data;
621+
},
622+
623+
async getStorageConfig(project_id: string) {
624+
const response = await managementApiClient.GET(
625+
'/v1/projects/{ref}/config/storage',
626+
{
627+
params: {
628+
path: {
629+
ref: project_id,
630+
},
631+
},
632+
}
633+
);
634+
635+
assertSuccess(response, 'Failed to get storage config');
636+
637+
return response.data;
638+
},
639+
640+
async updateStorageConfig(projectId: string, config: StorageConfig) {
641+
const response = await managementApiClient.PATCH(
642+
'/v1/projects/{ref}/config/storage',
643+
{
644+
params: {
645+
path: {
646+
ref: projectId,
647+
},
648+
},
649+
body: {
650+
fileSizeLimit: config.fileSizeLimit,
651+
features: {
652+
imageTransformation: {
653+
enabled: config.features.imageTransformation.enabled,
654+
},
655+
s3Protocol: {
656+
enabled: config.features.s3Protocol.enabled,
657+
},
658+
},
659+
},
660+
}
661+
);
662+
663+
assertSuccess(response, 'Failed to update storage config');
664+
665+
return response.data;
666+
},
603667
};
604668

605669
return platform;

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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1+
import type { InitData } from '@supabase/mcp-utils';
12
import { z } from 'zod';
23
import { AWS_REGION_CODES } from '../regions.js';
3-
import type { InitData } from '@supabase/mcp-utils';
4+
5+
export const storageBucketSchema = z.object({
6+
id: z.string(),
7+
name: z.string(),
8+
owner: z.string(),
9+
created_at: z.string(),
10+
updated_at: z.string(),
11+
public: z.boolean(),
12+
});
13+
14+
export const storageConfigSchema = z.object({
15+
fileSizeLimit: z.number(),
16+
features: z.object({
17+
imageTransformation: z.object({ enabled: z.boolean() }),
18+
s3Protocol: z.object({ enabled: z.boolean() }),
19+
}),
20+
});
421

522
export const organizationSchema = z.object({
623
id: z.string(),
@@ -135,6 +152,9 @@ export type GenerateTypescriptTypesResult = z.infer<
135152
typeof generateTypescriptTypesResultSchema
136153
>;
137154

155+
export type StorageConfig = z.infer<typeof storageConfigSchema>;
156+
export type StorageBucket = z.infer<typeof storageBucketSchema>;
157+
138158
export type SupabasePlatform = {
139159
init?(info: InitData): Promise<void>;
140160

@@ -146,7 +166,7 @@ export type SupabasePlatform = {
146166
options: ApplyMigrationOptions
147167
): Promise<void>;
148168

149-
// Project management
169+
// Account
150170
listOrganizations(): Promise<Pick<Organization, 'id' | 'name'>[]>;
151171
getOrganization(organizationId: string): Promise<Organization>;
152172
listProjects(): Promise<Project[]>;
@@ -188,4 +208,9 @@ export type SupabasePlatform = {
188208
mergeBranch(branchId: string): Promise<void>;
189209
resetBranch(branchId: string, options: ResetBranchOptions): Promise<void>;
190210
rebaseBranch(branchId: string): Promise<void>;
211+
212+
// Storage
213+
getStorageConfig(projectId: string): Promise<StorageConfig>;
214+
updateStorageConfig(projectId: string, config: StorageConfig): Promise<void>;
215+
listAllBuckets(projectId: string): Promise<StorageBucket[]>;
191216
};

0 commit comments

Comments
 (0)