Blog
Posts and series that take software and IT from the basics to advanced topics: from programming languages and databases to architecture and AI.
Choosing a Vector Database: pgvector, SQL Server 2025, Qdrant, Azure AI Search and Elasticsearch
Try your existing database's vector support first, and tune the ANN index by measuring recall on your own data. On a 100,000-vector pgvector table exact search took 237 ms and HNSW 1 ms, but recall stayed at 0.83 with the default ef_search; with a filter, HNSW forced onto the index returned zero rows while an iterative scan found 10. HNSW, IVFFlat, DiskANN, choosing a metric, and five options compared.
Chunking Strategies: Token-Based, Header-Based, Semantic, Overlap and Contextual Retrieval
There is no single best chunk size; choose a strategy by measuring recall and the context budget together. On the same 30 Turkish questions, 64-token windows ranked the right section first 19 times and header-based chunks 16 times; 256 tokens raised recall@5 to 28 but grew the prompt to 1,122 tokens. We compare fixed size, overlap, semantic, parent-child and Contextual Retrieval with gemma3:4b using real measurements.
Document Ingestion: Clean Text, Metadata and Incremental Updates from PDF, HTML and Markdown
RAG quality starts at ingestion: a "fi" ligature from a PDF made Contains("fiyat") return false, a page number landed in the middle of a section, and an HTML menu leaked into a chunk. Clean text, metadata on every chunk, a pipeline with partial success using Microsoft.Extensions.DataIngestion (preview), incremental updates with content hashes, and removing deleted documents from the index.
Choosing an Embedding Model: Dimensions, Multilinguality, Turkish and Cost
Choose an embedding model by measuring it in your own language on your own question set, not by the leaderboard average: on the same content nomic-embed-text ranked the right section first for 26 of 30 questions in English but only 16 in Turkish. We measure with recall@k and MRR and look at prefixes, Matryoshka dimensions, storage, silent truncation and the risk of old vectors after a model switch, with real output.
Production RAG Architecture: Ingestion and Query Pipelines, and Why Minimal RAG Breaks
On a real document set, minimal RAG answered only 20 of 30 questions correctly; most failures come from retrieval, chunking, stale data and unauthorized documents rather than the model. Using Bookstore's Turkish documents we classify the failures, separate the ingestion and query pipelines, and build a query pipeline skeleton with a permission filter and a trace log.
Evaluating Agents: Trajectory, Tool Call Accuracy, Task Adherence and Production Monitoring
To evaluate an agent you measure the outcome, the path it took (trajectory) and the cost separately, and report a success rate by running the same scenario N times with fake tools; LLM-as-judge comes only after code checks, with its reasoning read. We look at our own trajectory recording, deterministic scenarios, real results of Microsoft.Extensions.AI.Evaluation's agent evaluators with local models, and the path from OpenTelemetry spans to a regression set.
MCP and Agent Security: Tool Poisoning, Confused Deputy, Least Privilege and Sandboxing
MCP and agent security rests not on the model behaving well but on controls independent of it: pinning untrusted tool definitions, accepting tokens only for your own server and never forwarding them, binding destructive tools to a separate scope and approval, and restricting network egress. With real output we cover the spec's security guidance, per-tool authorization with [Authorize], an audit log that also captures denied attempts, and a stdio server running in a container without a network.
Writing an MCP Client: McpClient, Connecting Tools to IChatClient and Agents, Elicitation
In C# you create an MCP client with McpClient.CreateAsync over a stdio or HTTP transport; since the McpClientTool returned by ListToolsAsync is an AIFunction, it can go straight into IChatClient and a MAF agent. We separate same-named tools from two servers with prefixes, pin tool definitions with fingerprints, and see real tool calls with a local qwen3:4b and how the SDK handles the server's confirmation request through MRTR rounds.
Building an MCP Server in TypeScript: Zod Schemas, Tool/Resource Registration and Node.js
For an MCP server in TypeScript you pick the v2 SDK (@modelcontextprotocol/server 2.4.0), which supports 2026-07-28, register tools with Zod 4 schemas and serve them over stdio and Streamable HTTP with serveStdio and createMcpHandler. Comparing the same Bookstore server with its C# version, we see with real output how schemas give different answers to the same input, the Zod 3 incompatibility, distribution with npx and the supply chain risk.
Remote MCP Servers in ASP.NET Core: Streamable HTTP, Stateless Mode, State Handles and Authorization
In ASP.NET Core you build a remote MCP server with WithHttpTransport and MapMcp, run it in stateless mode and protect it as an OAuth resource server: tokens must be issued for this server, and state handles must be bound to the user. With curl output we look at protected resource metadata, the audience error, the cost of statelessness with two instances, asking for confirmation via MRTR with a signed requestState, and Mcp-Method/Mcp-Name header validation.
Building an MCP Server in C#: ModelContextProtocol SDK 2.x, [McpServerTool] and stdio
You build an MCP server in C# with the ModelContextProtocol 2.x package, the Generic Host and the [McpServerTool] attributes; on the stdio transport, logs must go to stderr. We build the Bookstore tools with services from DI, structured output, resources and prompts, test them with MCP Inspector, and see with real output how polluting stdout turns into a one-minute timeout and how culture settings corrupt tool output.
What Is the Model Context Protocol? Hosts, Clients, Servers and the 2026-07-28 Spec
MCP is a JSON-RPC based protocol that lets you write tools and data sources once as a server and connect them to any AI application through a standard client. We watch the wire with hand-written JSON messages to see the host, client and server roles, the tools/resources/prompts primitives, the stdio and Streamable HTTP transports, and the 2026-07-28 revision that removed the handshake.