mcp-client
Sample of MCP Client and MCP Server using Azure OpenAi in Chat Sample
claude mcp add --transport stdio nizzola-mcp-client-server dotnet run --project McpWeatherServer/McpWeatherServer.csproj \ --env OPENAI_API_KEY="your-openai-api-key (if using Azure/OpenAI integration)" \ --env ASPNETCORE_URLS="http://0.0.0.0:5000" \ --env AZURE_OPENAI_ENDPOINT="your-azure-openai-endpoint (if using Azure OpenAI)"
How to use
The MCP client/server setup in this repository demonstrates a .NET-based MCP implementation that leverages AI to process and respond to messages. The server component (MCP Weather Server) accepts MCP messages from clients, routes them through AI processing pipelines, and returns structured responses. The client component (MCP Client) sends messages and commands to the server and handles the AI-generated responses. This pairing enables asynchronous communication and modular extension for adding new AI capabilities or data sources. To use it, start the server first, then run the MCP client to send sample commands such as text analysis or decision-making prompts. The system is designed to be compatible with .NET 8 and .NET 9, enabling straightforward deployment in modern .NET environments.
How to install
Prerequisites:
- .NET SDK 8.x or 9.x installed on your machine
- Git installed to clone the repository
Installation steps:
-
Clone the repository: git clone https://github.com/your-org/mcp-client.git cd mcp-client
-
Restore and build the solution(s): dotnet restore dotnet build --configuration Release
-
Configure environment variables (example):
- Ensure ASPNETCORE_URLS is set if you plan to expose HTTP endpoints
- Provide AI service keys as needed (OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT)
-
Run the server (from project root or as configured): dotnet run --project McpWeatherServer/McpWeatherServer.csproj
-
Run the MCP client to interact with the server (as per the client project instructions): dotnet run --project MCPClient/MCPClient.csproj
Additional notes
Notes and tips:
- This repository provides an educational example showing how to wire an MCP server with AI processing in .NET 8/9. You can adapt the AI components to use ML.NET, OpenAI, or Azure OpenAI providers as needed.
- If you see connectivity issues, verify that the ASP.NET Core URL bindings (ASPNETCORE_URLS) align with where you run the server.
- Ensure proper handling of API keys and secrets, ideally using a secure secret store or user-secrets during development.
- The MCP protocol facilitates asynchronous messaging; consider implementing retry and idempotency strategies for robust client-server interactions.
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