MCP Server with .Net — DeepSeek Tips & Insights
    Neura MarketNeura Market/DeepSeek
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeek
    CoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsGamesBlogVideosGuidesCoursesCommunityTrending
    DeepSeekBlogMCP Server with .Net
    Back to Blog
    MCP Server with .Net
    dotnet

    MCP Server with .Net

    Antonio Di Motta March 12, 2026
    0 views

    Building a MCP Server with C#


    title: MCP Server with .Net published: true description: Building a MCP Server with C# tags: dotnet,mcp,ai cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0kngrc72v2awjxz6qm6w.jpg

    Use a ratio of 100:42 for best results.

    published_at: 2026-03-12 21:50 +0000


    With the [release 1.0 of the official ModelContextProtocol .Net SDK] (https://csharp.sdk.modelcontextprotocol.io), we are ready to make a MCP Server fully compliant with MCP specs and entirely in C#.

    As usually when I need to learn new stuffs I develop a simple demo around a real scenario. For the MCP Server I thought to build one for managing some data like customers, products and orders stored into a Postgres database.

    The MCP server provides the data on behalf of user prompt like:

        give me the customer list
        tell me the most expensive order
        how many USB-C Hub has been ordered ?
        give me the customer list without orders
        suggest a new product for the customer Jane Smith
        add new order
        .....
    

    The most important feature of MCP Server is the tool as function able to do something. Below an example of tool:

    [McpServerTool(Name = "GetCustomer"), Description("Retrieve a single customer from the database.")]
    public static async Task<object> GetCustomer(AppDbContext db, CancellationToken ct, ILogger<MCPTool> logger, [Description("Full name of the customer to retrieve.")] string fullName ){
            logger.LogDebug( $"Executing GetCustomer tool with full name : {fullName }" );
            
      var query = db.Customers.AsNoTracking();
      var result = await query.Where(c => (c.FirstName + " " + c.LastName) == fullName)
                              .FirstOrDefaultAsync(ct);
    
      if (result == null)
         return $"Customer with full name {fullName} not found.";
    
      return result;
    }
    

    The example shows how to help llm to recognize the right tool by using specific custom attributes [McpServerTool].

    Another interesting feature is the prompt. I implemented one to create a model capable of handling requests that require more complex and detailed context for responses.

    Here an example:

    [McpServerPrompt, Description("Generate product suggestion for new order prompt")]
    public static IEnumerable<ChatMessage> SuggestProductByCustomer(
            [Description("Full name of the customer")] string fullName )
    {
            return [
                new(ChatRole.System, "You are an assistant for an e-commerce platform. You help customers find products based on their preferences and past purchases."),
                new(ChatRole.User, $"Please suggest products for the customer with full name: {fullName}"),
                new(ChatRole.Assistant, "To suggest products for the customer, I will need to look up their past purchases and preferences in the database. I will use the GetCustomer and GetOrders tools to retrieve this information and then analyze it to find suitable product suggestions.")
            ];
    }
    

    The entire demo is available here. It contains a dev setup environment which able to spin up quickly the Postgres database with already some test data.

    happy coding!

    Tags

    dotnetmcpai

    Comments

    More Blog

    View all
    Five Gemma-4 models, one accelerator: what porting E2B 31B to AWS Inferentia2 taught megemma

    Five Gemma-4 models, one accelerator: what porting E2B 31B to AWS Inferentia2 taught me

    I ported the whole Gemma-4 family — E2B, E4B, 12B, 31B, and the 26B-A4B MoE — to run on...

    X
    xbill
    Hey DEV, I'm Tobore. Let's actually connect.community

    Hey DEV, I'm Tobore. Let's actually connect.

    Hey DEV, I'm Tobore. Let's actually connect. I've been on here for a while now, mostly writing and...

    L
    Laurina Ayarah
    I burned through thousands of AI tokens. Then a friend did it for freeai

    I burned through thousands of AI tokens. Then a friend did it for free

    (yep, kinda clickbait, just for the funsies 😊) At the beginning of the year, I relaunched my...

    P
    Paulo Henrique
    Claude might be saturating your machineai

    Claude might be saturating your machine

    My laptop was sitting idle with the fan at full tilt. Nothing was running that I knew of. The culprit...

    S
    Sidhant Panda
    Automated GitHub Code Reviews Using Google Geminigithubactions

    Automated GitHub Code Reviews Using Google Gemini

    I Built a Thing! TL;DR — Google Gemini-based Pull Request reviews and Issue Triaging for...

    D
    Darren "Dazbo" Lester
    What is an "agentic harness," actually?ai

    What is an "agentic harness," actually?

    I've been hearing the word "harness" thrown around a lot lately. I assumed it just meant "the IDE" or...

    T
    Tilde A. Thurium

    Stay up to date

    Get the latest DeepSeek prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for DeepSeek and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.

    Neura Market

    Custom AI Systems & Services

    Our team of experienced AI builders will help build custom AI systems, workflows, and solutions for your business.

    Request custom work

    Ready-made automations for this

    Workflows from the Neura Market marketplace related to this DeepSeek resource

    • Automate Blog Content Creation with Notion MCP, DeepSeek AI, and WordPressn8n · $9.99 · Related topic
    • Generate AI Videos from Scripts with DeepSeek, Synthesia, and Together.ain8n · $24.99 · Related topic
    • Get Scaleway Server Info with Dynamic Filteringn8n · $14.99 · Related topic
    • AI Agent Managed Tables and Views with Coda Tool MCP Server - 18 Operationsn8n · $14.99 · Related topic
    Browse all workflows