SShortSingh.
Back to feed

Guide: Building MCP Servers in C# and .NET 9 Using SDK, DI, and Native AOT

0
·1 views

Part 12 of a 15-part series on Model Context Protocol (MCP) focuses on the .NET tooling that simplifies building MCP servers in C#. The MCP C# SDK handles JSON-RPC framing, capability negotiation, and JSON Schema generation automatically, replacing error-prone hand-rolled code. Developers can use attributed classes and typed method signatures so the SDK auto-generates tool schemas, eliminating the need to maintain separate JSON Schema definitions. Dependency injection is fully supported, with the SDK resolving scoped tool instances per call from the app's existing DI container. The guide also covers hosting models, in-memory transport for unit testing, and Native AOT support for faster cold starts.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

How MCP and Zod Enable Dynamic Tool Discovery for Scalable AI Agents

Developers building AI agents have long relied on hardcoded tool definitions and static routing logic, an approach that becomes fragile as external APIs evolve or new microservices are introduced. The Model Context Protocol (MCP) offers an alternative by allowing agents to query external servers at runtime and dynamically discover available tools, much like microservice architectures use service registries. This decouples the LLM reasoning engine from its external capabilities, enabling updates without restarting the core application. Combining MCP with Zod runtime schema validation adds a critical safety layer, guarding against LLM hallucinations that could otherwise pass malformed or mistyped parameters to live systems. Together, these patterns allow engineers to build distributed, enterprise-grade AI agents in TypeScript that remain resilient as their tool ecosystems grow and change.

0
ProgrammingDEV Community ·

Developer runs self-trained neural network opponent entirely in-browser with no backend

A developer has released a browser version of their custom four-in-a-row board game featuring a self-trained neural network opponent that runs entirely on the player's device with no server, accounts, or external calls. The game uses a larger 9x8 grid instead of the classic 7x6, which nearly doubles the number of possible four-in-a-row lines and required training a dedicated model from scratch. The neural network is a policy and value model of just under one million parameters, exported as a 3.9 MB ONNX file and executed in the browser via ONNX Runtime Web. Four difficulty levels are powered by a single network with varying amounts of search, ranging from a shallow heuristic at beginner level to 256-simulation MCTS at grandmaster. The developer chose a single-threaded WebAssembly build to avoid complex cross-origin isolation headers required by shared hosting environments, achieving move times of around 120 milliseconds.

0
ProgrammingDEV Community ·

Rullst Claims to Be Rust's First True Full-Stack Framework, Rivaling Rails and Laravel

Rullst is a new Rust framework that builds on top of Axum to offer a batteries-included, full-stack development experience, according to a technical breakdown published on DEV Community. Unlike existing Rust web frameworks such as Axum, Actix-Web, and Rocket, which focus solely on HTTP and leave developers to assemble their own tooling, Rullst bundles an ORM, auth scaffolding, Stripe billing, background workers, an admin panel, a DB studio, and TypeScript SDK generation out of the box. The framework also differentiates itself from full-stack peers like Loco and Topcoat by adding Wasm Islands, Tauri-based desktop and mobile support, a zero-panics policy, and an AI context generator. Rullst positions itself as API-first, similar to Rails or Laravel, while still allowing integration with Rust frontend frameworks like Dioxus and Leptos. The project is available on GitHub and targets developers seeking a more complete, opinionated developer experience within the Rust ecosystem.

0
ProgrammingDEV Community ·

Rebuild or Refactor? A Structured Framework for Founders Facing Codebase Decisions

Growing tech products often reach a point where teams debate whether to rebuild their codebase from scratch or refactor the existing one, yet this critical decision is rarely made with a structured framework. Gut-driven choices frequently lead to costly mistakes — fixable codebases get expensively rebuilt, while fundamentally broken architectures receive ineffective incremental patches. The framework proposed treats the rebuild-vs-refactor question as a business decision rather than a technical or emotional one. A central criterion is distinguishing structural problems, such as flawed data models or incompatible technology choices, from incidental ones like duplicated logic or missing tests, since only the former truly warrants a rebuild. Psychological biases from original developers, inherited-code developers, and founders further cloud the decision, making an objective evaluation process essential.

Guide: Building MCP Servers in C# and .NET 9 Using SDK, DI, and Native AOT · ShortSingh