Get the FREE Ultimate OpenClaw Setup Guide →

mcp-client

Sample of MCP Client and MCP Server using Azure OpenAi in Chat Sample

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
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:

  1. Clone the repository: git clone https://github.com/your-org/mcp-client.git cd mcp-client

  2. Restore and build the solution(s): dotnet restore dotnet build --configuration Release

  3. 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)
  4. Run the server (from project root or as configured): dotnet run --project McpWeatherServer/McpWeatherServer.csproj

  5. 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

Sponsor this space

Reach thousands of developers