opencode-supabase 0.3.0 → 0.3.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,25 +32,21 @@ No separate `skills` CLI setup is required. Installing the plugin makes these sk
32
32
 
33
33
  ## Supabase MCP Onboarding
34
34
 
35
- Ask your agent:
35
+ After connecting Supabase, start by asking OpenCode to list projects:
36
36
 
37
37
  ```text
38
- Set up Supabase MCP for my project
38
+ List my Supabase projects
39
39
  ```
40
40
 
41
- The agent can explain Supabase MCP, help you choose the target project, and open the Supabase Studio Connect Sheet with the MCP tab and OpenCode client selected.
41
+ Pick the project you want to work with, then ask OpenCode to connect Supabase MCP for that project. OpenCode opens Supabase Studio so you can choose MCP permissions and copy the generated OpenCode config.
42
42
 
43
- Studio remains the source of truth for MCP feature groups, permissions, generated OpenCode config, and auth steps. If you want help applying the Studio output to this repository, paste the Studio prompt or OpenCode config snippet back into OpenCode.
44
-
45
- You can skip any Studio instruction to install Supabase Agent Skills separately. This plugin already bundles Supabase skills.
46
-
47
- After changing OpenCode MCP config, restart OpenCode. If OAuth is not prompted automatically, run:
43
+ After config is added, restart OpenCode and authenticate the MCP server:
48
44
 
49
45
  ```bash
50
46
  opencode mcp auth supabase
51
47
  ```
52
48
 
53
- This plugin opens the MCP setup page and guides the workflow. It does not automatically edit MCP config or choose read-only/feature-group settings for you.
49
+ Complete OAuth in the browser. Skip any `install Supabase Agent Skills` step in Studio; this plugin already bundles the Supabase skills.
54
50
 
55
51
  ### Disable Bundled Skills
56
52
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-supabase",
3
- "version": "0.3.0",
3
+ "version": "0.3.1-alpha.1",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin for Supabase integration with server and TUI components",
6
6
  "license": "Apache-2.0",
@@ -49,4 +49,4 @@
49
49
  "solid-js": "1.9.11",
50
50
  "typescript": "^5"
51
51
  }
52
- }
52
+ }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: opencode-supabase-guide
3
- description: Use when users ask to set up Supabase MCP in OpenCode, paste Supabase Studio MCP config, or need MCP tools connected.
3
+ description: Use when users ask to set up Supabase MCP in OpenCode, connect project to MCP, connect a project to MCP, connect MCP, conenct MCP, connect MCP server, connect Supabase MCP, paste Supabase Studio MCP config, or need MCP tools connected.
4
4
  ---
5
5
 
6
6
  # OpenCode Supabase Guide
@@ -9,31 +9,200 @@ description: Use when users ask to set up Supabase MCP in OpenCode, paste Supaba
9
9
 
10
10
  Every interactive choice MUST use `question` tool. Never assume, never auto-pick. This includes:
11
11
 
12
- - Selecting a project when multiple exist list options with name + ref in the question.
13
- - Confirming before opening browser include project name + ref in the question.
12
+ - Selecting a project when multiple exist -- list options with name + ref in the question.
13
+ - Confirming before opening browser -- include project name + ref in the question.
14
14
  - Choosing whether to apply Studio config to the repo.
15
15
  - Any yes/no or selection prompt.
16
16
 
17
- No prose "ask" always `question` tool invocation.
17
+ No prose "ask" -- always `question` tool invocation.
18
+
19
+ Question tool rules:
20
+
21
+ - Do not add `Other`, `Something else`, `Type your own answer`, or catch-all options.
22
+ - OpenCode adds `Type your own answer` automatically.
23
+ - Put the recommended option first and include `(Recommended)` in the label.
24
+ - Keep labels short and put explanatory text in `description`.
18
25
 
19
26
  ## Overview
20
27
 
21
- Supabase MCP adds project-scoped Supabase tools to OpenCode. Before MCP setup, tell user to run `/supabase` to connect their account — plugin tools (list projects, create project) need OAuth. MCP config comes from Studio prompt, not rebuilt from code.
28
+ List projects first. Do not lead with MCP setup immediately after `/supabase` auth.
29
+
30
+ Supabase MCP adds project-scoped Supabase tools to OpenCode. Before MCP setup, tell user to run `/supabase` to connect their account -- plugin tools (list projects, create project) need OAuth. MCP config comes from Studio prompt, not rebuilt from code.
22
31
 
23
32
  ## MCP Setup Flow
24
33
 
