Split vmcp auth/authz middleware for annotation flow#4115
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4115 +/- ##
==========================================
+ Coverage 68.84% 68.86% +0.01%
==========================================
Files 458 459 +1
Lines 46274 46324 +50
==========================================
+ Hits 31859 31899 +40
- Misses 11953 11959 +6
- Partials 2462 2466 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The vmcp middleware chain previously composed auth+parser+authz into a single middleware, which meant authz ran before discovery could provide tool annotations. This splits them so authz runs after discovery. - NewIncomingAuthMiddleware returns auth and authz separately (4 values) - Add annotation enrichment middleware between discovery and authz - Authz now sees tool annotations from discovered capabilities - New middleware ordering: auth+parser → audit → discovery → annotation-enrichment → authz → handler Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update stale middleware-chain comments in server.go to reflect the new ordering that includes annotation-enrichment and authz layers. Add an early-return guard to ParsingMiddleware so the double-application (once in auth, once in server.go for the no-auth case) skips re-reading the request body. Use the mcp.MethodToolsCall constant instead of a string literal to satisfy goconst, and add a clarifying comment on why convertAnnotations intentionally omits Title. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
e423040 to
b2c76b0
Compare
jhrozek
approved these changes
Mar 12, 2026
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
Type of change
Test plan
task test)task lint-fix)Changes
pkg/vmcp/auth/factory/incoming.goNewIncomingAuthMiddlewarereturns 4 values (auth, authz, handler, error) instead of 3. Auth+parser composed; authz returned separately.pkg/vmcp/auth/factory/incoming_test.gopkg/vmcp/auth/factory/authz_not_wired_test.gopkg/vmcp/server/annotation_enrichment.goWithToolAnnotationsfor authzpkg/vmcp/server/annotation_enrichment_test.gopkg/vmcp/server/server.goAuthzMiddlewarefield to Config; inserted authz and annotation-enrichment in middleware chaincmd/vmcp/app/commands.goAuthzMiddlewareto server configDoes this introduce a user-facing change?
No — internal middleware reordering. Users benefit when Cedar policies reference tool annotations in vmcp, which now work because authz runs after discovery has populated annotations.
Special notes for reviewers
auth+parser → audit → discovery → annotation-enrichment → authz → handler. The key change is authz moved from before discovery to after.AuthzMiddlewareis configured. No overhead when authz is disabled.tools/callmethods.authzMiddlewareis nil and skipped.Generated with Claude Code