Dotnet ai
AI/ML integration patterns for .NET. Covers MCP server/client creation and debugging, LLM integration (Semantic Kernel, OpenAI, Azure AI), RAG pipelines, ML.NET model training/inference, and AI technology selection. Load when building AI features in .NET, creating MCP servers, integrating LLMs, or evaluating AI frameworks. Synthesized from dotnet/skills dotnet-ai plugin + dotnet-artisan Semantic Kernel references.From its SKILL.md
npx -y skills add fenzel999/dotnet-artisan --skill dotnet-aiAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 7 stars7 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
3.7 KB, as published. Nobody here has run it
dotnet-ai
Core Principles
-
MCP for tool exposure — Use Model Context Protocol (MCP) to expose .NET capabilities to AI agents. MCP is the standard protocol — prefer it over custom REST APIs for agent-tool communication.
-
Semantic Kernel for orchestration — Use Microsoft.SemanticKernel for multi-step AI workflows (planning, function calling, memory). Use raw HttpClient + OpenAI SDK for simple single-call scenarios.
-
RAG = Retrieval + Generation — The retrieval side matters more than the generation side. Invest in chunking strategy, embedding quality, and hybrid search (vector + keyword) before tuning prompts.
-
ML.NET for production ML — When you need a model that runs in-process without external API calls (cost, latency, offline), ML.NET is the answer. Otherwise, call an external model API.
Technology Selection
| Scenario | Recommendation |
|---|---|
| Expose .NET tools to AI agents | MCP server (ModelContextProtocol) |
| Multi-step AI workflows | Semantic Kernel |
| Simple LLM call | HttpClient + OpenAI SDK |
| In-process ML inference | ML.NET |
| Vector search | Microsoft.SemanticKernel.Connectors.* or Qdrant |
| RAG pipeline | Semantic Kernel + vector DB |
| AI agent with tools | Microsoft.Agents.AI |
MCP (Model Context Protocol)
Creating an MCP Server
// Minimal MCP server exposing a .NET tool
#:sdk Microsoft.NET.Sdk.Web
#:package ModelContextProtocol
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddMcpServer();
var app = builder.Build();
app.MapMcpTool("get_weather", async (string city) =>
{
// Your .NET logic here
return new { City = city, Temp = 22.5, Condition = "Sunny" };
});
app.Run();
MCP Debugging
- Test with
mcp-inspectorCLI tool - Use
McpServerOptions.Validate()for startup validation - Log all tool invocations at Debug level for troubleshooting
RAG Pipeline Pattern
- Document ingestion — Chunk documents, generate embeddings (Azure OpenAI / OpenAI)
- Storage — Store chunks + vectors in Qdrant, Azure AI Search, or pgvector
- Retrieval — Hybrid search: vector similarity + keyword (BM25)
- Generation — Send retrieved context + user query to LLM
// Semantic Kernel RAG example
var kernel = Kernel.CreateBuilder()
.AddAzureOpenAIChatCompletion(deploymentName, endpoint, apiKey)
.AddQdrantVectorStore(host)
.Build();
// Query → search → generate
var response = await kernel.InvokePromptAsync(
"Answer based on: {{$context}} \n Question: {{$question}}",
new() { ["context"] = searchResults, ["question"] = userQuery });
Anti-patterns
- MCP for simple CRUD — If you're not exposing tools to AI agents, use minimal APIs, not MCP
- RAG without hybrid search — Vector-only retrieval misses exact keyword matches
- Embedding entire documents — Chunk first; large embeddings lose semantic precision
- Ignoring token costs — Cache embeddings, use streaming responses, set max_tokens
Out of Scope
- General ASP.NET Core API development (see dotnet-api)
- Frontend UI frameworks or rendering patterns (see dotnet-ui)
- CI/CD pipeline configuration (see dotnet-devops)