25
- 1. Resolve project with `supabase_list_projects`. If auth fails, tell user: "Run `/supabase` to connect your Supabase account." If multiple projects, use `question` tool listing name + ref for each.
26
- 2. Use `question` tool to confirm: "Open Supabase MCP Connect for `<name>` (`<ref>`)?"
27
- 3. Call `supabase_open_mcp_setup`. Always print returned URL in output.
28
- 4. Tell user to paste Studio prompt/config back for wiring into `.opencode/opencode.json`.
34
+ 1. If user has not chosen a project, call `supabase_list_projects`.
35
+ 2. If multiple projects exist, use the Question tool to choose one.
36
+ 3. After a project is selected, offer to connect that project to Supabase MCP.
37
+ 4. If user confirms, call `supabase_open_mcp_setup`.
38
+ 5. Tell user to paste the Studio prompt or OpenCode config snippet back here.
39
+ 6. After config is added, tell user to close OpenCode or exit the current session, run `opencode mcp auth supabase`, complete OAuth in the browser, then start OpenCode again.
40
+
41
+ User phrases that MUST trigger this flow include: `connect project to MCP`, `connect a project to MCP`, `connect MCP`, `conenct MCP`, `connect MCP server`, `connect Supabase MCP`, and `connect to Supabase MCP`.
42
+
43
+ Never list projects as bullets and ask the user to reply in prose. Use this Question tool shape for project selection:
44
+
45
+ ```json
46
+ {
47
+ "questions": [
48
+ {
49
+ "header": "Choose Project",
50
+ "question": "Which project do you want to connect to Supabase MCP?",
51
+ "multiple": false,
52
+ "options": [
53
+ {
54
+ "label": "opencode-tester",
55
+ "description": "Project ref: abcdefghijklmnopqrst"
56
+ },
57
+ {
58
+ "label": "analytics-prod",
59
+ "description": "Project ref: zyxwvutsrqponmlkjihg"
60
+ }
61
+ ]
62
+ }
63
+ ]
64
+ }
65
+ ```
66
+
67
+ Use this Question tool shape before opening Studio:
68
+
69
+ ```json
70
+ {
71
+ "questions": [
72
+ {
73
+ "header": "Connect Supabase",
74
+ "question": "Connect opencode-tester to Supabase MCP?",
75
+ "multiple": false,
76
+ "options": [
77
+ {
78
+ "label": "Open browser (Recommended)",
79
+ "description": "Open Supabase Studio to choose permissions and copy config"
80
+ },
81
+ {
82
+ "label": "Skip setup",
83
+ "description": "Do not connect Supabase MCP now"
84
+ }
85
+ ]
86
+ }
87
+ ]
88
+ }
89
+ ```
90
+
91
+ Replace `opencode-tester` with the selected project name.
92
+
93
+ ## Required Phrases
94
+
95
+ Use explicit wording. Do not improvise around auth/setup state.
96
+
97
+ After `/supabase` auth succeeds:
98
+
99
+ Say this:
100
+
101
+ ```text
102
+ Ask me to list your Supabase projects first.
103
+ Then pick a project and ask me to connect it to MCP.
104
+ ```
105
+
106
+ Do not say:
107
+
108
+ ```text
109
+ Set up Supabase MCP for my project.
110
+ ```
111
+
112
+ After project selection:
113
+
114
+ Say this:
115
+
116
+ ```text
117
+ Connect this project to Supabase MCP?
118
+ ```
119
+
120
+ Do not say:
121
+
122
+ ```text
123
+ I will set up MCP now.
124
+ ```
125
+
126
+ After Studio config is pasted or applied:
127
+
128
+ OAuth is a required separate step. The current OpenCode TUI session cannot reload the MCP config. Close OpenCode or exit the current session, then `opencode mcp auth supabase` starts browser OAuth for that MCP server. Start OpenCode again after OAuth completes.
129
+
130
+ Say this:
131
+
132
+ ```text
133
+ Close OpenCode or exit the current session, then run `opencode mcp auth supabase`.
134
+ Complete OAuth in the browser.
135
+ Start OpenCode again after OAuth completes.
136
+ ```
137
+
138
+ Do not say:
139
+
140
+ ```text
141
+ OAuth starts by itself after restart.
142
+ Run auth only if MCP fails.
143
+ ```
144
+
145
+ Never tell the user to wait for automatic OAuth. Always tell them to close OpenCode or exit the current session, run `opencode mcp auth supabase`, complete OAuth in the browser, and start OpenCode again after OAuth completes.
146
+
147
+ If config already exists:
148
+
149
+ Say this:
150
+
151
+ ```text
152
+ Supabase MCP config already exists for this workspace. No file changes needed.
153
+ Close OpenCode or exit the current session, then run `opencode mcp auth supabase`.
154
+ Complete OAuth in the browser.
155
+ Start OpenCode again after OAuth completes.
156
+ ```
157
+
158
+ Do not say:
159
+
160
+ ```text
161
+ Config already wired.
162
+ ```
163
+
164
+ If user says MCP works after only restarting:
165
+
166
+ Say this:
167
+
168
+ ```text
169
+ MCP auth may already be cached from an earlier setup.
170
+ Restarting loaded the config; cached auth let the MCP server work without a new browser auth step.
171
+ ```
172
+
173
+ ## OpenCode Auth
174
+
175
+ OpenCode does not automatically start OAuth after config is added. OAuth is a required separate step. After adding MCP config, tell the user:
176
+
177
+ ```text
178
+ Close OpenCode or exit the current session, then run:
179
+ opencode mcp auth supabase
180
+
181
+ Complete OAuth in the browser.
182
+ Start OpenCode again after OAuth completes.
183
+ ```
29
184
 
