Database-Facade-MCP-Module
A specialized Model Context Protocol (MCP) agent designed to interface with Supabase instances, facilitating structured database querying and automated generation of corresponding TypeScript interface definitions directly from the schema.
Author

NightTrek
Quick Info
Actions
Tags
Supabase Integration Agent for MCP
This server functions as a Model Context Protocol (MCP) bridge, enabling interaction with Supabase backends. Its primary capabilities include executing detailed data retrieval operations and deriving precise TypeScript data structures from the underlying database schema.
Core Capabilities
- Data Retrieval Execution: Perform complex SQL interactions against any table, supporting:
- Explicit schema declaration
- Column projection limitations
- Conditional filtering via multiple logical operators
- Offset/limit based pagination
-
Robust operational feedback mechanism
-
Type Schema Synthesis: Automatically derive TypeScript definitions for database entities:
- Compatibility across all defined schemas (e.g., public, auth, storage)
- Operational parity for locally run or externally hosted Supabase environments
- Direct streaming of generated types to the console interface
- Automated discovery of necessary project configuration references
Prerequisites for Deployment
- Runtime Environment: Node.js (version 16 or superior is mandatory)
- Target System: An accessible Supabase project (local deployment or remote service)
- CLI Dependency: The official Supabase command-line utility (essential for type derivation)
Deployment Procedure
-
Obtain Repository Source Code: bash git clone https://github.com/yourusername/supabase-mcp-server.git cd supabase-mcp-server
-
Install Required Dependencies: bash npm install
-
Install Supabase CLI (a dependency for schema tooling): bash
Via npm package manager
npm install -g supabase
Alternative for macOS users via Homebrew
brew install supabase/tap/supabase
Configuration Steps
- Acquire Supabase Access Credentials:
-
Remote Services:
- Access the project dashboard settings.
- Navigate to the API configuration section.
- Secure the Project URL and the
service_roleauthorization token (theanonkey is insufficient).
-
Local Instances:
- Ensure the local Supabase stack is operational.
- Utilize the default local endpoint (commonly
http://localhost:54321). - Use the local
service_rolecredential set.
-
Establish Environment Variables: bash
Create and populate the .env file (ensuring it is git-ignored)
echo "SUPABASE_URL=your_project_url SUPABASE_KEY=your_service_role_key" > .env
- Compile the Server Artifacts: bash npm run build
Integration Protocols
Integration with Claude Desktop Environment
- Access Claude Desktop Configuration File:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json -
Linux:
~/.config/Claude/claude_desktop_config.json -
Inject the Server Definition:
{ "mcpServers": { "supabase": { "command": "node", "args": ["/absolute/path/to/supabase-mcp-server/build/index.js"], "env": { "SUPABASE_URL": "your_project_url", "SUPABASE_KEY": "your_service_role_key" } } } }
Integration with VSCode Extension (Claude Dev)
- Locate VSCode Settings File:
- macOS:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json - Windows:
%APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json -
Linux:
~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json -
Apply the Configuration (Structure mirrors the Claude Desktop schema).
Operational Examples
Executing a Data Fetch Operation
typescript
// Example: Retrieving specific fields from 'users' table with a boolean filter
Deriving TypeScript Definitions
typescript
// Example: Generating types for the primary database schema
Available Service Functions
query_table
Retrieves records from a designated table, supporting schema scope and detailed filtering.
Parameters:
- schema (Optional): The database schema namespace; defaults to 'public'.
- table (Mandatory): The precise name of the data collection to query.
- select (Optional): A comma-delimited string specifying columns for projection.
- where (Optional): An array defining filtering criteria, each element requiring:
- column: The field identifier.
- operator: Must be one of: eq, neq, gt, gte, lt, lte, like, ilike, is.
- value: The target comparison data point.
generate_types
Initiates the process of synthesizing TypeScript interfaces based on the database structure.
Parameters:
- schema (Optional): The schema to analyze; defaults to 'public'.
Troubleshooting Diagnostics
Issues Related to Type Generation Failures
-
CLI Verification: Ensure the Supabase utility is callable: bash supabase --version
-
Local Project Validation:
- Confirm the Supabase local services are actively running.
-
Cross-reference the configured
service_rolekey for accuracy. -
Hosted Project Verification:
- Validate that the extracted project reference identifier is correct.
- Confirm that the supplied credentials utilize the elevated
service_rolescope.
Anomalies During Data Retrieval
- Verify Schema/Table Naming Conventions.
- Validate column names within both projection (
select) and filtering (where) definitions. - Confirm that the
service_rolepossesses adequate read permissions on the target objects.
Contribution Guidelines
- Fork the primary repository.
- Establish a feature branch:
git checkout -b feature/new-enhancement - Commit relevant modifications:
git commit -am 'Feat: Implemented [X]' - Push the branch to the origin remote:
git push origin feature/new-enhancement - Submit a formal Pull Request for review.
Licensing
This project operates under the terms of the MIT License (refer to the LICENSE file).
WIKIPEDIA: Cloud computing is defined by ISO as "a paradigm for enabling network access to a scalable and elastic pool of shareable physical or virtual resources with self-service provisioning and administration on-demand." It is often colloquially termed "the cloud."
== Key Attributes == The National Institute of Standards and Technology (NIST) formalized five indispensable traits for cloud infrastructures in 2011. These definitions are authoritative:
On-demand self-service: "A consumer can unilaterally provision computing capabilities, such as server time and network storage, as needed automatically without requiring human interaction with each service provider." Broad network access: "Capabilities are available over the network and accessed through standard mechanisms that promote use by heterogeneous thin or thick client platforms (e.g., mobile phones, tablets, laptops, and workstations)." Resource pooling: " The provider's computing resources are pooled to serve multiple consumers using a multi-tenant model, with different physical and virtual resources dynamically assigned and reassigned according to consumer demand." Rapid elasticity: "Capabilities can be elastically provisioned and released, in some cases automatically, to scale rapidly outward and inward commensurate with demand. To the consumer, the capabilities available for provisioning often appear unlimited and can be appropriated in any quantity at any time." Measured service: "Cloud systems automatically control and optimize resource use by leveraging a metering capability at some level of abstraction appropriate to the type of service (e.g., storage, processing, bandwidth, and active user accounts). Resource usage can be monitored, controlled, and reported, providing transparency for both the provider and consumer of the utilized service." ISO has since updated and expanded these criteria as of 2023.
== Historical Context ==
The conceptual foundation of cloud computing traces back to the 1960s with the maturation of time-sharing systems facilitated by remote job entry (RJE). During this period, the operational model centered on data centers, where users submitted tasks to specialized operators managing mainframe systems. The focus was heavily on experimentation to maximize the accessibility of high-capacity computational resources through time-sharing, optimizing infrastructure, platform layers, applications, and overall end-user efficiency. The adoption of the 'cloud' graphical abstraction for virtualized services surfaced in 1994, utilized by General Magic to denote the accessible domain for agents operating within their Telescript environment. This visual metaphor is largely attributed to David Hoffman, a communications strategist at General Magic, who based it on established conventions within telecommunications and networking. The term 'cloud computing' gained mainstream traction in 1996 following a business strategy document drafted by Compaq Computer Corporation outlining their vision for future internet and computing capabilities.
