Document recommended pattern for role/identity propagation in MCP tool execution#1497
Open
Document recommended pattern for role/identity propagation in MCP tool execution#1497
Conversation
Create docs/concepts/identity/identity.md covering: - How ClaimsPrincipal flows through the SDK pipeline - Direct ClaimsPrincipal parameter injection (recommended) - Accessing identity in filters - Role-based access with [Authorize] attributes - IHttpContextAccessor as HTTP-only alternative - Transport considerations (Streamable HTTP, SSE, stdio) - Setting identity for stdio via message filters Update toc.yml and index.md to include the new page. Agent-Logs-Url: https://github.com/modelcontextprotocol/csharp-sdk/sessions/4d418af2-a8c6-4d8d-8985-5bb54f93a8e9 Co-authored-by: jeffhandley <1031940+jeffhandley@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Document recommended pattern for role/identity propagation in MCP tool execution
Document recommended pattern for role/identity propagation in MCP tool execution
Apr 3, 2026
jeffhandley
requested changes
Apr 3, 2026
Agent-Logs-Url: https://github.com/modelcontextprotocol/csharp-sdk/sessions/b2f6909a-53c9-4c90-b26d-3ef35d085b93 Co-authored-by: jeffhandley <1031940+jeffhandley@users.noreply.github.com>
jeffhandley
approved these changes
Apr 3, 2026
Contributor
|
Here's a set of tests generated from these docs that validated all of the captured behavior: 082c3b5 |
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.
Fixes #1452
The SDK has built-in
ClaimsPrincipalpropagation viaJsonRpcMessage.Context.Userand automatic parameter injection into tool/prompt/resource handlers, but this wasn't documented anywhere.Adds
docs/concepts/identity/identity.mdcovering:ClaimsPrincipalparameter injection — the recommended, transport-agnostic pattern already demonstrated byClaimsPrincipalToolsin testscontext.User[Authorize]/[AllowAnonymous]+AddAuthorizationFilters()IHttpContextAccessorpositioned as HTTP-only alternative with cross-ref to existing httpcontext docUpdates
toc.ymlandindex.mdto wire up navigation.