remote-mcp-server-dotnet

partychen/remote-mcp-server-dotnet

3.2

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.

Tools
  1. 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

  1. Clone the repository:

    git clone <repository-url>
    cd remote-mcp-server-dotnet
    
  2. Restore dependencies:

    dotnet restore
    
  3. Build the project:

    dotnet build
    
  4. 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

  1. Enable MCP support in VS Code:

    • Open VS Code settings and enable chat.mcp.enabled
    • Ensure you have access to GitHub Copilot
  2. Configure the server (already done via .vscode/mcp.json)

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

  1. Create a new method in ExampleTools.cs or create a new tools class
  2. Decorate the method with [McpServerTool] and [Description] attributes
  3. 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 .