-
Notifications
You must be signed in to change notification settings - Fork 553
Introduce Unified API Key Generation, Storage, and Authentication for MCP for Unity #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…rt for server commands
… input management
… the server binary
- Removed legacy authentication settings and UI components. - Introduced API key management in AuthPreferencesUtility. - Updated ConfigJsonBuilder to use API key instead of authorization token. - Modified ServerManagementService to ensure API key is present. - Updated connection components to handle API key display and regeneration. - Changed server authentication logic to enforce API key usage. - Updated README and server documentation to reflect new authentication model. - Adjusted integration tests to validate new API key behavior.
… file path resolution
…ntication initialization
…fic logging for unauthorized access
…quest context for HTTP transport
…leware for /mcp endpoints
… add warning for unavailability
…on /mcp endpoints
…better client handling
…der for HTTP requests
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@Jordonh18 Thanks for your contribution here. This seems like a good idea for hardening the networking. But it does add complexity and maintenance, and more room for bugs and potential security issues down the road. So I guess my question is -- why now for this? Do you have a use case where you see more people wanting to run their own server remotely? It seems the vast majority of users are running locally at this point. |
|
The project already has extensive remote deployment infrastructure. The v8 migration explicitly redesigned the architecture to support remote scenarios. WebSocket communication replaced port 6400 specifically because a remote HTTP server wouldn't have access to a user's port 6400. The Docker Compose configuration binds to 0.0.0.0, and the documentation explicitly lists use cases like "run the MCP server in the cloud," "dedicated server all your personal computers connect to," and "hosted by various MCP marketplaces." These aren't theoretical features, they're documented capabilities of the current architecture. The security gap is that these remote deployment features exist without any authentication mechanism. Right now, anyone deploying the Docker container or running the HTTP server on a network exposes full Unity Editor control to anyone who can reach that endpoint. This isn't hypothetical. The documented use cases (team servers, cloud hosting, marketplace distribution) all require access control. Without authentication, users must choose between using the remote features unsafely or not using them at all, which seems wasteful given the significant architectural work that went into enabling them. A minimal API key implementation would be optional by default, preserving backward compatibility for local-only users. It would only activate when UNITY_MCP_API_KEY is set. This protects the users who are already deploying remotely (as your architecture enables and documents) without adding complexity for the majority running locally. This is a long-term improvement, and I’m fully aware there are plenty of factors to weigh up. I’d really like to hear any concerns or arguments against it. I’m always open to feedback on anything I propose. |
|
Hi, it makes sense, and I'm not against it in principle. In part this is a question of bandwidth (no pun intended). There are only a few active maintainers here, and I'm not a networking specialist -- so I need to look at it more closely, even though I realize it's straightforward. We should get feedback from other maintainers like @msanatan and @Scriptwonder too. It's true the http upgrade was done in anticipation of a remote option, so that's a clear point in its favor -- or rather, a must-have for that use case. I guess if it ends up being easy enough to do this (meaning potential downsides, maintenance-costs and risks clearly understood by all), then it doesn't matter if most people won't use it yet, it should just be in there. I just want to be deliberate and get everyone's input before we go full network mode. |
This pull request introduces a unified API key management system for MCP for Unity, enabling secure authentication across server processes, HTTP, and WebSocket transports. The changes ensure the API key is generated, persisted, and surfaced in the UI, and update configuration and connection logic to require and utilize the key. The most important changes are grouped below.
Authentication and API Key Management
AuthPreferencesUtilityclass to handle API key generation, storage (EditorPrefs and disk), and retrieval, ensuring the API key is always available and consistent between client and server.EditorPrefKeysto include a constant for storing the API key.X-API-KeyandAuthorizationheaders during handshake, with improved error handling for authentication failures.User Interface Enhancements
McpConnectionSection.uxmland code-behind), making it easy for users to manage their API key. [1] [2] [3] [4] [5] [6] [7]Configuration and Server Launch Updates
Meta and Miscellaneous
.metafiles for new assets and folders to support Unity's asset tracking. [1] [2]These changes collectively provide a more secure and user-friendly authentication flow for MCP for Unity, ensuring all clients and servers use a shared API key and making key management straightforward for users.