Skip to content

Fix MCP local deployment detection for self-hosted projects (#78)#92

Open
JustYannicc wants to merge 4 commits intoget-convex:mainfrom
JustYannicc:main
Open

Fix MCP local deployment detection for self-hosted projects (#78)#92
JustYannicc wants to merge 4 commits intoget-convex:mainfrom
JustYannicc:main

Conversation

@JustYannicc
Copy link
Copy Markdown

@JustYannicc JustYannicc commented Sep 30, 2025

Local/self-hosted deployments weren’t accessible through the MCP server; every tool call crashed with “Local backend isn’t running” or “Not Authorized,” as reported in #78.

  • ensure _loadExistingDeploymentCredentialsForProject skips BigBrain access checks when a deployment is explicitly marked local
  • broaden assertLocalBackendRunning to try both the configured URL, CONVEX_URL, and localhost/127.0.0.1 variants before failing
  • restores the private helper getTeamAndProjectSlugForDeployment scope and cleans up unused exports

Link to the issue: #78

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@goody81
Copy link
Copy Markdown

goody81 commented Oct 1, 2025

on it

@JustYannicc
Copy link
Copy Markdown
Author

anybody going to check this?

@JustYannicc
Copy link
Copy Markdown
Author

@thomasballinger you seem to be decently active here, could you maybe take a look at this?

@goody81
Copy link
Copy Markdown

goody81 commented Jan 10, 2026

This looks like a pull request description for fixing issues with local/self-hosted deployments in an MCP (Model Context Protocol) server. Let me help you refine this to be clearer and more professional:
Fix local/self-hosted deployment access in MCP server
Problem
Local/self-hosted deployments were inaccessible through the MCP server. Every tool call crashed with errors like "Local backend isn't running" or "Not Authorized" (see #78).
Changes
This PR fixes the issue by making three key improvements:
Skip BigBrain access checks for local deployments: Modified _loadExistingDeploymentCredentialsForProject to skip BigBrain access checks when a deployment is explicitly marked as local.
Improved local backend detection: Broadened assertLocalBackendRunning to try multiple URL variants before failing:
The configured URL
CONVEX_URL environment variable
localhost variants (localhost/127.0.0.1)
Code cleanup: Restored the private helper getTeamAndProjectSlugForDeployment to proper scope and removed unused exports.
Related Issue
Fixes #78
Contribution License
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Suggestions for improvement:
Add a "Testing" section describing how you verified the fix works
Include code snippets showing the key changes if appropriate
Add any migration notes if configuration changes are needed
Consider adding automated tests to prevent regression
Would you like me to help you expand any of these sections or add additional details?

zerx-lab pushed a commit to zerx-lab/convex-js that referenced this pull request Jan 16, 2026
- Add llms.txt documentation file from docs.convex.dev
- Create test project to reproduce MCP authorization issue
- Add investigation report confirming the bug in PR get-convex#92 / Issue get-convex#78

The investigation confirms that MCP returns "Not Authorized" error
for local/anonymous deployments because checkAuthorization() is
called unconditionally, even though local deployments don't need
cloud authentication.
zerx-lab pushed a commit to zerx-lab/convex-js that referenced this pull request Jan 16, 2026
The MCP server was unconditionally requiring BigBrain (Convex Cloud)
authentication for all tool calls, which caused local, anonymous,
and self-hosted deployments to fail with "Not Authorized" error.

This fix implements smart authorization checking that:
- Skips BigBrain auth for self-hosted deployments (CONVEX_SELF_HOSTED_URL)
- Skips BigBrain auth for CLI-specified URL/adminKey
- Skips BigBrain auth for anonymous local development
- Preserves BigBrain auth requirement for cloud-hosted deployments

Changes:
- Add requiresBigBrainAuth() method to RequestContext
- Add requiresBigBrainAuthForDeployment() helper function
- Modify MCP tool handler to use smart auth checking

Fixes: get-convex#78
Related: PR get-convex#92
zerx-lab pushed a commit to zerx-lab/convex-js that referenced this pull request Jan 16, 2026
- Updated PR92-INVESTIGATION-REPORT.md with detailed fix implementation
- Added comprehensive test results showing all scenarios pass
- Documented the difference between this fix and PR get-convex#92 approach
- Added test script for verification
zerx-lab pushed a commit to zerx-lab/convex-js that referenced this pull request Jan 16, 2026
The MCP server was unconditionally requiring BigBrain (Convex Cloud)
authentication for all tool calls, which caused local, anonymous,
and self-hosted deployments to fail with "Not Authorized" error.

Changes:
- Add requiresBigBrainAuth() method to RequestContext that checks
  deployment type before requiring cloud authentication
- Add requiresBigBrainAuthForDeployment() helper function
- Modify MCP tool handler to use smart auth checking
- Add clear usage documentation in --help for different deployment types

Deployment types that NO LONGER require cloud login:
- Self-hosted (CONVEX_SELF_HOSTED_URL + CONVEX_SELF_HOSTED_ADMIN_KEY)
- CLI direct (--url + --admin-key)
- Anonymous local development (CONVEX_AGENT_MODE=anonymous)

Deployment types that STILL require cloud login:
- Cloud-hosted projects (CONVEX_DEPLOYMENT)
- Deploy key based (CONVEX_DEPLOY_KEY)
- Preview deployments

Fixes: get-convex#78
Related: PR get-convex#92
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.

2 participants