Configure rate limits on VirtualMCPServer PR B 2#5522
Open
Sanskarzz wants to merge 1 commit into
Open
Conversation
Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5522 +/- ##
==========================================
+ Coverage 69.70% 69.72% +0.02%
==========================================
Files 645 645
Lines 65598 65627 +29
==========================================
+ Hits 45724 45758 +34
+ Misses 16530 16523 -7
- Partials 3344 3346 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
This PR adds optimizer-aware tool-name resolution to vMCP rate limiting.
PR #5276 wired
VirtualMCPServer.spec.config.rateLimitinginto the vMCP runtime for normaltools/callrequests, where the parsed MCP resource ID is already the backend tool name. When the vMCP optimizer is enabled, clients call the optimizer meta-toolcall_tool, and the real backend tool name is carried insidearguments["tool_name"]. Without this follow-up, per-tool rate limits are evaluated againstcall_toolinstead of the backend tool the optimizer is routing to.Fixes #4552
Type of change
Test plan
task test)task test-e2e)task lint-fix)API Compatibility
v1beta1API, OR theapi-break-allowedlabel is applied and the migration guidance is described above.This PR does not change the CRD schema or
v1beta1API surface.Changes
pkg/vmcp/cli/serve.gopassThroughToolsmap into the vMCP rate-limit factory.pkg/vmcp/ratelimit/factory/middleware.gocall_toolinner-tool resolution before invoking the shared rate-limit middleware.pkg/vmcp/ratelimit/factory/middleware_test.gotest/e2e/thv-operator/virtualmcp/virtualmcp_rate_limiting_test.gocall_toolrate limiting by inner backend tool name.Does this introduce a user-facing change?
Yes. When vMCP optimizer is enabled, per-tool rate limits now apply to the real backend tool name passed through
call_tool, instead of applying to the optimizer meta-tool name.Implementation plan
Approved implementation plan
passThroughToolsmap computed inpkg/vmcp/cli/serve.go.pkg/vmcp/ratelimit/factory.NewMiddleware.tools/callrequests.call_toolandarguments["tool_name"]is a non-empty string, shallow-copy the parsed MCP request and replace onlyResourceIDwith the inner backend tool name.pkg/ratelimitmiddleware with that temporary parsed request so rate-limit buckets use the backend tool name.call_toolrequest.call_toolinvocation for the same inner tool is rate-limited.Special notes for reviewers
pkg/ratelimit.pkg/ratelimit.NewMiddlewareremains the owner of Redis setup, limiter construction, fail-open behavior, identity extraction, and the JSON-RPC 429 response.call_toolto the inner backend tool name before the shared rate-limit middleware checks the bucket.call_toolrequest.