Skip to main content
Glama
Supabase GodMode MCP Server

Supabase GodMode MCP Server

by prompted365
README.md
# Supabase GodMode MCP Server

> Complete Supabase project management via Model Context Protocol (MCP) with OAuth authentication.

[![Deploy to Smithery](https://smithery.ai/badge)](https://smithery.ai/server/@prompted365/supabase-godmode)
[![npm version](https://badge.fury.io/js/supabase-godmode.svg)](https://www.npmjs.com/package/supabase-godmode)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## šŸš€ Quick Start

**One-click deploy to Smithery** (recommended):

```bash
npx @smithery/cli install @prompted365/supabase-godmode --project_ref YOUR_PROJECT_REF
```

Or [deploy from GitHub](./DEPLOYMENT.md#smithery-deployment-recommended) for automatic CD.

## ✨ Features

- **Account Management** - List projects, manage settings, handle billing
- **Database Operations** - Execute SQL, inspect schema, manage tables
- **Edge Functions** - Deploy, invoke, and monitor serverless functions
- **Storage Management** - Upload files, manage buckets, set permissions
- **Documentation Access** - Search docs, get code examples
- **OAuth Authentication** - Secure token management with auto-refresh

## šŸ“¦ Installation

### Option 1: Smithery (Recommended)

One-click deployment with automatic builds and hosting:

```bash
npx @smithery/cli install @prompted365/supabase-godmode
```

[šŸ“– Full deployment guide](./DEPLOYMENT.md#smithery-deployment-recommended)

### Option 2: Local Development

```bash
# Clone repository
git clone https://github.com/prompted365/supabase-godmode.git
cd supabase-godmode

# Install dependencies
npm install

# Build TypeScript
npm run build

# Run in development mode
npm run dev
```

[šŸ“– See more installation options](./DEPLOYMENT.md)

## āš™ļø Configuration

### Environment Variables

Create a `.env` file:

```bash
PROJECT_REF=your-project-ref
OAUTH_CLIENT_ID=your-oauth-client-id
OAUTH_CLIENT_SECRET=your-oauth-client-secret
FEATURES=docs,account,database,functions,storage
```

### MCP Client Configuration

#### Warp Terminal

Add to your MCP configuration:

```json
{
  "supabase-godmode": {
    "command": "node",
    "args": ["/path/to/supabase-godmode/dist/index.js"],
    "env": {
      "PROJECT_REF": "your-project-ref",
      "OAUTH_CLIENT_ID": "your-client-id",
      "OAUTH_CLIENT_SECRET": "your-client-secret"
    }
  }
}
```

#### Claude Desktop

Add to `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "supabase-godmode": {
      "command": "node",
      "args": ["/path/to/supabase-godmode/dist/index.js"],
      "env": {
        "PROJECT_REF": "your-project-ref"
      }
    }
  }
}
```

## šŸ”§ Available Tools

### Account Management

- **list-projects** - Get all projects for authenticated user
- **get-project-settings** - Retrieve project configuration
- **update-project-settings** - Update project settings

### Database Operations

- **execute-query** - Run SQL queries against your database
- **list-tables** - Get all tables in a schema
- **describe-table** - Get detailed table schema information
- **create-table** - Create new database tables

### Edge Functions

- **list-functions** - List all edge functions
- **deploy-function** - Deploy or update a function
- **invoke-function** - Test function execution
- **get-function-logs** - Retrieve function logs

### Storage Management

- **list-buckets** - List all storage buckets
- **create-bucket** - Create a new bucket
- **upload-file** - Upload files to storage
- **list-files** - List files in a bucket
- **delete-file** - Remove files from storage

### Documentation

- **search-docs** - Search Supabase documentation
- **get-code-example** - Get code examples for operations

## šŸ’” Usage Examples

### Query Database

```typescript
// Through MCP client
await callTool('execute-query', {
  project_ref: 'abc123',
  query: 'SELECT * FROM users WHERE created_at > NOW() - INTERVAL \'7 days\'',
});
```

### Deploy Edge Function

```typescript
await callTool('deploy-function', {
  project_ref: 'abc123',
  function_name: 'hello-world',
  code: `
    export default async (req) => {
      return new Response('Hello World!', {
        headers: { 'Content-Type': 'text/plain' },
      });
    }
  `,
  verify_jwt: true,
});
```

### Upload File to Storage

```typescript
await callTool('upload-file', {
  project_ref: 'abc123',
  bucket: 'avatars',
  path: 'user-123/profile.png',
  file_data: base64EncodedData,
  content_type: 'image/png',
});
```

## šŸ” OAuth Setup

### 1. Create OAuth Application

1. Go to your Supabase project dashboard
2. Navigate to **Authentication > Providers**
3. Create a new OAuth application
4. Set callback URL: `http://localhost:3000/callback`
5. Copy client ID and secret

### 2. Configure Server

Add credentials to `.env`:

```bash
OAUTH_CLIENT_ID=your_client_id
OAUTH_CLIENT_SECRET=your_client_secret
```

### 3. Authenticate

On first run, the server will:
1. Generate authorization URL
2. Open browser for authentication
3. Store tokens securely
4. Auto-refresh when expired

## šŸ› ļø Development

### Project Structure

```
supabase-godmode/
ā”œā”€ā”€ app/
│   ā”œā”€ā”€ server/
│   │   ā”œā”€ā”€ index.ts          # Main server entry
│   │   ā”œā”€ā”€ oauth.ts          # OAuth provider
│   │   └── tools/
│   │       ā”œā”€ā”€ account.ts    # Account tools
│   │       ā”œā”€ā”€ database.ts   # Database tools
│   │       ā”œā”€ā”€ functions.ts  # Edge functions tools
│   │       ā”œā”€ā”€ storage.ts    # Storage tools
│   │       └── docs.ts       # Documentation tools
│   └── shared/
│       └── types.ts          # TypeScript types
ā”œā”€ā”€ smithery.yaml             # Smithery configuration
ā”œā”€ā”€ package.json
└── tsconfig.json
```

### Build Commands

```bash
# Development with hot reload
npm run dev

# Build for production
npm run build

# Run built server
npm start

# Run tests
npm test
```

### Adding New Tools

1. Create tool function in appropriate module
2. Use Zod for parameter validation
3. Handle errors consistently
4. Return MCP-formatted responses

Example:

```typescript
server.tool(
  'my-new-tool',
  {
    description: 'Description of what this tool does',
    parameters: z.object({
      param1: z.string().describe('First parameter'),
      param2: z.number().optional().describe('Optional parameter'),
    }),
  },
  async ({ param1, param2 }) => {
    try {
      // Tool implementation
      return {
        content: [
          {
            type: 'text',
            text: 'Result data',
          },
        ],
      };
    } catch (error: any) {
      return {
        content: [
          {
            type: 'text',
            text: `Error: ${error.message}`,
          },
        ],
        isError: true,
      };
    }
  }
);
```

## šŸ”’ Security

- **Token Storage**: OAuth tokens stored securely in memory
- **Auto-Refresh**: Tokens refreshed automatically before expiration
- **Input Validation**: All inputs validated with Zod schemas
- **SQL Injection**: Use parameterized queries
- **Rate Limiting**: Respects Supabase API rate limits

## šŸ› Troubleshooting

### Common Issues

**OAuth Authentication Fails**
- Verify client ID and secret are correct
- Check callback URL matches OAuth app settings
- Ensure project reference is valid

**Database Query Errors**
- Verify table/column names exist
- Check user permissions
- Review SQL syntax

**Function Deployment Issues**
- Verify function code is valid TypeScript/JavaScript
- Check function name is unique
- Ensure sufficient permissions

### Debug Mode

Enable detailed logging:

```bash
DEBUG=* npm run dev
```

## šŸ¤ Contributing

Contributions welcome! Please:

1. Fork the repository
2. Create a feature branch
3. Add tests for new functionality
4. Submit a pull request

## License

MIT License - see LICENSE file for details

## šŸ“š Documentation

- **[Deployment Guide](./DEPLOYMENT.md)** - Deploy to Smithery, Docker, or serverless
- **[API Reference](./README.md#available-tools)** - Complete tool documentation
- **[Contributing Guide](./CONTRIBUTING.md)** - How to contribute

## šŸ’¬ Support

- **Issues**: [GitHub Issues](https://github.com/prompted365/supabase-godmode/issues)
- **Discussions**: [GitHub Discussions](https://github.com/prompted365/supabase-godmode/discussions)
- **Supabase Docs**: [supabase.com/docs](https://supabase.com/docs)
- **MCP Spec**: [modelcontextprotocol.io](https://modelcontextprotocol.io)

## Acknowledgments

- Built with [@smithery/sdk](https://smithery.ai)
- Powered by [Supabase](https://supabase.com)
- MCP protocol by [Anthropic](https://anthropic.com)

---

**Prompted LLC** - Making AI infrastructure accessible