Per Session Tools Sample (#724)
This commit is contained in:
parent
ec3b08b9dc
commit
0f0aad020b
1 changed files with 396 additions and 0 deletions
23
samples/AspNetCoreMcpPerSessionTools/Tools/UserInfoTool.cs
Normal file
23
samples/AspNetCoreMcpPerSessionTools/Tools/UserInfoTool.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using ModelContextProtocol.Server;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace AspNetCoreMcpPerSessionTools.Tools;
|
||||
|
||||
/// <summary>
|
||||
/// User information tools
|
||||
/// </summary>
|
||||
[McpServerToolType]
|
||||
public sealed class UserInfoTool
|
||||
{
|
||||
[McpServerTool, Description("Gets information about the current user in the MCP session.")]
|
||||
public static string GetUserInfo()
|
||||
{
|
||||
// Dummy user information for demonstration purposes
|
||||
return $"User Information:\n" +
|
||||
$"- User ID: {Guid.NewGuid():N}[..8] (simulated)\n" +
|
||||
$"- Username: User{new Random().Next(1, 1000)}\n" +
|
||||
$"- Roles: User, Guest\n" +
|
||||
$"- Last Login: {DateTime.Now.AddMinutes(-new Random().Next(1, 60)):HH:mm:ss}\n" +
|
||||
$"- Account Status: Active";
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue