Added MCp support
This commit is contained in:
@@ -70,7 +70,8 @@ PostFundManagement/
|
||||
├── PostFundManagement.Domain/ # Core entities, enums, value objects, domain logic
|
||||
├── PostFundManagement.Infrastructure/ # EF Core 10, PostgreSQL (Npgsql), Migrations, Data Protection
|
||||
├── PostFundManagement.Application/ # CQRS Handlers, Mediator, DTOs, Validations, S3, Email, Quartz
|
||||
├── PostFundManagement.Api/ # Minimal APIs / Carter endpoints, Auth, Swagger/Scalar, Versioning
|
||||
├── PostFundManagement.Api/ # Minimal APIs / Carter endpoints, Auth, Swagger/Scalar, In-App MCP Consumer
|
||||
├── PostFundManagement.Mcp/ # Dedicated Model Context Protocol (MCP) Server Host (HTTP/SSE & Stdio Transports)
|
||||
├── PostFundManagement.Jobs/ # Dedicated Quartz.NET Background Worker Host (Recurring & One-Time Execution)
|
||||
├── PostFundManagement.Tests/ # Unit & Integration test suite (xUnit, Coverlet)
|
||||
├── PostFundManagement.ConsoleUI/ # Internal Staff & Admin Web Portal (React 19 + Vite 6 + Tailwind 4)
|
||||
@@ -86,7 +87,8 @@ PostFundManagement/
|
||||
| **`PostFundManagement.Domain`** | `net10.0` | `Microsoft.EntityFrameworkCore` 10.0.12, `Npgsql.EntityFrameworkCore.PostgreSQL` 10.0.3, `Humanizer` 3.0.10, `Hashids.net` 1.7.0, `OpenTelemetry` 1.18.0, `Quartz` 4.1.0, `FluentResults` 4.0.0, `Mediator.Abstractions` 3.0.2, `AWSSDK.S3` 4.0.103.3, `MailKit`/`MimeKit` 4.18.0 | Contains domain entities, aggregate roots, value objects, domain enums, constant definitions, and interfaces. Clean of presentation concerns. |
|
||||
| **`PostFundManagement.Infrastructure`** | `net10.0` | `Microsoft.EntityFrameworkCore` 10.0.12, `Npgsql.EntityFrameworkCore.PostgreSQL` 10.0.3, `Duende.AccessTokenManagement` 4.2.0, EF Core Tools & Design | Houses `PostFundManagementDbContext`, EF Core fluent configurations, entity-to-table mappings, PostgreSQL schema definitions, multitenancy filters, and migrations. |
|
||||
| **`PostFundManagement.Application`** | `net10.0` | `Mediator.SourceGenerator` / `Mediator.Abstractions` 3.0.2, `FluentResults` 4.0.0, `Microsoft.Extensions.Caching.Hybrid` 10.10.0, `Microsoft.Extensions.Caching.StackExchangeRedis` 10.0.12, `Refit` 15.2.0, `Duende.AccessTokenManagement.OpenIdConnect` 4.2.0, `Quartz` 4.1.0, `AWSSDK.S3` | Implements CQRS command/query handlers, domain validators, S3 object storage clients (Garage S3), background jobs (Quartz), notification dispatchers, and business logic. |
|
||||
| **`PostFundManagement.Api`** | `net10.0` | `Microsoft.AspNetCore.OpenApi` 10.0.12, `Scalar.AspNetCore` 2.17.4, `Asp.Versioning.Http` 10.2.3, `IdentityModel.AspNetCore` 4.3.0, `Microsoft.AspNetCore.Authentication.JwtBearer` 10.0.12, `AspNetCore.HealthChecks.NpgSql` 9.0.0, `AspNetCore.HealthChecks.UI` | Minimal API endpoint definitions divided by business slices (`Grants`, `Projects`, `Execution`, `Governance`, `Evidence`, `Communications`, `Users`). Handles routing, auth policies, error problem details, and OpenAPI metadata. |
|
||||
| **`PostFundManagement.Api`** | `net10.0` | `Microsoft.AspNetCore.OpenApi` 10.0.12, `Scalar.AspNetCore` 2.17.4, `Asp.Versioning.Http` 10.2.3, `IdentityModel.AspNetCore` 4.3.0, `Microsoft.AspNetCore.Authentication.JwtBearer` 10.0.12, `ModelContextProtocol` 2.3.0, `AspNetCore.HealthChecks.NpgSql` 9.0.0, `AspNetCore.HealthChecks.UI` | Minimal API endpoint definitions divided by business slices (`Grants`, `Projects`, `Execution`, `Governance`, `Evidence`, `Communications`, `Users`). Features direct in-app MCP tooling access (`IInAppMcpClient`) for in-process tool execution without external network calls. Handles routing, auth policies, error problem details, and OpenAPI metadata. |
|
||||
| **`PostFundManagement.Mcp`** | `net10.0` | `ModelContextProtocol.AspNetCore` 2.3.0, `ModelContextProtocol` 2.3.0, `ModelContextProtocol.Core` 2.3.0, `AspNetCore.HealthChecks.NpgSql` 9.0.0, `AspNetCore.HealthChecks.UI` | Dedicated Model Context Protocol (MCP) Server host. Realises and serves tools defined in `Application.Mcp` externally over HTTP/SSE (`/mcp`) and Stdio (`--stdio`) for external LLMs, agent frameworks, and IDEs. |
|
||||
| **`PostFundManagement.Jobs`** | `net10.0` | `Quartz` 4.6.2, `Quartz.Extensions.DependencyInjection` 4.6.2, `Quartz.Serialization.SystemTextJson` 4.6.2, `Mediator.Abstractions` 3.0.2 | Dedicated background execution host. Executes recurring Quartz jobs (registered on startup by `JobsWorker`), processes asynchronous domain events (`IEvent`), and executes jobs concurrently (`MaxConcurrency = 5`). |
|
||||
| **`PostFundManagement.Tests`** | `net10.0` | `xunit` 2.9.3, `xunit.runner.visualstudio` 3.1.4, `Microsoft.NET.Test.Sdk` 17.14.1, `coverlet.collector` 6.0.4 | Unit and integration test coverage for domain rules, CQRS handlers, financial calculation models, and gate condition validations. |
|
||||
|
||||
@@ -146,6 +148,68 @@ PostFundManagement/
|
||||
3. *Email Notification Processing*: Batches and dispatches pending notification entries (`Platform.Email` / `NotificationPlatform.Email`) via MailKit/MimeKit SMTP and records delivery telemetry (`FR-M25-001`).
|
||||
4. *Future Jobs*: Seamlessly supports future scheduled workloads (e.g. drawdown reconciliations, compliance expiries, portfolio aggregations) simply by adding `IEvent` handlers.
|
||||
|
||||
### 2.5 Model Context Protocol (MCP) Architecture (Internal In-App & External Server Topology)
|
||||
The platform establishes a dual-channel Model Context Protocol (MCP) architecture on **.NET 10** using `ModelContextProtocol.AspNetCore` (v2.3.0):
|
||||
|
||||
```
|
||||
┌────────────────────────────────────────────────────────────────────────┐
|
||||
│ MCP TOOLING CONSUMERS │
|
||||
│ │
|
||||
│ [External AI Agents / Claude / Cursor] [Internal PFM API Flows] │
|
||||
│ │ │ │
|
||||
│ HTTP / SSE │ Stdio (--stdio) │ In-Process │
|
||||
│ (/mcp) │ │ Direct Call │
|
||||
│ ▼ ▼ │
|
||||
│ ┌─────────────────────────┐ ┌─────────────────────┐ │
|
||||
│ │ PostFundManagement.Mcp │ │PostFundManagement. │ │
|
||||
│ │ (Dedicated Server Host) │ │Api (In-App Consumer)│ │
|
||||
│ └────────────┬────────────┘ └──────────┬──────────┘ │
|
||||
│ │ │ │
|
||||
│ │ Direct DI / Component Reference │ │
|
||||
│ ▼ ▼ │
|
||||
│ ┌─────────────────────────────────────────────────────────────┐ │
|
||||
│ │ PostFundManagement.Application/Mcp │ │
|
||||
│ │ │ │
|
||||
│ │ [Grants] [Projects] [Execution] [Governance] │ │
|
||||
│ │ [Evidence] [Communications][Users] │ │
|
||||
│ │ Proxying: Application.Services.* │ │
|
||||
│ │ InApp Client: IInAppMcpClient / InAppMcpClient │ │
|
||||
│ └──────────────────────────────┬──────────────────────────────┘ │
|
||||
│ ▼ │
|
||||
│ ┌─────────────────────────────────────────────────────────────┐ │
|
||||
│ │ Application Domain Services │ │
|
||||
│ │ IGrantsService, IProjectService, IExecutionService, ... │ │
|
||||
│ └─────────────────────────────────────────────────────────────┘ │
|
||||
└────────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
1. **Tool Definitions Centralized in `Application.Mcp`**:
|
||||
- All MCP tools are defined in `PostFundManagement.Application` under the `Mcp` directory.
|
||||
- Tools are grouped strictly according to `Application.Services` boundaries:
|
||||
* `GrantsMcpTools`: Proxies `IGrantsService` (Awards M01, Contracts M02, Budgets M05).
|
||||
* `ProjectsMcpTools`: Proxies `IProjectService` (WBS Activities M04, Milestones M07, Beneficiaries M13, Changes M15, Issues M16, Site Visits M17).
|
||||
* `ExecutionMcpTools`: Proxies `IExecutionService` (Disbursements M06, Risk Register M09, Gating Rules BR-003).
|
||||
* `GovernanceMcpTools`: Proxies `IGovernanceService` (Organisations M03, Portfolios, Instruments BR-006, Tenants, Dashboards M20/M22).
|
||||
* `EvidenceMcpTools`: Proxies `IEvidenceService` (Audit Artifacts BR-004, M&E Indicators M08, Target/Actual Variance BR-009).
|
||||
* `CommunicationsMcpTools`: Proxies `ICommunicationsService` (Notifications M25, Onboarding Invites M03).
|
||||
* `UsersMcpTools`: Proxies `IUserService` (Identity accounts, RBAC roles, security claims).
|
||||
|
||||
2. **In-App MCP Consumer in `PostFundManagement.Api` (Zero Web Hops)**:
|
||||
- `PostFundManagement.Api` accesses tools in-process via `IInAppMcpClient` registered by `AddApplicationMcpTools()`.
|
||||
- Resolves and executes tool methods directly against scoped domain services without issuing HTTP network calls to an external MCP server.
|
||||
- Provides optional in-process protocol compatibility via `CreateProtocolClientAsync()` using duplex in-memory streams.
|
||||
- *Design Boundary*: No autonomous AI agents are defined in the solution at this time; the tooling layer and in-app consumer interfaces provide the underlying foundation for future agentic orchestration.
|
||||
|
||||
3. **External MCP Server in `PostFundManagement.Mcp`**:
|
||||
- Dedicated Web/CLI host running .NET 10.
|
||||
- Exposes tools externally via HTTP/SSE (`/mcp`) for remote agents, orchestrators, and platforms.
|
||||
- Supports local Stdio transport (`--stdio`) for desktop agents, Claude Desktop, and IDE tools.
|
||||
- Docker containerized (`pfm-mcp` service on port 8079).
|
||||
|
||||
4. **Token Usage Optimization**:
|
||||
- Tools return standardized, lightweight `McpToolResult<T>` and `McpToolResult` models.
|
||||
- Strips internal FluentResults metadata and complex execution graphs to ensure minimal prompt token bloat for consuming LLMs.
|
||||
|
||||
---
|
||||
|
||||
## 3. Master Business Rules (BR-001 to BR-010)
|
||||
|
||||
Reference in New Issue
Block a user