Skip to content

Shared config with the MCP server, scopes for 3.5.2, logout revokes - #8

Merged
amenophis1er merged 5 commits into
mainfrom
feat/shared-config-and-scopes
Sep 27, 2026
Merged

amenophis1er merged 5 commits into
mainfrom
feat/shared-config-and-scopes

Conversation

@amenophis1er

Copy link
Copy Markdown
Contributor

Goes with Trokky 3.5.2 (Trokky/trokky#62, on npm). Released as v0.3.0.

Shared config with the Trokky MCP server

  • ~/.trokky/config.yaml is shared with @trokky/mcp, so a site signed in with either tool works in both.
  • Both tools follow one protocol to change it:
    • an exclusive lock file with an owner id;
    • a stale-lock takeover that puts a live lock back if it took one by mistake;
    • an fsync, then an atomic rename;
    • unknown keys kept as they are.
  • Instances record the clientId they signed in with.
  • Signing in never replaces another site. The default moves only when exactly one site remains. The browser is opened without a shell, for http(s) links only.

Scopes

  • Requests content:publish and media:delete, which 3.5.2 enforces for restore and clean.

Logout and sign-in

  • trokky logout revokes the sign-in on the instance (RFC 7009), so it disappears from the Studio's Connected applications. An instance that can't be reached, or refuses, is still logged out locally, with a note saying which happened.
  • A 401 on a browser sign-in suggests trokky login: the sign-in may have been revoked in Studio, or predate the upgrade.
  • Sign-in requests send trokky-cli/<version> (OS; host), which Studio shows under Connected applications. Every other request sends only trokky-cli/<version>.

Upgrading

Run trokky login again for each browser-signed-in instance once its server is on 3.5.2. Tokens issued before 3.5.2 carry no grant and are refused.

Verification

  • go vet and go test ./... pass. Every test package pins HOME to a temp dir, so tests never touch the real config.
  • Reviewed with mutation-tested assertions.

…request publish and media delete

- config writes are atomic (temp file, fsync, rename with retry) and go through a lock file
  with owner ids and stale-lock takeover, the protocol the MCP server follows too
- invalid YAML is an error, never an empty config that the next save would write over
- unknown keys are preserved; instances record the OAuth2 client their token belongs to
- token refresh runs under the lock against the stored instance, reuses a token another
  process renewed, and never falls back to an expired token
- DefaultScopes adds content:publish and media:delete (restore, clean)
- clean and restore --clean stop instead of looping when media cannot be deleted; backup
  fails instead of writing an archive without media (#7)
- every test package runs against a throwaway HOME
…us; safer browser open

- login refuses a name already used by a different instance
- removing the default instance makes the remaining one default only if it is the only one
- instance names include the port and skip www, matching the Trokky MCP server
- OpenBrowser opens only http(s) URLs
- lock waiters outlast the stale threshold (75s)
RFC 7009 revoke with the refresh token (or access token), 10s timeout; the note
tells an unreachable instance from a refusal. A 401 on a browser sign-in hints
to run trokky login.
Device-flow requests send trokky-cli/<version> (macOS; host), recorded with the
grant for Studio's Connected applications; other requests send trokky-cli/<version>.
Device-flow requests send trokky-cli/<version> (OS; host); every other request
sends trokky-cli/<version>, keeping the machine name out of proxy logs. The host
is reduced to printable ASCII without comment syntax.
@amenophis1er
amenophis1er merged commit b1e853a into main Sep 27, 2026
1 check passed
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.

1 participant