using PostFundManagement.Application.Abstractions.Services; using PostFundManagement.Application.Extensions; using PostFundManagement.Application.Services.Communications; using PostFundManagement.Domain; using PostFundManagement.Domain.Models; namespace PostFundManagement.Application.Mcp; /// /// MCP tools proxying Communications, Onboarding Invites & Notification Services (Module M25, Recipient Onboarding M03). /// [McpServerToolType] public class CommunicationsMcpTools(ICommunicationsService service) { [McpServerTool(Name = "communications_get_notifications", Title = "Get Organisation Notifications", ReadOnly = true)] [Description("Retrieves notifications and alerts dispatched to an organisation.")] public async Task> GetNotificationsAsync([Description("Organisation hash identifier")] string organisationIdHash, CancellationToken cancellationToken = default) => (await service.GetNotificationsAsync(organisationIdHash, cancellationToken)).ToMcpResult(); [McpServerTool(Name = "communications_get_user_notifications", Title = "Get User Notifications", ReadOnly = true)] [Description("Retrieves pending notifications and task reminders for a specific user.")] public async Task> GetUserNotificationsAsync([Description("Target user identifier")] Guid userId, CancellationToken cancellationToken = default) => (await service.GetUserNotificationsAsync(userId, cancellationToken)).ToMcpResult(); [McpServerTool(Name = "communications_create_notification", Title = "Dispatch Notification", Destructive = false)] [Description("Creates and queues a system, in-app, or email notification for delivery (FR-M25-001).")] public async Task CreateNotificationAsync([Description("Notification creation request")] CreateNotificationRequest request, [Description("Optional acting user ID; defaults to System user if omitted")] Guid? userId = null, CancellationToken cancellationToken = default) => (await service.CreateNotificationAsync(request, userId ?? SystemUser, cancellationToken)).ToMcpResult("Notification successfully created and queued for delivery."); [McpServerTool(Name = "communications_update_notification", Title = "Update Notification Status", Destructive = false)] [Description("Updates the delivery or read status of a notification.")] public async Task UpdateNotificationAsync([Description("Notification update request")] UpdateNotificationRequest request, CancellationToken cancellationToken = default) => (await service.UpdateNotificationAsync(request, cancellationToken)).ToMcpResult("Notification status successfully updated."); [McpServerTool(Name = "communications_send_invite", Title = "Send Onboarding Invite", Destructive = false)] [Description("Sends an invitation email and onboarding link to an external grantee or partner organisation user (Module M03).")] public async Task> SendInviteAsync([Description("Invite request parameters")] InviteRequest request, [Description("Optional acting user ID; defaults to System user if omitted")] Guid? userId = null, CancellationToken cancellationToken = default) => (await service.SendInviteAsync(request, userId ?? SystemUser, cancellationToken)).ToMcpResult(); [McpServerTool(Name = "communications_get_invites", Title = "Get Onboarding Invites", ReadOnly = true)] [Description("Retrieves a paginated list of sent onboarding invitations and their verification states.")] public async Task> GetInvitesAsync([Description("Page index (1-based)")] int page = 1, [Description("Page size (1-100)")] int pageSize = 50, CancellationToken cancellationToken = default) => (await service.GetInvitesAsync(new Pagination(page, pageSize), cancellationToken)).ToMcpResult(); [McpServerTool(Name = "communications_get_applicant_data", Title = "Get Applicant Intake Data", ReadOnly = true)] [Description("Retrieves captured applicant and grantee profile data for onboarding validation.")] public async Task> GetApplicantDataAsync([Description("Applicant user identifier")] Guid applicantUserId, CancellationToken cancellationToken = default) => (await service.GetApplicantDataAsync(applicantUserId, cancellationToken)).ToMcpResult(); }