diff --git a/colaflow-api/src/ColaFlow.API/ColaFlow.API.csproj b/colaflow-api/src/ColaFlow.API/ColaFlow.API.csproj index 1d3af72..60f0be8 100644 --- a/colaflow-api/src/ColaFlow.API/ColaFlow.API.csproj +++ b/colaflow-api/src/ColaFlow.API/ColaFlow.API.csproj @@ -13,6 +13,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/colaflow-api/src/ColaFlow.API/Mcp/Sdk/SdkPocResources.cs b/colaflow-api/src/ColaFlow.API/Mcp/Sdk/SdkPocResources.cs new file mode 100644 index 0000000..f16a9f4 --- /dev/null +++ b/colaflow-api/src/ColaFlow.API/Mcp/Sdk/SdkPocResources.cs @@ -0,0 +1,54 @@ +// PoC file to test Microsoft ModelContextProtocol SDK Resources +// This demonstrates the SDK's attribute-based resource registration + +using ModelContextProtocol.Server; +using System.ComponentModel; + +namespace ColaFlow.API.Mcp.Sdk; + +/// +/// PoC class to test Microsoft MCP SDK Resource registration +/// NOTE: McpServerResource attribute MUST be on methods, not properties +/// +[McpServerResourceType] +public class SdkPocResources +{ + /// + /// Simple resource method to test SDK attribute system + /// + [McpServerResource] + [Description("Check MCP SDK integration status")] + public static Task GetSdkStatus() + { + return Task.FromResult(""" + { + "status": "active", + "sdk": "Microsoft.ModelContextProtocol", + "version": "0.4.0-preview.3", + "message": "SDK integration working!" + } + """); + } + + /// + /// Resource method to test health check + /// + [McpServerResource] + [Description("Health check resource")] + public static Task GetHealthCheck() + { + var healthData = new + { + healthy = true, + timestamp = DateTime.UtcNow, + components = new[] + { + new { name = "MCP SDK", status = "operational" }, + new { name = "Attribute Discovery", status = "operational" }, + new { name = "DI Integration", status = "testing" } + } + }; + + return Task.FromResult(System.Text.Json.JsonSerializer.Serialize(healthData)); + } +} diff --git a/colaflow-api/src/ColaFlow.API/Mcp/Sdk/SdkPocTools.cs b/colaflow-api/src/ColaFlow.API/Mcp/Sdk/SdkPocTools.cs new file mode 100644 index 0000000..265fa58 --- /dev/null +++ b/colaflow-api/src/ColaFlow.API/Mcp/Sdk/SdkPocTools.cs @@ -0,0 +1,60 @@ +// PoC file to test Microsoft ModelContextProtocol SDK +// This demonstrates the SDK's attribute-based tool registration + +using ModelContextProtocol.Server; +using System.ComponentModel; + +namespace ColaFlow.API.Mcp.Sdk; + +/// +/// PoC class to test Microsoft MCP SDK Tool registration +/// +[McpServerToolType] +public class SdkPocTools +{ + /// + /// Simple ping tool to test SDK attribute system + /// + [McpServerTool] + [Description("Test tool that returns a pong message")] + public static Task Ping() + { + return Task.FromResult("Pong from Microsoft MCP SDK!"); + } + + /// + /// Tool with parameters to test SDK parameter marshalling + /// + [McpServerTool] + [Description("Get project information by ID")] + public static Task GetProjectInfo( + [Description("Project ID")] Guid projectId, + [Description("Include archived projects")] bool includeArchived = false) + { + return Task.FromResult(new + { + projectId, + name = "SDK PoC Project", + status = "active", + includeArchived, + message = "This is a PoC response from Microsoft MCP SDK" + }); + } + + /// + /// Tool with dependency injection to test SDK DI integration + /// + [McpServerTool] + [Description("Get server time to test dependency injection")] + public static Task GetServerTime(ILogger logger) + { + logger.LogInformation("GetServerTime tool called via Microsoft MCP SDK"); + + return Task.FromResult(new + { + serverTime = DateTime.UtcNow, + message = "Dependency injection works!", + sdkVersion = "0.4.0-preview.3" + }); + } +} diff --git a/colaflow-api/src/ColaFlow.API/Program.cs b/colaflow-api/src/ColaFlow.API/Program.cs index f01e7cf..553a1cc 100644 --- a/colaflow-api/src/ColaFlow.API/Program.cs +++ b/colaflow-api/src/ColaFlow.API/Program.cs @@ -45,9 +45,16 @@ builder.Services.AddIssueManagementModule(builder.Configuration, builder.Environ builder.Services.AddIdentityApplication(); builder.Services.AddIdentityInfrastructure(builder.Configuration, builder.Environment); -// Register MCP Module +// Register MCP Module (Custom Implementation) builder.Services.AddMcpModule(builder.Configuration); +// ============================================ +// Register Microsoft MCP SDK (PoC - Phase 1) +// ============================================ +builder.Services.AddMcpServer() + .WithToolsFromAssembly() // Auto-discover tools with [McpServerToolType] attribute + .WithResourcesFromAssembly(); // Auto-discover resources with [McpServerResourceType] attribute + // Add Response Caching builder.Services.AddResponseCaching(); builder.Services.AddMemoryCache();