Added MCp support
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
using PostFundManagement.Application.Abstractions.Services;
|
||||
using PostFundManagement.Application.Extensions;
|
||||
using PostFundManagement.Application.Services.Evidence;
|
||||
using PostFundManagement.Domain;
|
||||
using PostFundManagement.Domain.Models;
|
||||
|
||||
namespace PostFundManagement.Application.Mcp;
|
||||
|
||||
/// <summary>
|
||||
/// MCP tools proxying Evidence, Indicators & Verification Services (BR-004 Evidence-Based Performance, M07 Milestones, M08 M&E Indicators).
|
||||
/// </summary>
|
||||
[McpServerToolType]
|
||||
public class EvidenceMcpTools(IEvidenceService service)
|
||||
{
|
||||
[McpServerTool(Name = "evidence_get_files", Title = "Get Uploaded Evidence Records", ReadOnly = true)]
|
||||
[Description("Retrieves a paginated list of uploaded evidence documents and audit artifacts (BR-004, Module M07).")]
|
||||
public async Task<Records<Evidence[]>> GetEvidenceFilesAsync([Description("Page index (1-based)")] int page = 1, [Description("Page size (1-100)")] int pageSize = 50, CancellationToken cancellationToken = default) =>
|
||||
(await service.GetEvidenceFilesAsync(new Pagination(page, pageSize), cancellationToken)).ToMcpResult();
|
||||
|
||||
[McpServerTool(Name = "evidence_get_evidence", Title = "Get Evidence by ID", ReadOnly = true)]
|
||||
[Description("Retrieves metadata, verification status, and hash verification for an evidence document.")]
|
||||
public async Task<Records<Evidence>> GetEvidenceAsync([Description("Evidence hash identifier")] string evidenceIdHash, CancellationToken cancellationToken = default) =>
|
||||
(await service.GetEvidenceAsync(evidenceIdHash, cancellationToken)).ToMcpResult();
|
||||
|
||||
[McpServerTool(Name = "evidence_get_milestone_evidence", Title = "Get Milestone Evidence", ReadOnly = true)]
|
||||
[Description("Retrieves all evidence documents uploaded to substantiate a specific milestone.")]
|
||||
public async Task<Records<Evidence[]>> GetMilestoneEvidenceAsync([Description("Milestone hash identifier")] string milestoneIdHash, CancellationToken cancellationToken = default) =>
|
||||
(await service.GetMilestoneEvidencesAsync(milestoneIdHash, cancellationToken)).ToMcpResult();
|
||||
|
||||
[McpServerTool(Name = "evidence_get_project_evidence", Title = "Get Project Evidence", ReadOnly = true)]
|
||||
[Description("Retrieves all evidence documents associated with a project across all its milestones and indicators.")]
|
||||
public async Task<Records<Evidence[]>> GetProjectEvidenceAsync([Description("Project hash identifier")] string projectIdHash, CancellationToken cancellationToken = default) =>
|
||||
(await service.GetProjectEvidencesAsync(projectIdHash, cancellationToken)).ToMcpResult();
|
||||
|
||||
[McpServerTool(Name = "evidence_get_url", Title = "Get Evidence Document URL", ReadOnly = true)]
|
||||
[Description("Generates a secure presigned download URL for an uploaded evidence artifact in object storage.")]
|
||||
public async Task<Records<string>> GetEvidenceUrlAsync([Description("Evidence hash identifier")] string evidenceIdHash, CancellationToken cancellationToken = default) =>
|
||||
(await service.GetEvidenceUrlAsync(evidenceIdHash, cancellationToken)).ToMcpResult();
|
||||
|
||||
[McpServerTool(Name = "evidence_get_indicators", Title = "Get M&E Indicators", ReadOnly = true)]
|
||||
[Description("Retrieves a paginated list of M&E indicators measuring project results hierarchy (Module M08, BR-008, BR-009).")]
|
||||
public async Task<Records<Indicator[]>> GetIndicatorsAsync([Description("Page index (1-based)")] int page = 1, [Description("Page size (1-100)")] int pageSize = 50, CancellationToken cancellationToken = default) =>
|
||||
(await service.GetIndicatorsAsync(new Pagination(page, pageSize), cancellationToken)).ToMcpResult();
|
||||
|
||||
[McpServerTool(Name = "evidence_get_indicator", Title = "Get Indicator by ID", ReadOnly = true)]
|
||||
[Description("Retrieves baseline, target, actual values, and variance calculation for an indicator (BR-009).")]
|
||||
public async Task<Records<Indicator>> GetIndicatorAsync([Description("Indicator hash identifier")] string indicatorIdHash, CancellationToken cancellationToken = default) =>
|
||||
(await service.GetIndicatorAsync(indicatorIdHash, cancellationToken)).ToMcpResult();
|
||||
|
||||
[McpServerTool(Name = "evidence_create_indicator", Title = "Create Performance Indicator", Destructive = false)]
|
||||
[Description("Creates an M&E indicator measuring Output, Outcome, or Impact with baseline and targets (Module M08, BR-008).")]
|
||||
public async Task<McpToolResult> CreateIndicatorAsync([Description("Indicator creation request")] CreateIndicatorRequest request, [Description("Optional acting user ID; defaults to System user if omitted")] Guid? userId = null, CancellationToken cancellationToken = default) =>
|
||||
(await service.CreateIndicatorAsync(request, userId ?? SystemUser, cancellationToken)).ToMcpResult("Indicator successfully created.");
|
||||
|
||||
[McpServerTool(Name = "evidence_record_actual_amount", Title = "Record Indicator Actual Value", Destructive = false)]
|
||||
[Description("Records achieved actual metric and cost for an indicator, recalculating variance against target (BR-009).")]
|
||||
public async Task<McpToolResult> RecordIndicatorActualAmountAsync([Description("Indicator hash identifier")] string indicatorIdHash, [Description("Actual numerical value achieved")] decimal amount, [Description("Optional actual financial cost incurred")] decimal? actualCost = null,
|
||||
[Description("Optional acting user ID; defaults to System user if omitted")] Guid? userId = null, CancellationToken cancellationToken = default) =>
|
||||
(await service.RecordIndicatorActualAmountAsync(indicatorIdHash, amount, actualCost, userId ?? SystemUser, cancellationToken)).ToMcpResult("Indicator actual value successfully recorded.");
|
||||
|
||||
[McpServerTool(Name = "evidence_create_milestone", Title = "Create Milestone with Gating Criteria", Destructive = false)]
|
||||
[Description("Defines a project milestone with verification evidence rules gating tranche disbursements (Module M07, BR-003).")]
|
||||
public async Task<McpToolResult> CreateMilestoneAsync([Description("Milestone creation request")] CreateMilestoneRequest request, [Description("Optional acting user ID; defaults to System user if omitted")] Guid? userId = null, CancellationToken cancellationToken = default) =>
|
||||
(await service.CreateMilestoneAsync(request, userId ?? SystemUser, cancellationToken)).ToMcpResult("Milestone successfully created.");
|
||||
|
||||
[McpServerTool(Name = "evidence_update_evidence", Title = "Update Evidence Metadata", Destructive = false)]
|
||||
[Description("Updates verification status, review notes, or metadata for an evidence submission.")]
|
||||
public async Task<McpToolResult> UpdateEvidenceAsync([Description("Evidence update request")] UpdateEvidenceRequest request, [Description("Optional acting user ID; defaults to System user if omitted")] Guid? userId = null, CancellationToken cancellationToken = default) =>
|
||||
(await service.UpdateEvidenceAsync(request, userId ?? SystemUser, cancellationToken)).ToMcpResult("Evidence metadata successfully updated.");
|
||||
}
|
||||
Reference in New Issue
Block a user