{"id":"f1485c8e-07b1-48a0-a5f3-2585437d330c","slug":"aimlapp","kind":"mcp","name":"AIMLAPP","summary":"","owner":"Songgumdhk","repoUrl":"https://github.com/Songgumdhk/AIMLAPP","license":"MIT","licenseTier":"permissive","trust":"community","stars":1,"match":null,"fewStars":true,"format":"mcp","createdAt":"2026-09-20T04:57:27.000Z","addedAt":"2026-10-21T21:57:01.554Z","logoUrl":"https://avatars.githubusercontent.com/u/122676226?v=4","linkOnly":false,"collection":null,"skillPath":null,"categories":["utilities"],"tags":[],"runtime":"binary","local":true,"cloudCapable":false,"cloudCapability":"unknown","cloudReadyOnPlatform":false,"needsApiKey":false,"reviewed":false,"syncedAt":"2026-10-26T09:20:21.902Z","sample":false,"url":"https://conduits.dev/tools/aimlapp","language":"C#","transports":["stdio"],"install":{},"requirements":{"env":[],"upstreamMayCharge":false},"tools":null,"readme":"# AIMLAPP: AI Engineering in .NET\n\nA hands-on .NET 10 console app for learning AI engineering. Each chapter pairs a written guide (`Learning/NN-*.md`) with a runnable demo, and the chapters build on each other: function calling first, then Semantic Kernel, advanced RAG, agentic workflows, evaluation, observability, production hardening, and local models.\n\nThe app also includes a small end-to-end sample: an interview-question service that stores embeddings in SQL Server's `VECTOR` type, finds the closest profile with cosine distance, and exposes the same data to AI clients through an MCP server.\n\n> **New to AI in C#? Start with the video.** The sample app (menu options 1–4) follows\n> [C# AI ML Tutorial for Beginners | Agents, RAG and MCP](https://www.youtube.com/watch?v=lEUPgdv0gY8)\n> by Shivprasad Koirala ([Questpond](https://www.youtube.com/@questpondvideos)): agents, vectors and\n> embeddings, RAG with SQL Server, sessions, tool calling, and MCP. Watch it, then run options 1–4 with\n> their guides. Each guide lists where the code here differs from the video.\n\n---\n\n## Contents\n\n- [What's inside](#whats-inside)\n- [Requirements](#requirements)\n- [Getting started](#getting-started)\n- [Configuration](#configuration)\n- [Database setup (options 2–4)](#database-setup-options-24)\n- [Running as an MCP server](#running-as-an-mcp-server)\n- [Project structure](#project-structure)\n- [Learning roadmap](#learning-roadmap)\n- [Security notes](#security-notes)\n- [License](#license)\n\n---\n\n## What's inside\n\nRun the app and pick a number from the menu:\n\n| Option | What it does | Guide |\n|---|---|---|\n| 1 | Chat with a simple agent (Microsoft Agent Framework) | [`01-ChatWithAgent.md`](Services/01-ChatWithAgent.md) |\n| 2 | Seed the `Experiences` table with embedded profiles | [`02-SeedExperiences.md`](Services/02-SeedExperiences.md) |\n| 3 | Interview flow: embed your description, vector-search SQL Server, generate questions | [`03-InterviewFlow.md`](Services/03-InterviewFlow.md) |\n| 4 | Run the MCP server over stdio | [`04-McpServer.md`](Mcp/04-McpServer.md) |\n| 5 | Chapter 1: Function calling without a framework | [`01-FunctionCalling.md`](Learning/01-FunctionCalling.md) |\n| 6 | Chapter 2: Semantic Kernel plugins and filters | [`02-SemanticKernel.md`](Learning/02-SemanticKernel.md) |\n| 7 | Chapter 3: Advanced RAG (chunking, hybrid search, RRF, reranking, query rewriting) | [`03-AdvancedRAG.md`](Learning/03-AdvancedRAG.md) |\n| 8 | Chapter 4: Agentic workflows (planning, state, memory, human-in-the-loop, multi-agent) | [`04-AgenticWorkflows.md`](Learning/04-AgenticWorkflows.md) |\n| 9 | Chapter 5: AI evaluation (retrieval metrics, hallucination checks, LLM-as-judge) | [`05-AIEvaluation.md`](Learning/05-AIEvaluation.md) ([short version](Learning/05-AIEvaluation-Simple.md)) |\n| 10 | Chapter 6: Observability (tracing, token usage, latency, cost) | [`06-Observability.md`](Learning/06-Observability.md) |\n| 11 | Chapter 7: Production AI (prompt injection, guardrails, caching, rate limiting, deployment) | [`07-ProductionAI.md`](Learning/07-ProductionAI.md) |\n| 12 | Chapter 8: Local AI (Ollama, ONNX-style inference, local embeddings) | [`08-LocalAI.md`](Learning/08-LocalAI.md) |\n\nOptions 1–4 follow the [Agents, RAG and MCP video](https://www.youtube.com/watch?v=lEUPgdv0gY8) in order: first agent, embeddings, RAG, then MCP. Options 5–12 go deeper, one topic per chapter.\n\nOptions 1 and 5–11 need only an OpenAI API key. Options 2–4 also need SQL Server. Option 12 needs neither; Ollama is optional.\n\n---\n\n## Requirements\n\n- [.NET 10 SDK](https://dotnet.microsoft.com/download)\n- An [OpenAI API key](https://platform.openai.com/api-keys) for options 1–11\n- SQL Server 2025 or Azure SQL Database (anything with the `VECTOR` data type) for options 2–4\n- Optional: [Ollama](https://ollama.com) for the live parts of Chapter 8\n\nMain packages: `OpenAI`, `Microsoft.Extensions.AI`, `Microsoft.Agents.AI`, `Microsoft.SemanticKernel`, `Microsoft.EntityFrameworkCore.SqlServer`, `ModelContextProtocol`.\n\n---\n\n## Getting started\n\n```bash\ngit clone https://github.com/Songgumdhk/AIMLAPP.git\ncd AIMLAPP\n```\n\nCreate your local secrets file from the template. This file is gitignored.\n\n```bash\n# macOS / Linux\ncp appsettings.Local.example.json appsettings.Local.json\n\n# Windows (PowerShell)\nCopy-Item appsettings.Local.example.json appsettings.Local.json\n```\n\nFill in your values:\n\n```json\n{\n  \"ConnectionStrings\": {\n    \"AimlDatabase\": \"Server=YOUR_SERVER;Database=aimlDatabase;User Id=YOUR_USER;Password=YOUR_PASSWORD;TrustServerCertificate=True;\"\n  },\n  \"OpenAI\": {\n    \"ApiKey\": \"sk-your-openai-key\"\n  }\n}\n```\n\nThen run:\n\n```bash\ndotnet run\n```\n\nIf you only want the Local AI chapter, you can skip the secrets file and pick option **12**.\n\n---\n\n## Configuration\n\nAll settings live in [`appsettings.json`](appsettings.json) and are loaded through the typed `AppSettings` class in [`Configuration/AppSettings.cs`](Configuration/AppSettings.cs). Every AI-related value (models, embedding model and dimensions, temperature, token limits, retrieval and agent limits, pricing) comes from there, so you can change models without touching code.\n\nSources are applied in this order, and later ones win:\n\n1. `appsettings.json` (committed, no secrets)\n2. `appsettings.Local.json` (gitignored, your secrets and personal overrides)\n3. Environment variables, using `__` for nesting, for example `OpenAI__ChatModel=gpt-4o-mini` or `ConnectionStrings__AimlDatabase=...`\n4. `OPENAI_API_KEY`, which is also accepted for the API key\n\n### Sections\n\n| Section | What it controls |\n|---|---|\n| `ConnectionStrings:AimlDatabase` | SQL Server connection for options 2–4 (keep it in `appsettings.Local.json`) |\n| `OpenAI` | `ApiKey`, `ChatModel`, `SmallChatModel`, `EmbeddingModel`, `EmbeddingDimensions`, `Temperature` |\n| `Ollama` | `BaseUrl`, `ChatModel`, `EmbeddingModel`, `RequestTimeoutSeconds` |\n| `Pricing` | Per-model input/output price per 1M tokens, used by the Observability cost view |\n| `FunctionCalling` | `MaxTurns` safety cap for the tool loop |\n| `Rag` | `TopK`, `RerankCandidates`, `RrfK`, `QueryRewriteCount`, chunk size, overlap, sentences per chunk |\n| `AgenticWorkflows` | `ReviewPassScore`, `MaxRevisions`, `MaxNodeVisits`, `MaxAgentHops` |\n| `Observability` | Output-token caps for the traced calls |\n| `ProductionAi` | `MaxOutputTokens`, `GuardrailsEnabled`, `RequestsPerMinute`, `CacheMaxEntries`, `LogPrompts` |\n\nA few things to know:\n\n- `SmallChatModel` is used by the Observability and Production AI chapters to keep repeated runs cheap. Everything else uses `ChatModel`.\n- If you change `EmbeddingModel`, update `EmbeddingDimensions` to match. The SQL column is `VECTOR(N)`, so you'll also need to recreate the table and re-seed.\n- If you switch to a model that isn't listed under `Pricing`, add a price entry or the Observability cost view will stop with an error telling you to.\n- The Production AI chapter checks its own config at startup and refuses to run if guardrails are off, the rate limit is zero, or prompt logging is on.\n\n---\n\n## Database setup (options 2–4)\n\nCreate the table once. The vector size must match `OpenAI:EmbeddingDimensions` (1536 for `text-embedding-3-small`).\n\n```sql\nCREATE TABLE Experiences (\n    Id          INT IDENTITY(1,1) PRIMARY KEY,\n    Experience  NVARCHAR(MAX) NOT NULL,\n    ExpVector   VECTOR(1536)  NULL,\n    Questions   NVARCHAR(MAX) NULL\n);\n```\n\nThen:\n\n1. Run option **2** to embed and insert the sample profiles.\n2. Run option **3** and describe yourself, for example \"senior .NET developer with 6 years\". The app embeds your text, finds the closest profile with `VECTOR_DISTANCE('cosine', ...)`, and generates five interview questions.\n\nThe step-by-step guides for these options are [`02-SeedExperiences.md`](Services/02-SeedExperiences.md) and [`03-InterviewFlow.md`](Services/03-InterviewFlow.md).\n\n---\n\n## Running as an MCP server\n\nThe app can run as a [Model Context Protocol](https://modelcontextprotocol.io) server over stdio, which lets MCP clients such as Cursor, Claude Desktop, or VS Code query the `Experiences` table.\n\n| Tool | Description |\n|---|---|\n| `find_matching_experience` | Embeds a free-form description and returns the closest profile and its questions |\n| `list_experiences` | Lists every seeded profile |\n| `get_experience_by_id` | Returns one profile by id |\n\nBuild in Release first. If you open this folder in Cursor, the included [`.cursor/mcp.json`](.cursor/mcp.json) picks the server up automatically. For other clients, point them at the project:\n\n```bash\ndotnet build -c Release\n```\n\n```json\n{\n  \"mcpServers\": {\n    \"aiml-experiences\": {\n      \"command\": \"dotnet\",\n      \"args\": [\"run\", \"--project\", \"/absolute/path/to/AIMLAPP/AIMLAPP.csproj\", \"-c\", \"Release\", \"--no-build\", \"--\", \"--mcp\"]\n    }\n  }\n}\n```\n\nIn MCP mode the app writes nothing to stdout except JSON-RPC, and all logs go to stderr. It reads the same `appsettings*.json` files from the build output folder. See [`04-McpServer.md`](Mcp/04-McpServer.md) for how it works, client setup for Cursor, Claude Desktop and VS Code, testing with MCP Inspector, and troubleshooting.\n\n---\n\n## Project structure\n\n```\nAIMLAPP/\n├── Program.cs                  Menu and entry point (--mcp for MCP mode)\n├── appsettings.json            All AI settings (committed, no secrets)\n├── appsettings.Local.example.json  Template for your gitignored secrets file\n├── Configuration/AppSettings.cs    Typed settings and loader\n├── ConsoleUi/AppBanner.cs      ASCII banner and startup menu\n├── Data/AppDbContext.cs        EF Core context with a SQL Server VECTOR column\n├── Models/Experience.cs        Experiences table entity\n├── Services/                   Agent chat, seeder, interview flow + guides (options 1–3)\n├── Mcp/                        MCP server host, tools + guide (option 4)\n└── Learning/\n    ├── 01-FunctionCalling.md … 08-LocalAI.md   Chapter guides\n    ├── FunctionCallingDemo/    Chapter 1\n    ├── SemanticKernelDemo/     Chapter 2\n    ├── AdvancedRagDemo/        Chapter 3\n    ├── AgenticWorkflowsDemo/   Chapter 4\n    ├── AiEvaluationDemo/       Chapter 5\n    ├── ObservabilityDemo/      Chapter 6\n    ├── ProductionAiDemo/       Chapter 7\n    └── LocalAiDemo/            Chapter 8\n```\n\nEach demo folder has an entry-point class, `<Name>Demo.cs`, with a header comment mapping its subfolders to sections of the chapter guide.\n\n---\n\n## Learning roadmap\n\nStart with the sample app (menu options 1–4). It covers the basics every chapter assumes: calling an LLM, what an agent is, embeddings, vector search, basic RAG, and MCP. Then work through the chapters (options 5–12) in order.\n\n```\nSTART HERE: the sample app (options 1–4, follows the video)\n\nOption 1. Chat with agent ─────── your first agent: model, instructions, streaming\n        │\nOption 2. Seed Experiences ────── embeddings, cosine similarity, SQL Server VECTOR column\n        │\nOption 3. Run interview ───────── basic RAG: embed → vector search → grounded agent\n        │\nOption 4. MCP server ──────────── expose your data as tools to Cursor, Claude, VS Code\n        │\n        ▼\nTHE CHAPTERS (options 5–12)\n\n1. Function Calling / Tool Calling\n        │\n2. Semantic Kernel\n        │\n3. Advanced RAG ──────── chunking, hybrid search, reranking, metadata filtering, query rewriting\n        │\n4. Agentic Workflows ─── planning, state, memory, human-in-the-loop, multi-agent\n        │\n5. AI Evaluation ─────── retrieval metrics, RAG evaluation, hallucination detection, LLM-as-judge\n        │\n6. Observability ─────── tracing, token usage, latency, cost\n        │\n7. Production AI ─────── security, guardrails, caching, rate limiting, deployment\n        │\n8. Local AI ──────────── Ollama, ONNX, local embeddings, local LLMs\n```\n\n### Start here: options 1–4\n\nA small interview-question app built step by step, following the [Agents, RAG and MCP video](https://www.youtube.com/watch?v=lEUPgdv0gY8):\n\n- **Option 1, Chat with agent** ([guide](Services/01-ChatWithAgent.md)): the smallest useful agent, built from one model, one instruction and streamed output. It also shows why agents are stateless and why they give generic answers without your own data.\n- **Option 2, Seed Experiences table** ([guide](Services/02-SeedExperiences.md)): turn profile descriptions into embeddings and store them in SQL Server's `VECTOR` column.\n- **Option 3, Run interview** ([guide](Services/03-InterviewFlow.md)): Retrieve → Augment → Generate. Embed the user's description, find the closest profile by cosine distance, and have the agent write questions grounded in it.\n- **Option 4, Run MCP server** ([guide](Mcp/04-McpServer.md)): publish the same data as MCP tools, so assistants in Cursor, Claude Desktop or VS Code can query it.\n\nOptions 2–4 need SQL Server; see [Database setup](#database-setup-options-24).\n\n### 1. Function calling\n\nLearn the raw mechanics before any framework hides them: tool schemas, how the model picks a tool, arguments, multiple and parallel tool calls, tool errors, retries, and human approval for dangerous actions. The demo runs the tool loop by hand with a `MaxTurns` safety cap.\n\n### 2. Semantic Kernel\n\nThe same tool loop, now handled by a framework built for .NET. Plugins are plain C# classes, filters act as middleware (logging, approval), and `FunctionChoiceBehavior.Auto()` replaces the hand-written loop from Chapter 1. Switching providers is a one-line change.\n\n```\nYour .NET app → Semantic Kernel → LLM → Plugins → Database / APIs / RAG / MCP\n```\n\n### 3. Advanced RAG\n\nGo past \"embed, cosine similarity, stuff into prompt\". The demo lets you compare chunking strategies and eight retrieval modes over one corpus:\n\n```\nQuery → Rewrite → Hybrid search (vector + keyword, merged with RRF) → Metadata filter → LLM rerank → Top chunks → Answer with citations\n```\n\n### 4. Agentic workflows\n\nHow do you design an agent system that is reliable, not just clever? The demo covers planning, explicit state and a state machine, conditional routing, persisted runs, memory, a human approval gate, and a supervisor coordinating specialist agents. Hard caps on revisions, node visits, and agent hops stop runaway loops.\n\nWorth reading alongside: LangGraph's concepts translate directly to .NET, even if you never write Python in production.\n\n### 5. AI evaluation\n\nIf you can't measure it, you can't tell whether a change helped. The demo freezes a labeled question set and scores three retrievers (naive, keyword, vector) with precision, recall, and MRR. It then checks answers for groundedness, computes a claim-level hallucination rate, and runs an LLM judge, including a pass that swaps answer order to expose position bias.\n\n```\nQuestion → Were the right documents retrieved? → Did the LLM use them? → Was the answer actually supported?\n```\n\n### 6. Observability\n\nOne handbook question is recorded as a trace: embed, retrieve, tool call, chat completion. The demo prints the span tree, input and output tokens per step, which step took the time, and what it cost. Comparing a short prompt with a padded one shows why stuffing context moves the bill.\n\n### 7. Production AI\n\nWhat changes once real users, real documents, and a real bill are involved:\n\n- **Security:** direct and indirect prompt injection, data leakage, tool authorization, PII redaction, secrets management\n- **Guardrails:** check the question before the model sees it, and the answer before the user does\n- **Caching:** the same question shouldn't pay for a second model call; bound the cache by size and time, and never cache personal data\n- **Rate limiting:** stop a burst before it becomes a bill\n- **Deployment:** read config from the environment, refuse to start with unsafe settings, never print the API key\n\nOptions 1–5 in the demo don't call the model at all. Option 6 runs the full guarded pipeline and can make one real call.\n\n### 8. Local AI\n\nRun models on your own machine: Ollama, GGUF and ONNX formats, quantization (Q4), CPU vs GPU inference, local embeddings, and local RAG. The demo runs a tiny model from a file, compares bag-of-words vectors with `nomic-embed-text`, and chats with a local `llama3.2` if Ollama is running.\n\n```bash\nollama pull llama3.2\nollama pull nomic-embed-text\n```\n\n### What's next: multi-agent systems\n\nOnce single-agent workflows feel solid, look at supervisor agents, specialized agents, shared state, handoffs, parallel agents, and evaluating agent systems. Chapter 4 includes a small supervisor example as a starting point.\n\n### Further learning\n\n- [*C# AI ML Tutorial for Beginners | Agents, RAG and MCP*](https://www.youtube.com/watch?v=lEUPgdv0gY8) (YouTube, Questpond): the walkthrough behind options 1–4. It covers models vs LLMs, Microsoft Agent Framework agents, embeddings and cosine similarity, RAG with SQL Server 2025, sessions, tool calling, and MCP.\n- [*Forward Deployed Engineer Full Course | GenAI Full Course*](https://www.youtube.com/watch?v=kBM5UXRbo3U&list=PLWSlr9idVBc0) (YouTube playlist, Coder Army): a multi-part GenAI course, framed around the Forward Deployed Engineer role. Good for broadening beyond .NET.\n- [*Attention Is All You Need*](https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf) (Vaswani et al., NeurIPS 2017, research paper): the paper that introduced the **Transformer**, the architecture behind GPT, Claude, Gemini, Llama and modern embedding models. Read it to see what's inside the models every chapter calls. Sections 3.2 (attention) and 3.5 (positional encoding) are the core ideas.\n- *Develop Single Agent .NET Applications Using Semantic Kernel* (Udemy): Semantic Kernel, RAG, MCP, plugins, local models with ONNX, Ollama, and Hugging Face\n- *Semantic Kernel for .NET: Plugins, Agents & RAG* (Udemy): plugins, automatic function invocation, chat history, embeddings, RAG\n- *Agentic AI Engineering with LangChain & LangGraph* (Udemy): LangGraph, MCP, memory, tool calling, and production agent patterns\n\n---\n\n## Security notes\n\n- **Never commit secrets.** API keys and connection strings belong in `appsettings.Local.json` (gitignored) or environment variables. `appsettings.json` ships with empty values on purpose.\n- **Watch what you spend.** Most demos call OpenAI. The function-calling loop, agent workflows, and RAG pipeline all have caps configured in `appsettings.json`, but a long session still costs money.\n- **The tools are fake.** Chapter 1 and 2 tools such as \"delete record\" and \"send email\" only print what they would do. They exist to teach approval flows.\n- **Demo data is fictional.** The \"Acme\" handbook, employees, and emails in the sample corpora are made up.\n\n---\n\n## License\n\n[MIT](LICENSE)\n"}