Skip to content

Conversation

@Rodriguespn
Copy link

@Rodriguespn Rodriguespn commented Oct 29, 2025

⚠️ This PR was vibe coded, proceed with caution

What

Implements supabase mcp init command to help users configure Model Context Protocol (MCP) clients to work with Supabase's remote MCP server.

Why

Closes https://linear.app/supabase/issue/AI-81

Users need an easy way to set up MCP integration with their preferred AI coding assistants without manually editing JSON configuration files.

How

Features

  • Interactive client detection: Automatically detects installed MCP clients on the system
  • 3 supported clients: Claude Code, Cursor, and VS Code (with architecture for easy addition of more)
  • --client flag: Target specific client for configuration
  • Remote server setup: Configures production server at https://mcp.supabase.com/mcp
  • Auto-configuration:
    • Claude Code: Uses claude mcp add CLI command
    • Cursor: Creates/updates .cursor/mcp.json with server URL
    • VS Code: Creates/updates .vscode/mcp.json with server config (type: http)
  • Installation validation: Checks for actual binary/app presence before attempting configuration
  • Project-local & global configs: Supports both workspace and user-level configurations
  • Config merging: Intelligently merges with existing MCP configurations

Architecture

Built with scalability in mind:

  • Client interface: Defines contract for all MCP clients
  • Base client: Provides common functionality via composition
  • Separate files: Each client implementation in its own file
  • Easy extensibility: Add new clients by creating a file and registering in clientRegistry

File structure:

internal/mcp/init/
├── client.go       # Interface and base client
├── claude_code.go  # Claude Code implementation
├── cursor.go       # Cursor implementation  
├── vscode.go       # VS Code implementation
├── utils.go        # Helper functions
├── init.go         # Core logic and registry
└── README.md       # Developer documentation

Client-Specific Configurations

Claude Code

claude mcp add --transport http supabase https://mcp.supabase.com/mcp

Cursor (.cursor/mcp.json)

{
  "mcpServers": {
    "supabase": {
      "url": "https://mcp.supabase.com/mcp"
    }
  }
}

VS Code (.vscode/mcp.json)

{
  "mcpServers": {
    "supabase": {
      "type": "http",
      "url": "https://mcp.supabase.com/mcp"
    }
  }
}

Usage Examples

# Interactive mode - detects installed clients and configures automatically
supabase mcp init

# Target specific client
supabase mcp init --client claude-code
supabase mcp init --client cursor
supabase mcp init --client vscode

# See all supported clients
supabase mcp init --help

User Experience Flow

  1. No clients installed: Shows list of available clients with installation instructions
  2. One client installed: Automatically configures that client
  3. Multiple clients installed: Shows menu and prompts user to choose via --client flag
  4. Specific client requested: Configures that client or shows installation instructions

Testing

  • ✅ Command compiles and installs successfully
  • ✅ Interactive mode detects installed clients correctly
  • ✅ Installation detection works (no false positives)
  • ✅ Config files generated with valid JSON structure
  • ✅ Existing configs are preserved and merged correctly
  • ✅ Works across all three clients (Claude Code, Cursor, VS Code)

Related

Notes

  • Command is in groupQuickStart (no authentication required)
  • Uses afero filesystem abstraction for testability
  • Scalable architecture makes adding new clients straightforward
  • Developer documentation included for adding new clients

- Add main mcp command group in cmd/mcp.go
- Add mcp init subcommand in cmd/mcp_init.go
- Create internal/mcp/init package for implementation
- Provides basic structure for interactive MCP server setup wizard

This implements the foundation for AI-81: CLI init command that will:
- Guide users through obtaining a Supabase PAT
- Detect installed MCP clients (Cursor, VS Code, Claude Desktop)
- Generate appropriate configuration files
- Securely store credentials

Related: https://linear.app/supabase/issue/AI-81/cli-init
Change mcpCmd.GroupID from groupManagementAPI to groupQuickStart to avoid
requiring authentication before running mcp init. The init command should
be accessible without prior login as it guides users through setup.
- Add --client flag to specify target MCP client
- Implement client detection for Cursor, VS Code, Claude Desktop, Claude Code, Windsurf, and Cline
- Generate platform-specific config templates based on official Supabase docs
- Display setup instructions for each client type
- Support macOS, Windows, and Linux config paths
…ude Code

