<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/build-your-first-mcp-server-in-net-with-ef-core-wxkiqbyk7" -->

---
title: Build Your First MCP Server in .NET with EF Core | daily.dev
description: A step-by-step walkthrough shows how to build a local MCP (Model Context Protocol) server from scratch in .NET, using Entity Framework Core to expose database...
canonical: https://daily.dev/posts/build-your-first-mcp-server-in-net-with-ef-core-wxkiqbyk7
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Build Your First MCP Server in .NET with EF Core | daily.dev
og:description: A step-by-step walkthrough shows how to build a local MCP (Model Context Protocol) server from scratch in .NET, using Entity Framework Core to expose database...
og:url: https://daily.dev/posts/build-your-first-mcp-server-in-net-with-ef-core-wxkiqbyk7
og:image: https://api.daily.dev/og/posts/wXkiqbyK7.png
og:image:alt: Build Your First MCP Server in .NET with EF Core
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Build Your First MCP Server in .NET with EF Core

**[We Are .NET](https://daily.dev/sources/wearedotnet)** · 19 min read · 2 upvotes · 0 comments

## Summary

A step-by-step walkthrough shows how to build a local MCP (Model Context Protocol) server from scratch in .NET, using Entity Framework Core to expose database access as AI tools. It covers MCP fundamentals (tools, resources, prompts), setting up a .NET 10 console app with the ModelContextProtocol and Microsoft.Extensions.Hosting NuGet packages, defining EF Core entities and seeding fake library data, decorating methods with McpServerTool attributes to expose search and statistics functions, publishing the server as a self-contained executable, and connecting it to Claude Desktop and the MCP Inspector for testing.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=P7gM6gVvtNI>

## Questions this post answers

### How do I create an MCP server in .NET that exposes tools to query a database via Entity Framework Core?

Create a .NET console app, add the ModelContextProtocol and Microsoft.Extensions.Hosting NuGet packages, register the MCP server in the DI container with stdio transport and WithToolsFromAssembly, then define a class marked with the McpServerTool type attribute containing methods decorated with McpServerTool attributes (each with a description). Inject the EF Core DbContext into that class to implement methods like searching books by title or author, filtering by genre, and returning aggregate library statistics.

_Developers wiring EF Core data into AI tools can compare implementation notes like these on daily.dev._

### Which NuGet packages do I need to build an MCP server in .NET, and does it matter if it's local or remote?

For a locally hosted server using standard input/output, install the ModelContextProtocol package. For a remotely hosted server over HTTP, use ModelContextProtocol.AspNetCore instead, alongside Microsoft.Extensions.Hosting for building and running the host application.

_Anyone choosing between local and remote MCP hosting setups can track these tradeoffs on daily.dev._

### How can I test an MCP server locally before connecting it to an AI client like Claude Desktop?

Run the MCP Inspector tool from the model context protocol website using the command 'npx @modelcontextprotocol/inspector', which downloads and runs it locally. Add the server manually with stdio transport, point it to the executable and working directory, then use the inspector's tools list to invoke and verify tool responses before wiring the server into Claude Desktop's config file.

_Developers validating MCP tool behavior before production use can follow similar testing workflows shared on daily.dev._

## Similar posts on daily.dev

- [Build Your First MCP Server in C\#: A Step-by-Step Quickstart](https://daily.dev/posts/build-your-first-mcp-server-in-c-a-step-by-step-quickstart-pt500c6tu) · We Are .NET · 4 upvotes · 0 comments
- [Your first MCP server with ASP.NET](https://daily.dev/posts/your-first-mcp-server-with-asp-net-0kwwmyuuj) · Tim Deschryver · 20 upvotes · 3 comments
- [Building Production-Ready MCP Servers in ASP.NET Core 10](https://daily.dev/posts/building-production-ready-mcp-servers-in-asp-net-core-10-frlgntgl0) · C\# Corner · 1 upvotes · 0 comments
- [Build Your First MCP Server in C\# with the Official SDK](https://daily.dev/posts/build-your-first-mcp-server-in-c-with-the-official-sdk-gfvr6bvsh) · Code with Mukesh · 17 upvotes · 2 comments

---

Tags: [#github](https://daily.dev/tags/github), [#.net](https://daily.dev/tags/.net), [#mcp](https://daily.dev/tags/mcp)

[View this post on daily.dev](https://daily.dev/posts/build-your-first-mcp-server-in-net-with-ef-core-wxkiqbyk7)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Build Your First MCP Server in .NET with EF Core","url":"https://daily.dev/posts/build-your-first-mcp-server-in-net-with-ef-core-wxkiqbyk7","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/build-your-first-mcp-server-in-net-with-ef-core-wxkiqbyk7"},"datePublished":"2026-09-15T07:34:45.518Z","dateModified":"2026-09-15T07:35:09.692Z","description":"A step-by-step walkthrough shows how to build a local MCP (Model Context Protocol) server from scratch in .NET, using Entity Framework Core to expose database...","image":"https://i.ytimg.com/vi/P7gM6gVvtNI/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/P7gM6gVvtNI/sddefault.jpg","isAccessibleForFree":true,"articleSection":"We Are .NET","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"We Are .NET","logo":"https://media.daily.dev/image/upload/s--BsnVOa3i--/f_auto/v1718347410/logos/wearedotnet","url":"https://daily.dev/sources/wearedotnet"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/build-your-first-mcp-server-in-net-with-ef-core-wxkiqbyk7","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"github,.net,mcp","timeRequired":"PT19M","video":{"@type":"VideoObject","name":"Build Your First MCP Server in .NET with EF Core","description":"A step-by-step walkthrough shows how to build a local MCP (Model Context Protocol) server from scratch in .NET, using Entity Framework Core to expose database...","thumbnailUrl":"https://i.ytimg.com/vi/P7gM6gVvtNI/sddefault.jpg","uploadDate":"2026-09-15T07:34:45.518Z","duration":"PT19M","url":"https://api.daily.dev/r/wXkiqbyK7","embedUrl":"https://www.youtube.com/embed/P7gM6gVvtNI"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"We Are .NET","item":"https://daily.dev/sources/wearedotnet"},{"@type":"ListItem","position":3,"name":"Build Your First MCP Server in .NET with EF Core"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/build-your-first-mcp-server-in-net-with-ef-core-wxkiqbyk7#faq","mainEntity":[{"@type":"Question","name":"How do I create an MCP server in .NET that exposes tools to query a database via Entity Framework Core?","acceptedAnswer":{"@type":"Answer","text":"Create a .NET console app, add the ModelContextProtocol and Microsoft.Extensions.Hosting NuGet packages, register the MCP server in the DI container with stdio transport and WithToolsFromAssembly, then define a class marked with the McpServerTool type attribute containing methods decorated with McpServerTool attributes (each with a description). Inject the EF Core DbContext into that class to implement methods like searching books by title or author, filtering by genre, and returning aggregate library statistics. Developers wiring EF Core data into AI tools can compare implementation notes like these on daily.dev."}},{"@type":"Question","name":"Which NuGet packages do I need to build an MCP server in .NET, and does it matter if it's local or remote?","acceptedAnswer":{"@type":"Answer","text":"For a locally hosted server using standard input/output, install the ModelContextProtocol package. For a remotely hosted server over HTTP, use ModelContextProtocol.AspNetCore instead, alongside Microsoft.Extensions.Hosting for building and running the host application. Anyone choosing between local and remote MCP hosting setups can track these tradeoffs on daily.dev."}},{"@type":"Question","name":"How can I test an MCP server locally before connecting it to an AI client like Claude Desktop?","acceptedAnswer":{"@type":"Answer","text":"Run the MCP Inspector tool from the model context protocol website using the command 'npx @modelcontextprotocol/inspector', which downloads and runs it locally. Add the server manually with stdio transport, point it to the executable and working directory, then use the inspector's tools list to invoke and verify tool responses before wiring the server into Claude Desktop's config file. Developers validating MCP tool behavior before production use can follow similar testing workflows shared on daily.dev."}}]}
```