30
185
  ## Studio Prompt Handling
31
186
 
32
- Extract MCP JSON from Studio prompt. Strip line numbers (`1{`). Preserve URLs exactly never rebuild from `project_ref`. MCP server key usually `supabase`; auth: `opencode mcp auth supabase`. Skip `npx skills add supabase/agent-skills` already bundled.
187
+ Extract MCP JSON from Studio prompt. Strip line numbers (`1{`). Preserve URLs exactly -- never rebuild from `project_ref`. MCP server key usually `supabase`; auth: `opencode mcp auth supabase`. Skip `npx skills add supabase/agent-skills` -- already bundled.
33
188
 
34
189
  ## Config Rules
35
190
 
36
- Prefer `.opencode/opencode.json` (or `.opencode/opencode.jsonc`). Global (`~/.config/opencode/opencode.json`) only on explicit request. Use `question` tool before editing. Remind to restart OpenCode.
191
+ Prefer `.opencode/opencode.json` (or `.opencode/opencode.jsonc`). Global (`~/.config/opencode/opencode.json`) only on explicit request. Use `question` tool before editing. Remind to close OpenCode or exit the current session before auth, then start OpenCode again after OAuth completes.
192
+
193
+ If the Studio config is already present in `.opencode/opencode.json` or `.opencode/opencode.jsonc`, say:
194
+
195
+ ```text
196
+ Supabase MCP config already exists for this workspace. No file changes needed.
197
+
198
+ Close OpenCode or exit the current session, then run:
199
+ opencode mcp auth supabase
200
+
201
+ Complete OAuth in the browser.
202
+ Start OpenCode again after OAuth completes.
203
+ ```
204
+
205
+ Do not say `already wired` without explaining the restart and auth steps.
37
206
 
38
207
  ## Common Mistakes
39
208
 
