Skip to content

Conversation

@Rodriguespn
Copy link

@Rodriguespn Rodriguespn commented Oct 29, 2025

What kind of change does this PR introduce?

Feature enhancement to supabase init command.

What is the current behavior?

supabase init initializes a local Supabase project but doesn't configure MCP (Model Context Protocol) clients.

What is the new behavior?

After running supabase init, users are now prompted to configure the Supabase MCP server for their preferred client through an interactive flow.

Expected User Interaction

When running supabase init, users will experience the following flow:

➜ supabase init
Generate VS Code settings for Deno? [y/N] n
Generate IntelliJ Settings for Deno? [y/N] n
Configure Supabase MCP server locally? [y/N] y

If user answers "yes", they see a dropdown menu:

Which client do you want to configure?
  • claude-code    (Claude Code)
  • cursor         (Cursor)
  • vscode         (VS Code)
  • other          (Configure it manually)

Navigation: Use arrow keys ↑/↓ to navigate, Enter to select

Option 1: Claude Code

If selected, automatically runs:

claude mcp add --transport http supabase http://localhost:54321/mcp

Option 2: Cursor

If selected, prompts for scope (also a dropdown):

Where would you like to add the configuration?
  • project    (Project-local (in .cursor/mcp.json))
  • global     (Global (in your home directory))

Creates/updates the selected config file with:

{
  "mcpServers": {
    "supabase": {
      "url": "http://localhost:54321/mcp"
    }
  }
}

Option 3: VS Code

If selected, prompts for scope (dropdown):

Where would you like to add the configuration?
  • project    (Project-local (in .vscode/mcp.json))
  • global     (Global (in your home directory))

Creates/updates the selected config file with:

{
  "servers": {
    "supabase": {
      "type": "http",
      "url": "http://localhost:54321/mcp"
    }
  }
}

Option 4: Other

If selected, skips automatic configuration. Users can configure manually later.

Final output:

Finished supabase init.

Related Issues

Implements requirements from Linear issue AI-81

@Rodriguespn Rodriguespn self-assigned this Oct 29, 2025
@coveralls
Copy link

coveralls commented Oct 29, 2025

Pull Request Test Coverage Report for Build 19194338182

Details

  • 0 of 355 (0.0%) changed or added relevant lines in 9 files are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-1.6%) to 53.056%

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%
cmd/init.go 0 18 0.0%
internal/mcp/init/client.go 0 18 0.0%
internal/mcp/init/claude_code.go 0 47 0.0%
internal/mcp/init/init.go 0 78 0.0%
internal/mcp/init/cursor.go 0 84 0.0%
internal/mcp/init/vscode.go 0 88 0.0%
Files with Coverage Reduction New Missed Lines %
internal/gen/keys/keys.go 5 12.9%
Totals Coverage Status
Change from base Build 19176861370: -1.6%
Covered Lines: 6388
Relevant Lines: 12040

💛 - Coveralls

@Rodriguespn Rodriguespn marked this pull request as ready for review November 4, 2025 17:01
@Rodriguespn Rodriguespn requested a review from a team as a code owner November 4, 2025 17:01
var (
mcpCmd = &cobra.Command{
GroupID: groupQuickStart,
Use: "mcp",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we plan to add other sub commands under supabase mcp? If not, I'd probably add new flags to supabase init instead.

We currently prompt users to create deno config when running supabase init which is logically similar to vscode config for mcp.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have plans to extend the mcp command to a dev env for building mcp servers
https://www.notion.so/supabase/Supabase-CLI-Integration-635fe64201f944c1a97856cf83c565c9?source=copy_link

The Notion page is still under construction so please disregard the exact commands stated but the general idea is there.

But since these plans are for developing mcp servers using Supabase and not to configure the SUpabase MCP server using our CLI, I agree that a flag to supabase init would suit this use case better.

Something like supabase init --mcp-client=claude-code?

@Rodriguespn
Copy link
Author

Addressed @sweatybridge's suggestion to move MCP configuration under supabase init:

  • Added a new flag: --mcp-client
  • Usage: supabase init --mcp-client=claude-code (also supports cursor, vscode)
  • This runs MCP setup after project scaffolding and configures the chosen client

Kept supabase mcp init for now to support interactive/targeted setup, but the flag should cover the review's intent. Happy to consolidate further if you'd prefer removing the mcp command entirely.

@Rodriguespn Rodriguespn force-pushed the feat/mcp-init-command branch from 997f4ca to 79948e4 Compare November 5, 2025 14:34
@Rodriguespn Rodriguespn marked this pull request as draft November 5, 2025 16:21
@Rodriguespn
Copy link
Author

Hey @sweatybridge, brainstormed about this with @gregnr and we've decided to go on a different direction. It's still under development but I'll change the Linear issue with the new approach to this once we have it.
Converting this PR into a draft one

@Rodriguespn Rodriguespn force-pushed the feat/mcp-init-command branch from 88cba49 to fd00eef Compare November 7, 2025 12:28
@Rodriguespn Rodriguespn marked this pull request as ready for review November 8, 2025 14:29
- 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)
- 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
- 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
- Adds --mcp-client flag to supabase init (e.g., --mcp-client=claude-code)
- Wires to internal MCP setup after project scaffolding
- Addresses review feedback to avoid a top-level mcp command for config
- Replace --mcp-client flag with interactive prompts
- Add yes/no prompt: 'Configure Supabase MCP server locally?'
- Add dropdown selection for client choice (Claude Code, Cursor, VS Code, Other)
- Add 'Other' option for manual configuration
- Update all clients to use local MCP server (http://localhost:54321/mcp)
- Fix VS Code config property from 'mcpServers' to 'servers'
- Replace VS Code scope selection with interactive dropdown (project/global)

This implements the requirements from Linear issue AI-81.
@Rodriguespn Rodriguespn force-pushed the feat/mcp-init-command branch from 7eafb42 to a898faa Compare November 8, 2025 14:29
@Rodriguespn
Copy link
Author

@sweatybridge ready for review. I've updated the description with the expected behavior

@gregnr gregnr changed the title feat(mcp): add supabase mcp init command to configure MCP clients feat(mcp): add supabase init command to configure MCP clients Nov 11, 2025
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.

4 participants