MCP-Client -for-agents
This project demonstrates a Model Context Protocol (MCP) server and client implementation in .NET
claude mcp add --transport stdio qmatteoq-mcp-client-server-for-agents dotnet run --project src/csharp/Stdio/MCP.Stdio.Server/MCP.Stdio.Server.csproj
How to use
This MCP server sample demonstrates a backend for managing employee vacation days using the Model Context Protocol (MCP). It includes two transport implementations: a standard I/O (stdio) server implemented in .NET and a TypeScript-based stdio server. The .NET stdio server runs as a console app and exposes MCP tooling to manage and query vacation balances, while the TypeScript variant provides a Node.js-based path to interact with the MCP stack. You can connect client apps (for example, Blazor-based or other MCP clients) to these servers to issue prompts like listing employees and balances or charging vacation days to an employee. When using the SSE (server-sent events) path, you’ll typically run and configure the ASP.NET Core server and interact via the Aspire dashboard or a web client; for the stdio path, you’ll connect via the command-line or a client that communicates over standard input/output with the server.
To get started, choose the implementation you want to run (NET stdio or TS stdio), start the corresponding server, and then use your client of choice to issue MCP prompts such as querying vacation days left for employees or applying charges. The README describes example commands and setup steps for both the .NET and TypeScript variants, including how to prepare dependencies and environment prerequisites before launching the servers.
How to install
Prerequisites
- .NET SDK 9.0 or higher
- Node.js (latest LTS) for the TypeScript sample
- Visual Studio Code (recommended)
- Azurite extension for VS Code (for local Table storage emulation)
Install and run the .NET stdio server
- Clone the repository and navigate to the stdio project folder.
- Ensure you have Azurite running or other required storage emulation configured as described in the README.
- Build or run the server directly:
- Command: dotnet run --project src/csharp/Stdio/MCP.Stdio.Server/MCP.Stdio.Server.csproj
- The console will start the MCP stdio server and listen for input/output over standard I/O as per MCP conventions.
Install and run the TypeScript stdio server
- Install Node.js prerequisites from nodejs.org.
- Open a terminal and navigate to the repository.
- Build the TypeScript sample:
- cd src/ts/stdio/server
- npm run build
- Run the server (after build):
- node /src/ts/stdio/server/dist/app.js
- Ensure Azurite or any required storage emulator is running as described in the README.
Notes
- For the SSE sample (ASP.NET Core server), follow the instructions in the README to configure the openAI connection and start the MCP.SSE.AppHost project with dotnet run --project MCP.SSE.AppHost/MCP.SSE.AppHost.csproj.
- If you are using the Node.js stdio sample, you may need to interact with the server via a client that supports the MCP protocol over stdio, or adapt scripts to feed input and read output from the running process.
Additional notes
Tips and common issues:
- For the SSE path, configure openAiConnectionName in appsettings.json with your Azure OpenAI Azure connection string format, then start the Azurite table service and launch the AppHost as described in the README.
- Ensure Azurite is running before attempting to connect clients, as the MCP servers rely on storage emulation for state.
- The two provided server variants (NET stdio and TS stdio) are alternative implementations; choose the one that fits your environment. The TS variant requires a build step before running the app.js file.
- If you encounter port or binding issues, verify that the required ports (e.g., for SSE hosting or local devtools endpoints) are not blocked by other processes.
- The README mentions example prompts that exercise MCP tools, such as listing employees and charging vacation days; adapt these prompts to your actual data model if you modify the server.
Related MCP Servers
mssql
MSSQL Server MCP implementation written in C#
McpDotNet.Extensions.SemanticKernel
Microsoft SemanticKernel integration for the Model Context Protocol (MCP). Enables seamless use of MCP tools as AI functions.
DatabaseMcpServer
MCP server from ttcc666/DatabaseMcpServer
mcp-dataverse
MCP Server for querying Dataverse using SQL
xperience-community
ASP.NET Core MCP server for Xperience by Kentico projects
console-to-http
Example of converting a stdio MCP server to HTTP using ModelContextProtocol.AspNetCore