@@ -46,7 +215,8 @@ Prefer `.opencode/opencode.json` (or `.opencode/opencode.jsonc`). Global (`~/.co
46
215
  | Choosing MCP features for user | Studio decides read-only, feature groups |
47
216
  | Calling MCP setup while unauthenticated | Tell user to run `/supabase` first |
48
217
  | Asking user without `question` tool | Always use `question` tool for confirmations, project selection, any interactive choice |
218
+ | Saying OAuth happens automatically | OAuth is a required separate step: close OpenCode or exit the current session, run `opencode mcp auth supabase`, complete browser OAuth, start OpenCode again |
49
219
 
50
220
  ## Troubleshooting
51
221
 
52
- MCP tools missing after config? Restart OpenCode, run `opencode mcp auth supabase`.
222
+ MCP tools missing after config? Say: `Close OpenCode or exit the current session, run opencode mcp auth supabase, complete OAuth, then start OpenCode again.`
@@ -103,6 +103,8 @@ export const HTML_SUCCESS = `<!doctype html>
103
103
  <p>You can <strong>close this window</strong> and return to OpenCode.</p>
104
104
  <div class="prompt-label">Try this next:</div>
105
105
  <div class="prompt-box">list my Supabase projects</div>
106
+ <div class="prompt-label">Then try:</div>
107
+ <div class="prompt-box">connect a project to MCP</div>
106
108
  <div class="footer">Having troubles or found a bug?<br><a href="${REPO_URL}" target="_blank" rel="noopener">Report it on GitHub</a></div>
107
109
  </div>
108
110
  <script>setTimeout(function(){window.close()},2000)</script>
@@ -431,18 +431,25 @@ function createMcpSetupUrl(projectRef: string) {
431
431
  return url.toString();
432
432
  }
433
433
 
434
- function formatMcpSetupResult(projectRef: string, url: string) {
435
- return `Opened Supabase MCP setup for project ${projectRef} in Studio.
436
-
437
- URL: ${url}
438
-
439
- On the Connect page:
440
- 1. Confirm MCP tab and OpenCode client are selected.
441
- 2. Choose the feature groups and permissions you want in Studio.
442
- 3. Follow the OpenCode config and auth steps shown by Studio.
443
- 4. If you want me to wire this into the current repo, paste the Studio prompt or OpenCode config snippet back here.
444
- 5. You can skip any "install Supabase Agent Skills" step because this plugin already bundles them.
445
- 6. Restart OpenCode after changing config; run \`opencode mcp auth supabase\` if OAuth is not prompted automatically.`;
434
+ function formatMcpSetupResult(url: string) {
435
+ return [
436
+ "MCP Connect page is open:",
437
+ url,
438
+ "",
439
+ "Grab config from Supabase Studio:",
440
+ "1. In Connect -> MCP -> OpenCode, choose permissions.",
441
+ "2. Copy the generated config under Configure MCP.",
442
+ "3. Paste the Studio prompt or config snippet back here.",
443
+ "",
444
+ "Skip any install Supabase Agent Skills step; this plugin already bundles them.",
445
+ "",
446
+ "After adding config:",
447
+ "1. Close OpenCode or exit the current session.",
448
+ "2. Run:",
449
+ "opencode mcp auth supabase",
450
+ "3. Complete OAuth in the browser.",
451
+ "4. Start OpenCode again.",
452
+ ].join("\n")
446
453
  }
447
454
 
448
455
  export function createSupabaseTools(
@@ -551,7 +558,7 @@ export function createSupabaseTools(
551
558
  }),
552
559
  supabase_open_mcp_setup: tool({
553
560
  description:
554
- "Open Supabase Studio MCP Connect page for a project after the user confirms the project. Use when the user asks to set up, connect, configure, or use Supabase MCP in OpenCode. Before calling, explain MCP briefly and ask: Open Supabase MCP Connect page for <project name> (<project-ref>)?",
561
+ "Open Supabase Studio MCP Connect page for a project after the user confirms the project. Use when the user asks to set up, connect, configure, or use Supabase MCP in OpenCode. Before calling, briefly explain that MCP adds project-scoped database, docs, advisor, and management tools. Ask a Question tool confirmation with an Open browser recommended option and a Skip setup option.",
555
562
  args: {
556
563
  project_ref: tool.schema.string().describe("Supabase project reference ID"),
557
564
  },
@@ -566,7 +573,7 @@ export function createSupabaseTools(
566
573
  messageID: _context.messageID,
567
574
  agent: _context.agent,
568
575
  });
569
- return formatMcpSetupResult(args.project_ref, url);
576
+ return formatMcpSetupResult(url);
570
577
  },
571
578
  }),
572
579
  supabase_login: tool({
@@ -22,16 +22,16 @@ type SupabaseDialogProps = {
22
22
 
23
23
  const ONBOARDING_MESSAGE = `Supabase is connected.
24
24
 
25
- Now unlock project-scoped tools with Supabase MCP ask me to set it up to get database inspection, docs, advisors, and more for your project in OpenCode.
25
+ Start by listing your Supabase projects, then connect project-scoped MCP tools for database inspection, docs, advisors, and more in OpenCode.
26
26
 
27
27
  You can also ask about:
28
- - your organizations and projects
29
- - API keys for a project
30
- - available database regions
28
+ - organizations and projects
29
+ - API keys
30
+ - regions
31
31
  - creating a new project
32
32
 
33
33
  Try this:
34
- Set up Supabase MCP for my project`;
34
+ List my Supabase projects`;
35
35
 
36
36
  const onboardedSessionIDsByApi = new WeakMap<TuiPluginApi, Set<string>>();
37
37
 
@@ -679,7 +679,8 @@ export function SupabaseDialog(props: SupabaseDialogProps) {
679
679
 
680
680
  return props.api.ui.DialogAlert({
681
681
  title: "Connected to Supabase",
682
- message: "Your account is ready. Close this dialog and ask me to list your Supabase projects.",
682
+ message:
683
+ "Your account is ready. Close this dialog, ask me to list your Supabase projects, then ask me to connect one to MCP.",
683
684
  onConfirm: closeDialog,
684
685
  });
685
686
  }