IvanMurzak / IvanMurzak/Unity-MCP
feat(connection): RFC 8628 device flow + machine credential store + zero-button boot
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.3k
- Forks
- 379
- Avg merge
- 6h 52m
- Merged PRs (30d)
- 17
Description
Summary
Wire the real ai-game.dev sign-in for the Unity Editor plugin (mcp-authorize d1, PR 2 of the chain). Foundation PR #875 already adopted McpPlugin 7.0.0-preview.1 (vendored) and migrated UnityConnectionConfig.Token → CredentialProvider (behavior-preserving). This PR implements the RFC 8628 device-authorization grant against the live authorization server, persists the credential into the shared per-machine credential store, and connects signed-in on boot with zero UI interaction.
Context
- Design refs:
.claude/design/mcp-authorize/{03-auth-flows.md (Flow B), 06-engine-plugins.md, 09-user-workflows.md}; tasktasks/d1-unity-plugin.md. - The Authorization Server is live at
https://ai-game.dev(issuer). - McpPlugin 7.0 already ships
MachineCredentialStore+MachineCredentials+PluginCredentialProvider(auto-adopt, proactive/reactive refresh via an injectedITokenRefresher) +ConnectionCredentialCoordinator(on-401 refresh→reconnect); this PR provides the Unity device-flow + refresher and wires the provider into the Cloud-mode connection. - Mirrors the sibling engine device-flow PRs (Godot #265 / Unreal #212).
Proposed approach
DeviceAuthService: RFC 8628 alias —POST /oauth/device_authorization(formclient_id=unity-mcp-plugin+scope=mcp:plugin) → pollPOST /oauth/tokenwith theurn:ietf:params:oauth:grant-type:device_codegrant → ES256 access JWT + rotating refresh token.
-
DeviceAuthFlow: injectable state machine (client / browser-open / poll-delay injectable) so it runs against a mocked AS with no live network in CI; honoursinterval/slow_down/authorization_pending/access_denied/expired_token.
-
UnityTokenRefresher(ITokenRefresher): exchanges the refresh token for a fresh access token at/oauth/token; fails closed.
-
AccountCredentialService: owns aPluginCredentialProviderover the shared machine store (~/.ai-game-dev/credentials.json, 0600 / DPAPI); auto-adopt on boot, proactive refresh at connect, on-401 refresh+reconnect viaConnectionCredentialCoordinator.
-
- Wire the Cloud credential provider into
UnityConnectionConfig.CredentialProvider(machine-store JWT wins in Cloud mode; falls back to the mode-routed token; ignored in Custom/Local).
- Wire the Cloud credential provider into
Acceptance criteria
- Zero-button: a seeded machine store → editor boots connected in Cloud mode with no UI interaction.
- Device-flow / store / refresher / provider unit tests pass against a mocked authorization server (no live network in CI).
- Unity plugin compiles; full EditMode suite green on the local worktree Editor.
- Unity CI matrix green.
Scope note: instance-metadata handshake / ProjectIdentity marker (PR 3), port change (PR 4), config-writer UI flip / token-field removal (PR 5), and live e2e (PR 6) are out of scope for this PR.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with tasks/d1-unity-plugin.md and the referenced Flow B design, then inspect UnityConnectionConfig.CredentialProvider and the sibling Godot and Unreal device-flow changes. Run the mocked authorization-server unit tests and the Unity EditMode suite. Done means the seeded machine store enables zero-button Cloud startup, device flow and refresh behavior pass without live network access, and the Unity CI matrix is green.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, unity
- Domain
- authentication, desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100