fix(mcp): auto-discover project_id + fix cluster_versions_list crash#5
Merged
Merged
Conversation
- discovery: _require_project_id now async; when project_id is unset it fetches GET /v1/projects from vServer, uses the single project, and caches it on the config (no portal-user-id needed). Configured GRN_PROJECT_ID/credentials still take precedence. All discovery call sites updated to await. - version: fix cluster_versions_list crashing with "'list' object has no attribute 'get'" on a top-level array response; normalise dict/list/empty shapes robustly. - tests: bare-array version response; project_id configured/auto-discover+cache/ empty-error. Full suite 137 passed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two MCP server fixes:
Auto-discover
project_idfrom vServer._require_project_idis now async: whenproject_idis not configured (noGRN_PROJECT_ID, no credentials-file value — e.g. running in Docker / Agent Runtime), it fetchesGET /v1/projectsand uses the single project for the account (each user has exactly one), caching it on the config so later tool calls don't refetch. A configured value still takes precedence. Noportal-user-idrequired. All discovery call sites updated toawait.Fix
cluster_versions_listcrash'list' object has no attribute 'get'. The shape-normalisation ternary was inverted — it calleddata.get(...)exactly whendatawas a top-level array (which/v1/cluster-versionsreturns). Replaced with robust dict/list/empty normalisation.Test Plan
pytest tests/test_version_tools.py tests/test_discovery_tools.py— new tests: bare-array version response; project_id configured / auto-discover+cache / empty→errorruff checkclean🤖 Generated with Claude Code