- Add configureJSONClient() to automatically create/update mcp.json files
- Support project-local and global configuration options
- Prompt for project reference interactively
- Handle existing configs by merging (not overwriting)
- Add configureClaudeCode() to use Claude CLI for configuration
- Detect if Claude CLI is available and run 'claude mcp add' command
- Display step-by-step next actions after configuration
- Mark clients as CanAutomate: cursor, vscode, claude-code
- Add actual client binary/app detection instead of just checking config directories
- Add isClientInstalled() that checks for:
  * Cursor: cursor binary or Cursor.app
  * VS Code: code binary
  * Claude Desktop: Claude.app
  * Claude Code: claude CLI
  * Windsurf: windsurf binary or Windsurf.app
  * Cline: VS Code (as it's an extension)
- Switch from local NPX server to remote OAuth server at https://mcp.supabase.com/mcp
- Update config templates to use remote server format with:
  * type: 'remote'
  * url: https://mcp.supabase.com/mcp
  * OAuth configuration with api.supabase.com
  * SUPABASE_MCP_SERVER_PERSONAL_ACCESS_TOKEN env var
- Show manual config instructions when client not installed
- Separate installed vs. available clients in interactive mode
- Update Claude Code auto-config to use 'remote' command instead of npx
- Update all manual instruction templates to use remote server format
- Add Codex to the list of supported MCP clients
- Add getCodexConfigPath() for platform-specific config paths:
  * macOS: ~/Library/Application Support/Codex/mcp.json
  * Windows: ~/AppData/Roaming/Codex/mcp.json
  * Linux: ~/.config/Codex/mcp.json
- Add Codex detection via 'codex' binary or Codex.app
- Add Codex-specific manual configuration instructions
- Update supported clients list to include Codex with URL: https://codex.so
- Set CanAutomate to false (manual configuration only)
@Rodriguespn Rodriguespn self-assigned this Oct 29, 2025
- Fix import formatting with goimports
- Add error checking for fmt.Scanln calls
- Lowercase error messages (ST1005)
- Remove redundant newlines in fmt.Println
- Remove unused ctx parameter from configureJSONClient
- Add #nosec G204 comment for validated command execution
- Apply gofmt formatting to all files
@coveralls
Copy link

coveralls commented Oct 29, 2025

Pull Request Test Coverage Report for Build 19043045070

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 297 (0.0%) changed or added relevant lines in 8 files are covered.
  • 26 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-1.4%) to 53.318%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cmd/mcp.go 0 3 0.0%
cmd/mcp_init.go 0 8 0.0%
internal/mcp/init/utils.go 0 11 0.0%
internal/mcp/init/client.go 0 18 0.0%
internal/mcp/init/claude_code.go 0 28 0.0%
internal/mcp/init/init.go 0 59 0.0%
internal/mcp/init/cursor.go 0 84 0.0%
internal/mcp/init/vscode.go 0 86 0.0%
Files with Coverage Reduction New Missed Lines %
internal/utils/profile.go 2 81.82%
internal/gen/keys/keys.go 5 12.9%
internal/utils/flags/config_path.go 7 56.25%
internal/link/link.go 12 76.26%
Totals Coverage Status
Change from base Build 18900105989: -1.4%
Covered Lines: 6388
Relevant Lines: 11981

💛 - Coveralls

- Introduced Client interface for extensible MCP client support
- Implemented client registry pattern for easy addition of new clients
- Refactored Claude Code implementation to use new interface
- Added documentation for adding new clients
- Supports auto-detection of installed clients
- Currently supports Claude Code with foundation for more clients
- Implemented cursorClient with JSON config file approach
- Supports both project-local (.cursor/mcp.json) and global configs
- Adds Supabase MCP server URL to mcpServers configuration
- Merges with existing config if present
- Added appExists helper for macOS app detection
- Updated help text to mention Cursor support
- Created baseClient struct with common Client interface methods
- Refactored claudeCodeClient and cursorClient to embed baseClient
- Added constructor functions (newClaudeCodeClient, newCursorClient)
- Reduced code duplication by using composition pattern
- Updated example template to show new pattern
- Each client now only implements Configure() method
- Implemented vscodeClient with JSON config file approach
- Supports both project-local (.vscode/mcp.json) and global configs
- Adds Supabase MCP server with type: http and URL
- Merges with existing config if present
- Updated help text to mention VS Code support
- Checks for 'code' command availability
Reorganized MCP init package for better scalability and maintainability:

- client.go: Base Client interface and baseClient implementation
- claude_code.go: Claude Code client implementation
- cursor.go: Cursor client implementation
- vscode.go: VS Code client implementation
- utils.go: Helper functions (appExists)
- init.go: Core logic, client registry, and orchestration

Benefits:
- Each client is now in its own file for easy maintenance
- Adding new clients is simpler - just create a new file
- Reduced init.go from 425 to ~100 lines
- Better separation of concerns
- Easier to navigate and understand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants