Reusing Your Existing .NET REST APIs for AI with MCP

This blog is presented as a part of C# Advent 2025. Follow the link to check out the rest of the excellent C# and .NET content coming out in 2 blogs per day between December 1 and 25.

Many organizations today are looking to integrate AI into their existing infrastructure without completely rewriting everything. In this blog post, I’ll walk you through the process of adding MCP (Model Context Protocol) capabilities to your current REST APIs built in .NET, enabling seamless interaction between AI systems and your backend data and applications.

What is MCP?

MCP is an open-source, standardized protocol introduced by Anthropic. It was designed to enable AI models (like chatbots or large language models – LLMs) to interact with external systems. One of its core features is bidirectional communication, allowing AI to not only retrieve data but also perform actions, such as making updates to those systems.

The main advantage of MCP is that it bridges AI systems (such as ChatGPT or Claude) and backend systems, like databases or third-party services, creating a flexible, two-way data flow. If you’re looking to add AI functionality to your application without a complete overhaul, MCP provides a simple and effective solution.

Why Use MCP with Your .NET APIs?

At Trailhead, we often help clients modernize their tech stacks, particularly around .NET. Many of these clients already have RESTful .NET APIs implemented using ASP.NET. However, they often want to add AI capabilities without starting from scratch. This is where MCP comes in.

The goal is to integrate AI models into the APIs, enabling them to interact with data stored in existing databases or other systems. This allows AI agents to do almost anything, such as:

  • Retrieve data (e.g., CRM data, sales figures)
  • Update data (e.g., completing tasks or making notes)
  • Provide actionable insights (e.g., sending proactive alerts about key performance indicators).

These integrations can automate mundane tasks, optimize decision-making, and provide real-time insights based on your data. And the best part? All of this can be done without rewriting your entire codebase.

How Does MCP Work with .NET APIs?

If you’re already familiar with RESTful APIs, you might be wondering how MCP differs. While REST is a widely-used architecture for inter-service communication, MCP is optimized for AI-to-system communication.

Here’s a comparison between the two:

Audience:

  • REST: Primarily used by developers for service integrations.
  • MCP: Designed for AI models and agents to interact with backend systems. It’s built for easier integration with non-technical users and systems.

Transport:

  • REST: Communication typically happens over HTTP, using methods like GET, POST, PUT, DELETE.
  • MCP: Can use standard I/O for local communication, or streamable HTTP for remote communication, which supports real-time data exchange.

Discoverability:

  • REST: Requires tools like OpenAPI (Swagger) for documentation.
  • MCP: Automatically discovers available tools, resources, and prompts at runtime, making it more dynamic.

Use Case:

  • REST: Great for server-to-server or server-to-client communication.
  • MCP: Best suited for integrating AI agents with backend systems like CRMs, databases, or even third-party services.

Adding MCP to Your .NET API

To demonstrate how MCP can be integrated with your existing .NET APIs, let’s go through the steps involved. We will use .NET 10 and the MCP C# SDK to set up a basic MCP server.

Step 1: Install MCP SDK and Set Up the Server

Start by installing the MCP SDK in your .NET project. The SDK provides all the necessary tools to create a server that can interact with AI models via MCP.

dotnet add package ModelContextProtocol

NOTE: At the time of the writing of this blog, MCP C# SDK is in preview, so you’ll also need the --version 0.4.1-preview.1 flag.

Now, in your Program.cs, add the following code to set up the MCP server:

builder.Services.AddMcpServer()
    .AddTransport<HttpTransport>() // For remote communication
    .ScanAssemblyForTools(); // Auto-discover tools in your project

Step 2: Create MCP Tools for Your API Endpoints

Next, we define the MCP tools that map to our existing REST API endpoints. This is done by adding specific attributes to the methods that will expose functionality to the AI system.

For example, a To-Do API endpoint could be mapped as an MCP tool:

[McpTool("Get To-Dos")]
public async Task<IEnumerable<ToDo>> GetToDos()
{
    // Logic to fetch to-dos from database
}

Step 3: Integrate with AI Models

Now that your MCP server is set up, we can integrate it with AI models, like Claude or ChatGPT. When an AI agent asks for a task (like checking the to-do list), it will use the MCP protocol to query your server.

For instance, using an AI like Claude, you can programmatically retrieve data from your to-do list:

AIModelRequest request = new AIModelRequest("Get To-Dos");
var response = await aiModel.ExecuteRequest(request);

This request will retrieve data via the MCP server, allowing the AI model to act upon it, like marking tasks as complete.

To view an entire working to-do integration in C#, check out the code from my talk on this same topic.

The Future of MCP and AI Integrations

As more systems adopt MCP, we expect to see increased collaboration between AI models and backend systems. MCP makes it easier for organizations to “AI-enable” their applications without the need for a full-scale rewrite. It helps create a future-proof architecture that can scale with new technological advancements.

Furthermore, if you’re hosting your .NET APIs in Azure, you can use Azure API Management to create an MCP wrapper around your existing REST endpoints. This can be done without writing any code, enabling faster AI integrations.

