Skip to content

Commit 77efb92

Browse files
committed
fix: guide MCP authorization by host capabilities
1 parent adcd2b9 commit 77efb92

5 files changed

Lines changed: 120 additions & 54 deletions

File tree

‎plugins/screenrig/skills/screenrig/SKILL.md‎

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ The common signage path; each step has its section below.
3737

3838
## Choose where commands run
3939

40+
For a screens, playlists or media viewing request, start with
41+
[interactive cards](#interactive-cards-and-account-authorization). An authenticated
42+
MCP view does not require CLI setup, doctor or CLI reauthentication. The command
43+
preflight below applies when the task needs CLI operations.
44+
4045
Use the bundled CLI in the current permitted execution environment. Codex on
4146
desktop, ChatGPT Work, and a dot can each provide a CLI-capable environment;
4247
verify the actual runtime before operating. Do not assume the user's computer
@@ -136,14 +141,15 @@ switch from an email address, another tool's visible data, or a browser login.
136141

137142
## Interactive cards and account authorization
138143

139-
The plugin declares the hosted screenRIG MCP connection for supported Codex
140-
and Claude plugin hosts. The host discovers it from the package; do not ask
144+
The plugin declares the hosted screenRIG MCP connection for compatible plugin
145+
hosts. The host discovers it from the package; do not ask
141146
the user to enter a server URL, paste a token, or install a credential helper.
142147
The bundled connection targets production. An explicitly selected alternative
143148
environment needs a matching host connection; never silently mix environments.
144149

145-
1. Reuse the CLI's saved connection, or complete the first-run enrollment below.
146-
Continue using the CLI for pairing, transcoding, uploads and management.
150+
1. For onboarding or management, reuse the CLI's saved connection or follow
151+
first-run enrollment below. For a view-only request, use the authenticated
152+
MCP connection directly; do not run CLI diagnostics or enrollment as a gate.
147153
2. Treat "show my screens", "show my playlists" and "show my media" as requests
148154
for the interactive view. Discover the plugin's MCP tools before choosing a
149155
CLI command. Call the matching screen, playlist or media list/get tool through
@@ -152,21 +158,23 @@ environment needs a matching host connection; never silently mix environments.
152158
connect/sign-in action. The user signs in to screenRIG and approves access
153159
to the same project. Finish dashboard invitation acceptance or account
154160
verification if required; do not enroll a second project to fix MCP login.
155-
4. Confirm the returned project identity matches the CLI-selected project
156-
before combining results or making changes. A matching email or screen name
161+
4. When a CLI project has already been selected for this task, confirm the
162+
returned project identity matches it before combining results or making changes. A matching email or screen name
157163
alone is insufficient. If the user selected another project, resolve that
158164
selection explicitly rather than claiming the two connections are shared.
159165
5. Reuse the saved CLI configuration and the host's OAuth session in later
160166
conversations. The host manages its own token storage and refresh. CLI API
161167
tokens cannot authenticate MCP; never copy them into headers or the widget.
162168

163-
For Codex hosts with the `codex` executable, inspect `codex mcp list --json`
164-
and `codex mcp get NAME --json` to identify the matching registered endpoint.
165-
When it reports that login is needed, run the host's supported OAuth command:
166-
167-
```sh
168-
codex mcp login NAME --oauth-client-registration cimd --scopes access:manage,screens,content,playlists,reports
169-
```
169+
Discover the current host's connection-management and OAuth capabilities. Use
170+
its supported sign-in action or login command for the registered connection;
171+
check available tools or command help before claiming the user must start it.
172+
See [host authentication examples](references/installation.md#host-authentication-examples)
173+
when command discovery needs help. Do not assume a command installed on the
174+
machine manages the current host's connection or shares its credential store.
175+
If login needs a terminal, use a persistent interactive terminal/PTY and retain
176+
it while the user approves. Give manual sign-in instructions only when no
177+
supported agent-triggered path is available, using that host's actual controls.
170178

171179
The requested `access:manage` scope is required to capture a fresh screenshot:
172180
that sends a command to the Player. It also permits other writes within the
@@ -179,24 +187,24 @@ capture is requested, use the single native login flow below with the required
179187
scope and wait for approval. If the host retains the old grant, explain that its
180188
connection needs reauthorization; do not loop through login attempts.
181189

182-
Replace `NAME` with the discovered connection name. Start at most one login
183-
attempt and keep its process/session so you can wait for its result. This
184-
command opens the approval browser itself: do not also open its URL in another
185-
tab, run another login, or navigate plugin settings or the dashboard. Tell the
190+
Start at most one login attempt for the discovered connection and retain its
191+
process/session so you can wait for its result. If the host opens the approval
192+
browser, reuse that tab. Otherwise open the authorization URL it provides once.
193+
Do not start another login or navigate unrelated settings or dashboard pages. Tell the
186194
user to finish sign-in and approval in that one tab, then wait. Do not operate
187195
the consent form, alter its scopes, or inspect other signed-in browser sessions
188196
unless the user explicitly asks for that browser assistance. If browser opening
189197
fails, offer the existing login URL once; do not start another authorization.
190198

191-
After successful login, rediscover tools once. If this conversation still has
192-
only the old tools, stop and ask the user to start a fresh conversation. Do not
193-
retry OAuth, log out, replace another connection, or open settings tabs to force
194-
a tool refresh. A missing tool after login is not an authentication failure.
199+
After successful login, rediscover tools once. If still unavailable, use a
200+
documented native reconnect or tool reload once when supported, then retry
201+
discovery. Ask for a fresh conversation only if this host cannot reload or the
202+
bounded retry fails; do not claim every host loads connections only at startup.
203+
Do not retry OAuth, log out, replace another connection, or open settings tabs
204+
to force a tool refresh. A missing tool after login is not an authentication failure.
195205
Only retry login after a confirmed failure and explain that failure first.
196-
Do not request `identity` for this MCP connection. If the host has a native sign-in
197-
action instead, use it. In Claude Code, use its MCP authentication flow for the
198-
plugin-provided server. Do not claim a sign-in command succeeded before it
199-
finishes, and do not treat a CLI enrollment as MCP authorization.
206+
Do not request `identity` for this MCP connection. Do not claim sign-in succeeded
207+
before the host reports completion, or treat CLI enrollment as MCP authorization.
200208

201209
Use the host's discovered connection identifier. The packaged dependency is
202210
`screenrig-views`; another connection simply named `screenrig` may belong to a
@@ -212,7 +220,13 @@ request cannot render a native card. Continue authorized CLI work and provide
212220
text or screenshot results only after explaining why the interactive view
213221
could not be opened and what user action, if any, is needed. Do not silently
214222
skip discovery or OAuth and substitute a Markdown table for this request.
215-
Do not promise card rendering on hosts that only expose MCP text tools.
223+
A successful tool response proves data access, not visual rendering. Do not say
224+
"the card is above" or "if supported it appeared" without host rendering evidence.
225+
When only text is exposed, say the data loaded but card rendering is unverified;
226+
use any available host UI/error evidence to distinguish a renderer limitation
227+
from a resource failure. Do not repeat login or CLI setup to fix rendering.
228+
Keep the response brief and omit internal IDs unless resolving an account
229+
mismatch. Do not promise card rendering on hosts that only expose MCP text tools.
216230

217231
## First run: enroll a new project
218232

‎plugins/screenrig/skills/screenrig/references/installation.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,22 @@ add and install commands above. Grok install must keep `--trust`. Refresh
151151
updates skill text and the bundled CLI together. After refresh, re-resolve
152152
the plugin root, prepend scripts to PATH, and require a successful
153153
`screenrig version` envelope before any other command.
154+
155+
## Host authentication examples
156+
157+
The shared skill uses capability discovery. These examples apply only when the
158+
executable manages the current host's registered MCP connection; verify installed
159+
command help first. Other hosts can expose equivalent native sign-in tools.
160+
Never install a different host CLI just to authenticate the current host.
161+
162+
- Codex: inspect `codex mcp list --json` and `codex mcp get NAME --json`.
163+
When supported, initiate `codex mcp login NAME --oauth-client-registration cimd --scopes access:manage,screens,content,playlists,reports`.
164+
- Claude Code: check `claude mcp login --help`, then use
165+
`claude mcp login NAME` in a persistent interactive terminal. The plugin server
166+
is commonly `plugin:screenrig:screenrig-views`; use its discovered name.
167+
The interactive `/mcp` sign-in panel is a fallback when agent-triggered login
168+
is unavailable. Do not assume Desktop or Cowork uses the same controls/store.
169+
170+
Keep one authorization attempt alive until it completes. The person signs in
171+
and approves; the host stores and refreshes its own OAuth session. Follow the
172+
shared skill's bounded rediscovery/reconnect flow after successful consent.

‎scripts/test.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,8 @@ def test_remote_oauth_declarations_and_retired_helper(self):
814814
self.assertNotIn("identity", scopes)
815815
self.assertEqual(set(server), {"type", "url", "scopes" if host == "codex" else "oauth"})
816816
for skill_root in (ROOT, ROOT / "plugins/screenrig"):
817-
skill = (skill_root / "skills/screenrig/SKILL.md").read_text()
818-
login_scopes = re.search(r'--scopes ([^\s`]+)', skill).group(1).split(',')
817+
installation = (skill_root / "skills/screenrig/references/installation.md").read_text()
818+
login_scopes = re.search(r'--scopes ([^\s`]+)', installation).group(1).split(',')
819819
self.assertEqual(login_scopes, scopes,
820820
"Manual OAuth login must retain screenshot capture permission")
821821
for root in (ROOT, ROOT / "plugins/screenrig"):

‎skills/screenrig/SKILL.md‎

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ The common signage path; each step has its section below.
3737

3838
## Choose where commands run
3939

40+
For a screens, playlists or media viewing request, start with
41+
[interactive cards](#interactive-cards-and-account-authorization). An authenticated
42+
MCP view does not require CLI setup, doctor or CLI reauthentication. The command
43+
preflight below applies when the task needs CLI operations.
44+
4045
Use the bundled CLI in the current permitted execution environment. Codex on
4146
desktop, ChatGPT Work, and a dot can each provide a CLI-capable environment;
4247
verify the actual runtime before operating. Do not assume the user's computer
@@ -136,14 +141,15 @@ switch from an email address, another tool's visible data, or a browser login.
136141

137142
## Interactive cards and account authorization
138143

139-
The plugin declares the hosted screenRIG MCP connection for supported Codex
140-
and Claude plugin hosts. The host discovers it from the package; do not ask
144+
The plugin declares the hosted screenRIG MCP connection for compatible plugin
145+
hosts. The host discovers it from the package; do not ask
141146
the user to enter a server URL, paste a token, or install a credential helper.
142147
The bundled connection targets production. An explicitly selected alternative
143148
environment needs a matching host connection; never silently mix environments.
144149

145-
1. Reuse the CLI's saved connection, or complete the first-run enrollment below.
146-
Continue using the CLI for pairing, transcoding, uploads and management.
150+
1. For onboarding or management, reuse the CLI's saved connection or follow
151+
first-run enrollment below. For a view-only request, use the authenticated
152+
MCP connection directly; do not run CLI diagnostics or enrollment as a gate.
147153
2. Treat "show my screens", "show my playlists" and "show my media" as requests
148154
for the interactive view. Discover the plugin's MCP tools before choosing a
149155
CLI command. Call the matching screen, playlist or media list/get tool through
@@ -152,21 +158,23 @@ environment needs a matching host connection; never silently mix environments.
152158
connect/sign-in action. The user signs in to screenRIG and approves access
153159
to the same project. Finish dashboard invitation acceptance or account
154160
verification if required; do not enroll a second project to fix MCP login.
155-
4. Confirm the returned project identity matches the CLI-selected project
156-
before combining results or making changes. A matching email or screen name
161+
4. When a CLI project has already been selected for this task, confirm the
162+
returned project identity matches it before combining results or making changes. A matching email or screen name
157163
alone is insufficient. If the user selected another project, resolve that
158164
selection explicitly rather than claiming the two connections are shared.
159165
5. Reuse the saved CLI configuration and the host's OAuth session in later
160166
conversations. The host manages its own token storage and refresh. CLI API
161167
tokens cannot authenticate MCP; never copy them into headers or the widget.
162168

163-
For Codex hosts with the `codex` executable, inspect `codex mcp list --json`
164-
and `codex mcp get NAME --json` to identify the matching registered endpoint.
165-
When it reports that login is needed, run the host's supported OAuth command:
166-
167-
```sh
168-
codex mcp login NAME --oauth-client-registration cimd --scopes access:manage,screens,content,playlists,reports
169-
```
169+
Discover the current host's connection-management and OAuth capabilities. Use
170+
its supported sign-in action or login command for the registered connection;
171+
check available tools or command help before claiming the user must start it.
172+
See [host authentication examples](references/installation.md#host-authentication-examples)
173+
when command discovery needs help. Do not assume a command installed on the
174+
machine manages the current host's connection or shares its credential store.
175+
If login needs a terminal, use a persistent interactive terminal/PTY and retain
176+
it while the user approves. Give manual sign-in instructions only when no
177+
supported agent-triggered path is available, using that host's actual controls.
170178

171179
The requested `access:manage` scope is required to capture a fresh screenshot:
172180
that sends a command to the Player. It also permits other writes within the
@@ -179,24 +187,24 @@ capture is requested, use the single native login flow below with the required
179187
scope and wait for approval. If the host retains the old grant, explain that its
180188
connection needs reauthorization; do not loop through login attempts.
181189

182-
Replace `NAME` with the discovered connection name. Start at most one login
183-
attempt and keep its process/session so you can wait for its result. This
184-
command opens the approval browser itself: do not also open its URL in another
185-
tab, run another login, or navigate plugin settings or the dashboard. Tell the
190+
Start at most one login attempt for the discovered connection and retain its
191+
process/session so you can wait for its result. If the host opens the approval
192+
browser, reuse that tab. Otherwise open the authorization URL it provides once.
193+
Do not start another login or navigate unrelated settings or dashboard pages. Tell the
186194
user to finish sign-in and approval in that one tab, then wait. Do not operate
187195
the consent form, alter its scopes, or inspect other signed-in browser sessions
188196
unless the user explicitly asks for that browser assistance. If browser opening
189197
fails, offer the existing login URL once; do not start another authorization.
190198

191-
After successful login, rediscover tools once. If this conversation still has
192-
only the old tools, stop and ask the user to start a fresh conversation. Do not
193-
retry OAuth, log out, replace another connection, or open settings tabs to force
194-
a tool refresh. A missing tool after login is not an authentication failure.
199+
After successful login, rediscover tools once. If still unavailable, use a
200+
documented native reconnect or tool reload once when supported, then retry
201+
discovery. Ask for a fresh conversation only if this host cannot reload or the
202+
bounded retry fails; do not claim every host loads connections only at startup.
203+
Do not retry OAuth, log out, replace another connection, or open settings tabs
204+
to force a tool refresh. A missing tool after login is not an authentication failure.
195205
Only retry login after a confirmed failure and explain that failure first.
196-
Do not request `identity` for this MCP connection. If the host has a native sign-in
197-
action instead, use it. In Claude Code, use its MCP authentication flow for the
198-
plugin-provided server. Do not claim a sign-in command succeeded before it
199-
finishes, and do not treat a CLI enrollment as MCP authorization.
206+
Do not request `identity` for this MCP connection. Do not claim sign-in succeeded
207+
before the host reports completion, or treat CLI enrollment as MCP authorization.
200208

201209
Use the host's discovered connection identifier. The packaged dependency is
202210
`screenrig-views`; another connection simply named `screenrig` may belong to a
@@ -212,7 +220,13 @@ request cannot render a native card. Continue authorized CLI work and provide
212220
text or screenshot results only after explaining why the interactive view
213221
could not be opened and what user action, if any, is needed. Do not silently
214222
skip discovery or OAuth and substitute a Markdown table for this request.
215-
Do not promise card rendering on hosts that only expose MCP text tools.
223+
A successful tool response proves data access, not visual rendering. Do not say
224+
"the card is above" or "if supported it appeared" without host rendering evidence.
225+
When only text is exposed, say the data loaded but card rendering is unverified;
226+
use any available host UI/error evidence to distinguish a renderer limitation
227+
from a resource failure. Do not repeat login or CLI setup to fix rendering.
228+
Keep the response brief and omit internal IDs unless resolving an account
229+
mismatch. Do not promise card rendering on hosts that only expose MCP text tools.
216230

217231
## First run: enroll a new project
218232

‎skills/screenrig/references/installation.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,22 @@ add and install commands above. Grok install must keep `--trust`. Refresh
151151
updates skill text and the bundled CLI together. After refresh, re-resolve
152152
the plugin root, prepend scripts to PATH, and require a successful
153153
`screenrig version` envelope before any other command.
154+
155+
## Host authentication examples
156+
157+
The shared skill uses capability discovery. These examples apply only when the
158+
executable manages the current host's registered MCP connection; verify installed
159+
command help first. Other hosts can expose equivalent native sign-in tools.
160+
Never install a different host CLI just to authenticate the current host.
161+
162+
- Codex: inspect `codex mcp list --json` and `codex mcp get NAME --json`.
163+
When supported, initiate `codex mcp login NAME --oauth-client-registration cimd --scopes access:manage,screens,content,playlists,reports`.
164+
- Claude Code: check `claude mcp login --help`, then use
165+
`claude mcp login NAME` in a persistent interactive terminal. The plugin server
166+
is commonly `plugin:screenrig:screenrig-views`; use its discovered name.
167+
The interactive `/mcp` sign-in panel is a fallback when agent-triggered login
168+
is unavailable. Do not assume Desktop or Cowork uses the same controls/store.
169+
170+
Keep one authorization attempt alive until it completes. The person signs in
171+
and approves; the host stores and refreshes its own OAuth session. Follow the
172+
shared skill's bounded rediscovery/reconnect flow after successful consent.

0 commit comments

Comments
 (0)