partychen/remote-mcp-server-dotnet
If you are the rightful owner of remote-mcp-server-dotnet and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
This project is an example implementation of a Model Context Protocol (MCP) server built using .NET 9.0 and ASP.NET Core.
say-greeting
Greets the user with a custom message.
Remote MCP Server (.NET)
This project is an example implementation of a Model Context Protocol (MCP) server built using .NET 9.0 and ASP.NET Core. It demonstrates how to create a stateless HTTP-based MCP server with custom tools.
Features
- Health Check Endpoint: A simple ping endpoint to verify server availability and get version information
- MCP Server Tools: Includes a sample
say-greeting
tool to demonstrate MCP server functionality - Stateless HTTP Transport: Configured for stateless communication using the ModelContextProtocol.AspNetCore package
- Session Tracking: Supports MCP session ID headers for request tracking
- Logging Integration: Built-in logging for tool invocations and debugging
Project Structure
remote-mcp-server-dotnet/
āāā Controllers/
ā āāā PingController.cs # Health check endpoint
āāā Tools/
ā āāā ExampleTools.cs # MCP tool implementations
ā āāā Constants.cs # Tool constants and descriptions
āāā Program.cs # Application configuration and startup
āāā remote-mcp-server-dotnet.csproj
āāā .vscode/
ā āāā mcp.json # MCP server configuration
āāā README.md
Dependencies
- ModelContextProtocol (v0.2.0-preview.3): Core MCP functionality
- ModelContextProtocol.AspNetCore (v0.2.0-preview.3): ASP.NET Core integration
Getting Started
Prerequisites
- .NET 9.0 SDK
- A REST client (e.g., Postman,
curl
, or VS Code REST Client extension) for testing
Running the Server
-
Clone the repository:
git clone <repository-url> cd remote-mcp-server-dotnet
-
Restore dependencies:
dotnet restore
-
Build the project:
dotnet build
-
Run the server:
dotnet run
The server will start at http://localhost:5000
by default.
API Endpoints
Health Check
- GET/HEAD
/
- Returns server status and version information
Example Response:
{
"Message": "Ping succeeded",
"Version": "1.0.0",
"AspNetCoreEnvironment": "local"
}
MCP Endpoint
- POST
/mcp
- Main MCP endpoint for tool invocations
Available Tools
say-greeting
Greets the user with a custom message.
Parameters:
input
(string): The text to include in the greeting
Configuration
The MCP server configuration is defined in .vscode/mcp.json
:
{
"servers": {
"my-mcp-server-051bc3eb": {
"url": "http://localhost:5000/mcp"
}
}
}
Testing the Server
Test the Health Check
curl http://localhost:5000
Test the MCP Tool
-
Enable MCP support in VS Code:
- Open VS Code settings and enable
chat.mcp.enabled
- Ensure you have access to GitHub Copilot
- Open VS Code settings and enable
-
Configure the server (already done via
.vscode/mcp.json
) -
Test in agent mode:
- Open the Chat view (Ctrl+Alt+I)
- Select "Agent mode" from the dropdown
- Click the "Tools" button to see available tools
- You should see the
say-greeting
tool listed - Try a prompt like: "Please greet me using the say-greeting tool"
- Or reference the tool directly:
#say-greeting
Troubleshooting
- Run
MCP: List Servers
from the Command Palette to check server status - Check the server logs if there are connection issues
- Ensure the server is running on
http://localhost:5000/mcp
- Verify the
.vscode/mcp.json
configuration is correct
Development
Adding New Tools
- Create a new method in
ExampleTools.cs
or create a new tools class - Decorate the method with
[McpServerTool]
and[Description]
attributes - Register the tools class in
Program.cs
using.WithTools<YourToolsClass>()
Example Tool Method
[McpServerTool(Name = "your-tool-name")]
[Description("Description of what your tool does")]
public async Task<object?> YourTool([Description("Parameter description")] string parameter)
{
// Your tool logic here
return await Task.FromResult(new { result = "success" });
}
Logging
The server includes built-in logging for MCP tool invocations. Check the console output for detailed information about tool calls, including session IDs and parameters.
License
This project is licensed under the .