Conclusion

Integrating MCP with your .NET REST APIs brings powerful AI capabilities to your existing systems. Whether you’re building a chatbot, automating customer support, or proactively notifying users about key performance indicators, MCP provides the connectivity needed to make it happen seamlessly.

If you’d like to use the MCP C# SDK to add AI-driven functionality to your .NET apps, contact us at Trailhead and we’ll show you how to get started.

Picture of J. Tower

J. Tower

Jonathan, or J. as he's known to friends, is a husband, father, and founding partner of Trailhead Technology Partners, a custom software consulting company with employees across the U.S., Europe, and South America. He is a 12-time recipient of the Microsoft MVP award for his work with .NET, a frequent speaker at software conferences around the world, and was recently elected to the .NET Foundation Board for the 2026–2027 term. He doesn’t mind the travel, though, as it allows him to share what he's been learning and also gives him the chance to visit beautiful places like national parks—one of his passions. So far, he's visited 58 of the 63 U.S. national parks. J. is also passionate about building the software community. Over the years, he has served on several non-profit boards, including more than a decade as president of the board for Beer City Code, Western Michigan's largest professional software conference. Outside of work, J. enjoys hiking, reading, photography, and watching all the Best Picture nominees before the Oscars ceremony each year.

Free Consultation

Sign up for a FREE consultation with one of Trailhead's experts.

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Related Blog Posts

We hope you’ve found this to be helpful and are walking away with some new, useful insights. If you want to learn more, here are a couple of related articles that others also usually find to be interesting:

Our Gear Is Packed and We're Excited to Explore With You

Ready to come with us? 

Together, we can map your company’s software journey and start down the right trails. If you’re set to take the first step, simply fill out our contact form. We’ll be in touch quickly – and you’ll have a partner who is ready to help your company take the next step on its software journey. 

We can’t wait to hear from you! 

Main Contact

This field is for validation purposes and should be left unchanged.

Together, we can map your company’s tech journey and start down the trails. If you’re set to take the first step, simply fill out the form below. We’ll be in touch – and you’ll have a partner who cares about you and your company. 

We can’t wait to hear from you! 

Montage Portal

Montage Furniture Services provides furniture protection plans and claims processing services to a wide selection of furniture retailers and consumers.

Project Background

Montage was looking to build a new web portal for both Retailers and Consumers, which would integrate with Dynamics CRM and other legacy systems. The portal needed to be multi tenant and support branding and configuration for different Retailers. Trailhead architected the new Montage Platform, including the Portal and all of it’s back end integrations, did the UI/UX and then delivered the new system, along with enhancements to DevOps and processes.

Logistics

We’ve logged countless miles exploring the tech world. In doing so, we gained the experience that enables us to deliver your unique software and systems architecture needs. Our team of seasoned tech vets can provide you with:

Custom App and Software Development

We collaborate with you throughout the entire process because your customized tech should fit your needs, not just those of other clients.

Cloud and Mobile Applications

The modern world demands versatile technology, and this is exactly what your mobile and cloud-based apps will give you.

User Experience and Interface (UX/UI) Design

We want your end users to have optimal experiences with tech that is highly intuitive and responsive.

DevOps

This combination of Agile software development and IT operations provides you with high-quality software at reduced cost, time, and risk.

Trailhead stepped into a challenging project – building our new web architecture and redeveloping our portals at the same time the business was migrating from a legacy system to our new CRM solution. They were able to not only significantly improve our web development architecture but our development and deployment processes as well as the functionality and performance of our portals. The feedback from customers has been overwhelmingly positive. Trailhead has proven themselves to be a valuable partner.

– BOB DOERKSEN, Vice President of Technology Services
at Montage Furniture Services

Technologies Used

When you hit the trails, it is essential to bring appropriate gear. The same holds true for your digital technology needs. That’s why Trailhead builds custom solutions on trusted platforms like .NET, Angular, React, and Xamarin.

Expertise

We partner with businesses who need intuitive custom software, responsive mobile applications, and advanced cloud technologies. And our extensive experience in the tech field allows us to help you map out the right path for all your digital technology needs.

  • Project Management
  • Architecture
  • Web App Development
  • Cloud Development
  • DevOps
  • Process Improvements
  • Legacy System Integration
  • UI Design
  • Manual QA
  • Back end/API/Database development

We partner with businesses who need intuitive custom software, responsive mobile applications, and advanced cloud technologies. And our extensive experience in the tech field allows us to help you map out the right path for all your digital technology needs.

Our Gear Is Packed and We're Excited to Explore with You

Ready to come with us? 

Together, we can map your company’s tech journey and start down the trails. If you’re set to take the first step, simply fill out the contact form. We’ll be in touch – and you’ll have a partner who cares about you and your company. 

We can’t wait to hear from you! 

Thank you for reaching out.

You’ll be getting an email from our team shortly. If you need immediate assistance, please call (616) 371-1037.