You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(infrastructure): streamline services startup and testing patterns
This commit enhances the project's infrastructure and testing capabilities:
- Updated CHANGELOG.md with new infrastructure improvements
- Modified pyproject.toml to adjust pytest asyncio fixture scope
- Refactored core container initialization to support synchronous startup
- Updated services to support clean singleton instance reset
- Improved test fixtures and integration test coverage
- Restructured project test directories for better organization
- Added comprehensive integration tests for various services
Copy file name to clipboardExpand all lines: CHANGELOG.MD
+24-31Lines changed: 24 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -5,41 +5,34 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
7
7
8
-
## [0.3.8] - Planned
9
-
## Added
10
-
1. Runtime SQL query validation
11
-
2. Automatic versioning of database changes
12
-
3. Improvement of SQL execution safety mode
13
-
- Categorizes all queries into three safety levels:
14
-
-`safe` - includes all read operations, plus basic postgres commands which do not modify the data or database structure. Always allowed.
15
-
-`write` - includes write operations. Requires `write` db_client mode to be enabled for use.
16
-
-`destructive` - include operations which modify database structure, or can lead to data loss. Require 2-step confirmation to be executed AND a `write` mode enabled.
17
-
4. Exception
18
-
5. More modern postgresql client - `asyncpg`
19
-
6. Eliminated depenente on PostgreSQL client libary
20
-
7. Documentation
21
-
- Management API uses encrytpedHTTPS for connecting
22
-
8. Reliability
23
-
- Implemented retry logic for
24
-
- Establishing connection to the database or API
25
-
- Sending requests / executing statements
26
-
- Improved API management spec tool:
27
-
- return all domains
28
-
- return a specific path and method
29
-
- return all paths and emthods
30
-
- Added code coverage
31
-
9. Infra:
32
-
- Streamlined dependency injection for easier testing
33
-
34
-
## Changed
35
-
- Updated README.md with detailed feature description.
8
+
## [0.3.8] - 2025-03-07
9
+
### Added
10
+
- SQL query validation using PostgreSQL's parser (pglast v7.3+)
11
+
- Automatic migration script generation for schema changes
12
+
- Universal safety system with standardized risk levels (Low/Medium/High/Extreme)
13
+
- Switched to asyncpg v0.30.0+ from psycopg2
14
+
- Enhanced API spec tool with multiple query modes and risk assessment
15
+
- Connection retry logic for database and API operations
16
+
- Code coverage with pytest-cov
17
+
- SQL linting with SQLFluff
18
+
- Added pyyaml v6.0.2+ for configuration
19
+
20
+
### Changed
21
+
- Refactored to use dependency injection pattern
22
+
- Standardized service initialization to synchronous pattern
23
+
- Improved SQL safety categorization:
24
+
-`safe`: Read-only operations (always allowed)
25
+
-`write`: Data modification (requires unsafe mode)
Installing the server requires the following on your system:
58
62
- Python 3.12+
59
-
- PostgresSQL 16+
60
63
61
64
If you plan to install via `uv`, ensure it's [installed](https://docs.astral.sh/uv/getting-started/installation/#__tabbed_1_1).
62
65
63
66
### PostgreSQL Installation
64
-
> ⚠️ **Important**: PostgreSQL must be installed BEFORE installing project dependencies, as psycopg2 requires PostgreSQL development libraries during compilation.
67
+
PostgreSQL installation is no longer required for the MCP server itself, as it now uses asyncpg which doesn't depend on PostgreSQL development libraries.
68
+
69
+
However, you'll still need PostgreSQL if you're running a local Supabase instance:
After installing the package, you'll need to configure your database connection settings. The server supports both local and remote Supabase instances.
117
120
118
121
#### Local Supabase instance (Default)
119
-
Server is pre-configured to connect to the local Supabase instance using default settings:
122
+
Server is pre-configured to connect to the local Supabase instance using default settings:
120
123
-`Host`: 127.0.0.1:54322
121
124
-`Password`: postgres
122
-
-`API URL` : http://127.0.0.1:54321
123
-
125
+
-`API URL`: http://127.0.0.1:54321
124
126
125
127
>💡 As long as you didn't modify the default settings and you want to connect to the local instance, you don't need to set environment variables.
126
128
@@ -156,14 +158,21 @@ The server supports all Supabase regions:
156
158
-`ap-southeast-2` - Oceania (Sydney)
157
159
-`sa-east-1` - South America (São Paulo)
158
160
159
-
Method of MCP configuration differs between Cursor and Windsurf. Read the relevant section to understand how to configure connection.
161
+
#### Configuration Methods
162
+
163
+
The server looks for configuration in this order:
164
+
1. Environment variables (highest priority)
165
+
2. Local `.env` file in current directory
166
+
3. Global config file:
167
+
- Windows: `%APPDATA%/supabase-mcp/.env`
168
+
- macOS/Linux: `~/.config/supabase-mcp/.env`
169
+
4. Default settings (local development)
160
170
161
171
##### Cursor
162
-
Since v0.46 there are two ways to configure MCP servers in Cursor:
172
+
Since Cursor v0.46 there are two ways to configure MCP servers:
163
173
- per project basis -> create `mcp.json` in your project / repo folder and `.env` to configure connection
164
174
- globally -> create an MCP server in Settings and configure using `.env` which is supported by this MCP server only
165
175
166
-
167
176
You can create project-specific MCP by:
168
177
- creating .cursor folder in your repo, if doesn't exist
169
178
- creating or updating `mcp.json` file with the following settings
@@ -333,76 +342,69 @@ A super useful tool to help debug MCP server issues is MCP Inspector. If you ins
333
342
334
343
### Database query tools
335
344
336
-
Since v0.3.0 server supports both read-only and data modification operations:
337
-
338
-
- **Read operations**: SELECT queries for data retrieval
339
-
- **Data Manipulation Language (DML)**: INSERT, UPDATE, DELETE operations for data changes
340
-
- **Data Definition Language (DDL)**: CREATE, ALTER, DROP operations for schema changes*
341
-
342
-
*Note: DDL operations require:
343
-
1. Read-write mode enabled via `live_dangerously`
344
-
2. Sufficient permissions for the connected database role
345
-
346
-
#### Transaction Handling
347
-
348
-
The server supports two approaches for executing write operations:
CREATE TABLE public.test_table (id SERIAL PRIMARY KEY, name TEXT);
354
-
COMMIT;
355
-
```
356
-
357
-
2. **Single Statements**:
358
-
```sql
359
-
CREATE TABLE public.test_table (id SERIAL PRIMARY KEY, name TEXT);
360
-
```
361
-
362
-
For DDL operations (CREATE/ALTER/DROP), tool description appropriately guides Cursor/Windsurft to use explicit transaction control with BEGIN/COMMIT blocks.
363
-
364
-
#### Connection Types
365
-
366
-
This MCP server uses::
367
-
- **Direct Database Connection**: when connecting to a local Supabase instance
368
-
- **Transaction Pooler Connections**: when connecting to a remote Supabase instance
369
-
370
-
371
-
When connecting via Supabase's Transaction Pooler, some complex transaction patterns may not work as expected. For schema changes in these environments, use explicit transaction blocks or consider using Supabase migrations or the SQL Editor in the dashboard.
372
-
373
-
Available database tools:
374
-
- `get_db_schemas` - Lists all database schemas with their sizes and table counts
375
-
- `get_tables` - Lists all tables in a schema with their sizes, row counts, and metadata
376
-
- `get_table_schema` - Gets detailed table structure including columns, keys, and relationships
377
-
- `execute_sql_query` - Executes raw SQL queries with comprehensive support for all PostgreSQL operations:
- `blocked`: Destructive operations (delete project, etc.) - never allowed
401
+
- Default safe mode prevents accidental state changes
402
+
- Path-based pattern matching for precise safety rules
403
+
404
+
**Note**: Management API tools only work with remote Supabase instances and are not compatible with local Supabase development setups.
404
405
405
406
### Auth Admin tools
407
+
406
408
I was planning to add support for Python SDK methods to the MCP server. Upon consideration I decided to only add support for Auth admin methods as I often found myself manually creating test users which was prone to errors and time consuming. Now I can just ask Cursor to create a test user and it will be done seamlessly. Check out the full Auth Admin SDK method docs to know what it can do.
407
409
408
410
Since v0.3.6 server supports direct access to Supabase Auth Admin methods via Python SDK:
@@ -440,13 +442,29 @@ The Auth Admin SDK provides several key advantages over direct SQL manipulation:
440
442
441
443
### Automatic Versioning of Database Changes
442
444
443
-
"With great power comes great responsibility." While `execute_sql_query` tool coupled with aptly named `live_dangerously` tool provide a powerful and simple way to manage your Supabase database, it also means that dropping a table or modifying one is one chat message away. In order to reduce the risk of irreversible changes, since v0.3.8 the server supports:
445
+
"With great power comes great responsibility." While `execute_postgresql` tool coupled with aptly named `live_dangerously` tool provide a powerful and simple way to manage your Supabase database, it also means that dropping a table or modifying one is one chat message away. In order to reduce the risk of irreversible changes, since v0.3.8 the server supports:
444
446
- automatic creation of migration scripts for all write & destructive sql operations executed on the database
445
447
- improved safety mode of query execution, in which all queries are categorized in:
446
448
- `safe` type: always allowed. Includes all read-only ops.
447
449
- `write`type: requires `write` mode to be enabled by the user.
448
450
- `destructive` type: requires `write` mode to be enabled by the user AND a 2-step confirmation of query execution for clients that do not execute tools automatically.
449
451
452
+
### Universal Safety Mode
453
+
Since v0.3.8 Safety Mode has been standardized across all services (database, API, SDK) using a universal safety manager. This provides consistent risk management and a unified interface for controlling safety settings across the entire MCP server.
454
+
455
+
All operations (SQL queries, API requests, SDK methods) are categorized into risk levels:
456
+
- `Low` risk: Read-only operations that don't modify data or structure (SELECT queries, GET API requests)
457
+
- `Medium` risk: Write operations that modify data but not structure (INSERT/UPDATE/DELETE, most POST/PUT API requests)
458
+
- `High` risk: Destructive operations that modify database structure or could cause data loss (DROP/TRUNCATE, DELETE API endpoints)
459
+
- `Extreme` risk: Operations with severe consequences that are blocked entirely (deleting projects)
460
+
461
+
Safety controls are applied based on risk level:
462
+
- Low risk operations are always allowed
463
+
- Medium risk operations require unsafe mode to be enabled
464
+
- High risk operations require unsafe mode AND explicit confirmation
465
+
- Extreme risk operations are never allowed
466
+
467
+
This universal approach ensures consistent protection across all server components while providing flexibility for legitimate operations when needed.
450
468
451
469
## Feature Changelog
452
470
@@ -457,12 +475,10 @@ The Auth Admin SDK provides several key advantages over direct SQL manipulation:
457
475
- 🔄 Robust transaction handling for both direct and pooled connections - ✅ (v0.3.2)
458
476
- 🐍 Support methods and objects available in native Python SDK - ✅ (v0.3.6)
459
477
- 🔍 Stronger SQL query validation ✅ (v0.3.8)
460
-
- 📝 Automatic versioning of DDL queries ✅ (v0.3.8)
478
+
- 📝 Automatic versioning of database changes ✅ (v0.3.8)
479
+
- 📖 Radically improved knowledge and tools of api spec ✅ (v0.3.8)
461
480
- 🪵 Tools / resources to more easily access database, edge functions logs (?)
462
-
- 👨💻 Supabase CLI integration (?)
463
-
- 📖 Radically improved knowledge and tools of api spec
464
-
- Resources to more easily access and check api spec
465
-
- Atomic url paths and ops (right now LLM trips more often then not)
481
+
466
482
467
483
For a more detailed roadmap, please see this [discussion](github.com) on GitHub.
0 commit comments