Conversation
Co-authored-by: PederHP <[email protected]>
Co-authored-by: PederHP <[email protected]>
Co-authored-by: PederHP <[email protected]>
Copilot
AI
changed the title
[WIP] Can you make an aspnetcore mcp server sample showcasing the technique described by halter73 here:
@modelcontextprotocol/csharp-sdk/issues/714
Base it on the existing aspnetcore sample:
@modelcontextprotocol/csharp-sdk/files/samples/AspNetCoreMcpServer
Add ASP.NET Core MCP server sample showcasing per-user tool filtering
Aug 21, 2025
PederHP
requested changes
Aug 21, 2025
Owner
PederHP
left a comment
There was a problem hiding this comment.
Looks good! We should remove dotnet-install.sh and demo.sh before merging this. But great examples.
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.
This PR addresses issue modelcontextprotocol#714 by implementing a complete sample demonstrating how to vary the list of available tools/resources per user in an ASP.NET Core MCP server.
Problem
Users needed a way to provide different sets of MCP tools to different users based on their authentication and permissions, rather than having a static list of tools available to all users.
Solution
The sample showcases the technique described by @halter73 in issue modelcontextprotocol#714, using the
ConfigureSessionOptionscallback to dynamically modify theToolCollectionbased on user permissions for each MCP session.Key Features
Per-User Tool Filtering
Implementation Highlights
The core technique uses
ConfigureSessionOptionsto filter tools per session:Sample Structure
Authentication
Uses a simple header-based authentication system for easy testing:
Benefits
Testing
The sample includes comprehensive testing:
Production Guidance
The README includes detailed guidance for adapting the sample for production use, including:
This sample provides a complete, working foundation for implementing per-user MCP tool/resource filtering in production applications.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.