MCP Server Sample
@qmatteoq
This project demonstrates a Model Context Protocol (MCP) server and client implementation in .NET
Overview
What is MCP Server Sample?
MCP Server Sample is a .NET demonstration of a Model Context Protocol (MCP) server and client for managing employee vacation days. It exposes vacation tracking, querying, and updating capabilities through MCP tools using SSE and stdio transports. This sample is intended for developers learning to implement MCP with .NET or TypeScript.
How to use MCP Server Sample?
Install the required prerequisites (.NET SDK 9.0 or Node.js) and start the Azurite Table service emulator. For the stdio sample, connect a client using dotnet run --project src/csharp/Stdio/MCP.Stdio.Server/MCP.Stdio.Server.csproj (C#) or node /src/ts/stdio/server/dist/app.js (TypeScript). For the SSE sample, update appsettings.json with your Azure OpenAI connection string, then run dotnet run --project MCP.SSE.AppHost/MCP.SSE.AppHost.csproj and open http://localhost:5291/ in a browser.
Key features of MCP Server Sample
- MCP server for tracking, querying, and updating vacation balances
- Two transport layers: HTTP Streaming (SSE) and standard I/O (stdio)
- Implementations in both .NET and TypeScript
- Blazor web client using Semantic Kernel
- Integration with Teams AI library
- Uses Azurite emulator for Azure Table storage
Use cases of MCP Server Sample
- Learn how to build and run an MCP server with .NET
- Prototype a vacation management backend service
- Test MCP clients against a real server (e.g., Visual Studio Code, AI Toolkit)
- Integrate MCP tools into Copilot Studio or Semantic Kernel agents
- Experiment with SSE vs. stdio transport in MCP
FAQ from MCP Server Sample
What transports does MCP Server Sample support?
The sample includes both SSE (HTTP Streaming) and stdio (standard input/output) transport layers.
What are the prerequisites to run the sample?
You need .NET SDK 9.0, Node.js, Visual Studio Code, and the Azurite extension for the table storage emulator.
How do I run the SSE sample?
Open the appsettings.json in the MCP.SSE.AppHost project, set the openAiConnectionName with your Azure OpenAI connection string, start Azurite, and run dotnet run --project MCP.SSE.AppHost/MCP.SSE.AppHost.csproj. Then open http://localhost:5291/ to use the Blazor UI.
How do I connect a client to the stdio server?
Use the command dotnet with arguments run --project src/csharp/Stdio/MCP.Stdio.Server/MCP.Stdio.Server.csproj for the .NET version, or node with /src/ts/stdio/server/dist/app.js for TypeScript.
Is there a TypeScript version of the sample?
Yes, the repository contains a TypeScript implementation under the src/ts/ folder.