BLOG

AI engineering in .NET

Short, practical write-ups on building AI features in C#. No roundups, no hype.

Prompt Injection Through Tool Results: a user asks an agent to show the latest ticket, and the get_ticket tool result contains an injected instruction to reset all users' passwords, with four defenses listed below.
MCP

Prompt Injection Through Tool Results

Text your tools return can carry instructions the model may follow. Why you can't filter that away, and how to design a C# MCP server so it can't do much harm.

5 min readRead
Securing a Remote MCP Server: an MCP client connected to an MCP server through a lock, with authentication, authorization, transport security and best practices.
MCP

Securing a Remote MCP Server

Lock down a remote C# MCP server with ASP.NET Core: JWT and OAuth metadata, role-based tools, per-user data access, rate limits and an audit trail.

5 min readRead
Stateless vs Stateful MCP Servers over HTTP: a stateless server with no server-side state next to a stateful server that keeps session context, with MCP over HTTP in the middle.
MCP

Stateless vs Stateful MCP Servers over HTTP

MCP C# SDK 2.0 made HTTP servers stateless by default. What that changes, how to keep state across tool calls anyway, and when to opt back into sessions.

5 min readRead
Return Errors the Model Can Recover From: a failed order lookup returning an order_not_found error with a retryable flag, after which the model recovers with the right order.
MCP

Return Errors the Model Can Recover From

How the MCP C# SDK turns exceptions into tool errors, why most of them reach the model as a useless generic message, and how to write errors it can act on.

4 min readRead
Keep Prompts Out of Your C# Code: a hardcoded prompt string crossed out, and a prompt.md file with a name header loaded by a prompt provider.
PROMPTS

Keep Prompts Out of Your C# Code

Store LLM prompts as files, version them automatically with a content hash, and log which prompt produced every answer. A simple pattern for .NET apps.

4 min readRead