Remote MCP Server using .NET SDK with VS Code Support
Remote MCP Server using .NET SDK with VS Code Support
This project is a C# implementation of a Model Context Protocol (MCP) server that exposes weather forecast and health check tools. This server integrates with GitHub Copilot in VS Code, allowing AI assistants to call your custom tools.
Overview
This project demonstrates how to build an HTTP-based MCP server using the .NET SDK. The server exposes two tools:
- ping: Health check with optional message echo
- get_weather: Weather forecast retrieval for cities
Prerequisites
- .NET 8.0 SDK or later
- Visual Studio Code
- GitHub Copilot extension (with MCP support)
- C# Dev Kit extension (recommended)
Project Structure
remote-MCP-servers-using-dotnet-sdk-vs-code-support/
├── src/
│ └── McpServer/
│ └── McpServer/
│ ├── McpServerTools.cs # Tool definitions
│ ├── Program.cs # Server entry point
│ └── McpServer.csproj # Project file
├── .vscode/
│ └── mcp.json # MCP server configuration
└── README.md
Getting Started
1. Build and Run the Server
Open a terminal in the project root and run:
dotnet run --project .\src\McpServer\McpServer\McpServer.csproj
You should see output indicating the server is running:
info: Microsoft.Hosting.Lifetime[14]
Now listening on: http://0.0.0.0:8081
2. Configure VS Code
Create or verify .vscode/mcp.json in your workspace:
{
"servers": {
"local-mcp-server": {
"url": "http://0.0.0.0:8081/mcp",
"type": "http"
}
}
}
3. Connect to the Server in VS Code
-
Open Command Palette: Press
Ctrl + Shift + P(Windows/Linux) orCmd + Shift + P(Mac) -
List MCP Servers: Type and select
List MCP Servers -
Select your server: Choose
local-mcp-serverfrom the list -
Available actions:
- Start: Starts the MCP server connection
- Stop: Stops the MCP server connection
- Restart: Restarts the MCP server connection
- Show Configuration: Displays the server configuration from
mcp.json - Show Output: Opens the output panel showing server logs and tool discovery
- Configure Model Access: Configures which AI models can access this MCP server
4. Verify Server Status
After starting the server, check the output panel for:
[info] Connection state: Running
[info] Discovered 2 tools
✅ If you see this, the server is ready to use!
⚠️ If you see warnings about tool descriptions, ensure all methods in McpServerTools.cs have [Description] attributes.
Testing the MCP Server
Ping Test
Once the server is running, test it using the ping tool in GitHub Copilot Chat:
Open chat windows and start conversation
Test 1: Basic Health Check
Ask: "Ping the server"
Expected Response: ✅ MCP server is alive.
Ask your question
Approve and get result
Test 2: Echo Message
Ask: "Ping the server with message 'Hello MCP'"
Expected Response: ✅ MCP server received: Hello MCP
Weather Forecast Test
Test the weather forecast functionality:
Ask: "What's the weather in London?"
Expected Response: Weather forecast data for London
Ask your question
Approve and get result
Available Tools
The local-mcp-server provides the following tools:
ping
Description: Health check tool that verifies the MCP server is running. If a message is provided, it echoes it back; otherwise, returns server health status.
Parameters:
message(string, optional): Optional message to echo back. If empty, returns health status.
Example Usage:
- “Ping the server”
- “Run a health check on the MCP server”
get_weather
Description: Retrieves the current weather forecast for a specified city.
Parameters:
city(string, required): The name of the city to get weather forecast for.
Example Usage:
- “What’s the weather in Paris?”
- “Get weather forecast for Tokyo”
Troubleshooting
Server Not Discovering Tools
Symptom:
[warning] Tool get_weather does not have a description
[warning] Tool ping does not have a description
Solution: Ensure all tool methods have [Description] attributes at the method level in McpServerTools.cs:
[McpServerTool]
[Description("Health check tool that verifies the MCP server is running...")]
public async Task<string> Ping([Description("Optional message...")] string message)
Server Won’t Start
Symptom: Port 8081 already in use
Solution:
- Stop any existing instances of the server
- Check for processes using port 8081:
netstat -ano | findstr :8081 - Kill the process or change the port in
Program.cs
Tools Not Visible in Copilot Chat
Symptom: Server is running but tools don’t appear in chat
Solution:
- Verify the server is running: Check output panel
- Restart VS Code:
Ctrl + Shift + P→ “Developer: Reload Window” - Reconnect to the server: Use “List MCP Servers” command
- Ensure GitHub Copilot extension is up to date
Connection State: Stopped
Symptom: Server keeps stopping automatically
Solution:
- Check server logs for errors: “Show Output” command
- Verify the server is running on the correct port (8081)
- Test the endpoint manually:
curl -k -v http://localhost:8081/api/healthz
Resources
- Build a Model Context Protocol (MCP) Server in C# – Official Microsoft tutorial
- C# SDK Repository – Official MCP C# SDK
- MCP Specification – Protocol documentation
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License


