Remote MCP Servers Using Dotnet SDK Prompts
No description available
Ask AI about Remote MCP Servers Using Dotnet SDK Prompts
Powered by Claude · Grounded in docs
I know everything about Remote MCP Servers Using Dotnet SDK Prompts. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
Remote MCP Server Using .NET SDK: Prompts
This repository contains a sample remote Model Context Protocol (MCP) server built with the .NET SDK and ModelContextProtocol.AspNetCore.
The server exposes:
- MCP tools (for operations such as ping and weather lookup)
- MCP prompts (for reusable instruction templates)
- HTTP MCP endpoint at
/mcp - Health endpoint at
/api/healthz
What This Project Is
The project is an ASP.NET Core MCP server that can be used by MCP clients (including VS Code MCP client configuration in .vscode/mcp.json).
Source layout:
src/McpServer/McpServer: MCP host applicationsrc/McpServer/WeatherService: weather service used by the weather toolscripts: PowerShell scripts to list and call MCP tools/resources/prompts
Prerequisites
- Windows with PowerShell (
pwshor Windows PowerShell) - .NET SDK
10.0(project targetsnet10.0) - VS Code with MCP client support
- Internet access for weather lookup (uses Open-Meteo APIs)
Run The Server Locally
From the repository root:
dotnet restore .\src\McpServer\McpServer.slnx
dotnet run --project .\src\McpServer\McpServer\McpServer.csproj
Default server URL:
http://0.0.0.0:8081/mcp
Notes:
- Port is controlled by
FUNCTIONS_CUSTOMHANDLER_PORT(defaults to8081). - Health check endpoint:
http://localhost:8081/api/healthz
VS Code MCP Client Configuration
This repository already includes .vscode/mcp.json:
{
"servers": {
"local-mcp-server": {
"url": "http://0.0.0.0:8081/mcp",
"type": "http"
}
}
}
If needed, update url to match your local port.
Exposed MCP Tools
Defined in src/McpServer/McpServer/McpServerTools.cs:
Ping(message: string)- Verifies server responsiveness and optionally echoes a message.
GetWeather(city: string)- Returns current weather data for the requested city.
Tool names shown by MCP clients can be normalized by the MCP library. Use tools/list (or the script below) to confirm exact callable names in your environment.
Exposed MCP Prompts
Defined in src/McpServer/McpServer/McpServerPrompts.cs and registered in src/McpServer/McpServer/Program.cs with:
.WithPrompts<McpServerPrompts>();
Available prompts:
-
default_prompt- Description: Default system prompt for the MCP server.
- Returns a concise system instruction set:
- be concise
- prefer plain text
- do not hallucinate
- ask for clarification when input is unclear
-
weather_query_guide(userContext?: string)- Description: Guidance on how to ask for weather forecasts in a structured way.
- Optional argument:
userContext: extra location or preference context appended to the prompt output.
-
weather_data_interpretation- Description: Instructions for interpreting weather forecast data returned by the server.
- Includes formatting guidance for temperature, summary, context, and recommendations.
Use prompts/list to see exact prompt names and argument metadata in your runtime.
How To Create A New MCP Prompt
Use this pattern from McpServerPrompts when adding a new prompt.
- Add or reuse a prompt container class and mark it with
[McpServerPromptType]. - Add a public method and mark it with
[McpServerPrompt]. - Add a
[Description("...")]attribute so clients can show meaningful metadata. - For input arguments, add
[Description("...")]attributes for better client introspection. - Return
stringorTask<string>. - Ensure the prompt type is registered in startup (already done with
.WithPrompts<McpServerPrompts>()). - Run the server and validate with
prompts/listandprompts/get.
Example (new prompt in McpServerPrompts.cs):
[McpServerPrompt]
[Description("Provides concise guidance for travel weather planning")]
public Task<string> TravelWeatherGuide(
[Description("Destination city")] string city,
[Description("Optional number of travel days")] int? days = null)
{
var output = $"""
# Travel Weather Guide
Destination: {city}
Duration: {(days.HasValue ? $"{days} day(s)" : "unspecified")}
Ask for:
- daily highs/lows
- rain probability
- wind conditions
""";
return Task.FromResult(output);
}
After adding the method, test it:
# 1) Start server
dotnet run --project .\src\McpServer\McpServer\McpServer.csproj
# 2) List prompts and confirm the new prompt name
.\scripts\list-mcp-server-prompts.ps1
# 3) Get the prompt by name
.\scripts\call-mcp-prompt.ps1 -PromptName "travel_weather_guide"
Scripts
Scripts are in scripts/:
scripts/list-mcp-server-tools.ps1- Calls MCP
tools/listand prints discovered tools and schemas.
- Calls MCP
scripts/call-mcp-tool.ps1- Calls MCP
tools/callfor a specific tool and arguments. - Defaults:
toolName=get_weather,toolParams=@{ city = "Paris" }.
- Calls MCP
scripts/list-mcp-server-prompts.ps1- Calls MCP
prompts/listand prints discovered prompts and arguments.
- Calls MCP
scripts/call-mcp-prompt.ps1- Calls MCP
prompts/getfor a specific prompt name. - Default prompt name:
weather_query_guide.
- Calls MCP
Optional resource scripts are also present if you still want to inspect MCP resources:
scripts/list-mcp-server-resources.ps1scripts/call-mcp-resources.ps1
Quick Test Examples
Run these from the repository root in a second terminal while the server is running.
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force;
List available tools:
.\scripts\list-mcp-server-tools.ps1
Call ping tool:
.\scripts\call-mcp-tool.ps1 -toolName "ping" -toolParams @{ message = "hello from local test" }
Call weather tool:
.\scripts\call-mcp-tool.ps1 -toolName "get_weather" -toolParams @{ city = "Paris" }
List available prompts:
.\scripts\list-mcp-server-prompts.ps1
Get default prompt:
.\scripts\call-mcp-prompt.ps1 -PromptName "default_prompt"
Get weather query guide prompt:
.\scripts\call-mcp-prompt.ps1 -PromptName "weather_query_guide"
Get weather interpretation prompt:
.\scripts\call-mcp-prompt.ps1 -PromptName "weather_data_interpretation"
