Skip to content

feat: check and cache permission remote MCP calls - #10930

Open
chkuang-g wants to merge 6 commits into
mainfrom
chkuang/mcp-role
Open

feat: check and cache permission remote MCP calls#10930
chkuang-g wants to merge 6 commits into
mainfrom
chkuang/mcp-role

Conversation

@chkuang-g

@chkuang-g chkuang-g commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description

Verifies that the authenticated account has the right permission to make OneMCP tools/call before making remote calls. To avoid ResourceManager API query latency and quota burn, positive validations are cached with TTL in configstore. If validation fails, it attempts to auto-bind the role roles/mcp.toolUser using setIamPolicy, falling back to clear error instructions and manual gcloud repair commands on permission failures.

Scenarios Tested

  • Unit tests for local caching logic, direct API checking (via force flag), prefix resolution, and auto-binding flows.
  • Unit tests verifying OneMcpServer callTool correctly invokes the validation logic.

Sample Commands

N/A. It only affect MCP

@chkuang-g
chkuang-g requested a review from joehan August 12, 2026 22:17
Comment thread src/ensureRoleBound.ts Fixed

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ensureRole utility to verify and automatically bind the required IAM role (roles/mcp.toolUser) for a user or service account on a GCP project, caching positive results in configstore to reduce latency. The review feedback focuses on improving the robustness and user experience of this implementation: adding a 24-hour TTL to the cache to prevent stale permissions, printing a user-facing message during the 10-second propagation delay to avoid the appearance of a frozen CLI, avoiding the use of any in the catch block by using the getError utility, and updating the unit tests to reflect these changes.

Comment thread src/ensureRoleBound.ts Outdated
Comment thread src/ensureRoleBound.ts Outdated
Comment thread src/ensureRoleBound.ts Outdated
Comment thread src/ensureRoleBound.ts Outdated
Comment thread src/ensureRoleBound.ts Outdated
Comment thread src/ensureRoleBound.spec.ts Outdated
Comment thread src/ensureRoleBound.spec.ts Outdated
Comment thread src/ensureRoleBound.spec.ts Outdated
Comment thread src/ensureRoleBound.spec.ts Outdated
Verifies that the authenticated account has the 'roles/mcp.toolUser' role before making remote calls for 'tools/call'. To avoid ResourceManager API query latency and quota burn, positive validations are cached indefinitely in configstore. If validation fails, it attempts to auto-bind the role using setIamPolicy, falling back to clear error instructions and manual gcloud repair commands on permission failures.

- Unit tests for local caching logic, direct API checking (via force flag), prefix resolution, and auto-binding flows.
- Unit tests verifying OneMcpServer callTool correctly invokes the validation logic.

@joehan joehan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spoke in chat - this one might be uneeded?

@chkuang-g chkuang-g changed the title feat: enforce and cache roles/mcp.toolUser for remote MCP calls feat: check and cache permission remote MCP calls Aug 13, 2026
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.

4 participants