A modular, production-grade framework for building AI-powered skills in .NET using the Model Context Protocol (MCP).
The .NET MCP Skill Engine provides a highly extensible, middle-ware based orchestration system for AI agents. It allows you to build "skills" (intelligent tools) once and expose them seamlessly via the Model Context Protocol to any AI consumer (Claude, ChatGPT, etc.).
- Middleware Execution Pipeline: Intercept and augment skill requests with validation, logging, and caching.
- Enterprise-Grade Observability: Native
ActivitySourceintegration for full-stack OpenTelemetry tracing. - Lean & High Performance: Optimized with
LoggerMessagesource generators and minimalist dependencies. - Rules Engine: Flexible policy-based validation for skill invocation.
- Built-in Code Intelligence: A collection of pre-built skills for scaffolding, reviews, and diagnostics.
Add the Skill Engine to your service collection in Program.cs:
using SkillEngine.Core;
var builder = WebApplication.CreateBuilder(args);
// Register Core Engine
builder.Services.AddSkillEngine(options => {
options.MaxParameters = 15;
options.DeniedTools = ["experimental-tool"];
});
// Register Built-in Skills
builder.Services.AddSkill<ScaffoldSkill>()
.AddSkill<CodeReviewSkill>()
.AddSkill<ArchitectureAdvisorSkill>();
// (Optional) Add custom middleware
builder.Services.AddSkillMiddleware<PerformanceMetricsMiddleware>();Inject SkillOrchestrator and execute tools:
public async Task<string> HandleRequest(SkillOrchestrator orchestrator, string toolName)
{
var request = new SkillRequest { ToolName = toolName };
var result = await orchestrator.InvokeAsync(request);
return result.IsSuccess ? result.Content! : $"Error: {result.ErrorMessage}";
}The engine follows Clean Architecture principles, ensuring the core logic is divorced from external protocols like MCP or HTTP.
graph TD
Consumer[AI Agent / IDE] --> MCP[MCP Endpoints]
MCP --> Orchestrator[Skill Orchestrator]
subgraph "Execution Pipeline"
Orchestrator --> Middleware1[Validation Middleware]
Middleware1 --> Middleware2[Custom Middleware]
Middleware2 --> Skill[Target Skill]
end
subgraph "Domain Core"
Skill --> Rules[Rule Engine]
Skill --> Context[Context Builder]
end
- Observability: Uses
System.Diagnostics.Activityto provide detailed spans during skill execution. - Resilience: Middlewares can be used to implement Retry and Circuit Breaker patterns.
- Decoupling: The
ISkillRouterabstracts skill discovery, allowing for dynamic loading of capabilities.
graph LR
Core[SkillEngine.Core] --- Tools[SkillEngine.Tools]
Core --- Mcp[SkillEngine.Mcp]
Tools --- Mcp
Core -.-> Examples[examples]
Tools -.-> Examples
Mcp -.-> Examples
Core -.-> Knowledge[knowledge base]
style Core fill:#f9f,stroke:#333,stroke-width:2px
style Mcp fill:#bbf,stroke:#333,stroke-width:2px
style Tools fill:#dfd,stroke:#333,stroke-width:2px
| Skill | Description |
|---|---|
scaffold |
Generates Clean Architecture, CQRS, and CRUD boilerplate. |
review-code |
Expert-level security and performance code review. |
explain-error |
Diagnostic tool for explaining complex .NET exceptions. |
advise-architecture |
Tailored advice on patterns (MVC, Hexagonal, etc.). |
- Middleware Pipeline Architecture
- OpenTelemetry / Tracing support
- Initial Code Intelligence tools
- Multi-format Prompt Templating (Scriban)
- Distributed Caching Middleware
- Auto-discovery of Skill DLLs
- MCP streaming support
We welcome contributions! Please see our Developer Guide for information on how to add new skills or middlewares.
If you're building agentic systems with .NET, I'd love to connect!
- 💼 LinkedIn: Yassine Zakhama
- 📧 Email: zakhamayassine@gmail.com