HemSoft/mcp-server-demo
If you are the rightful owner of mcp-server-demo 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.
A sample Model Context Protocol (MCP) server built with C# and .NET that demonstrates how to create custom tools for AI assistants.
Echo
Echoes the message back to the client with a greeting.
ReverseEcho
Returns the input message with characters in reverse order.
MCP Server Demo
A sample Model Context Protocol (MCP) server built with C# and .NET that demonstrates how to create custom tools for AI assistants. This server provides two simple tools: Echo and ReverseEcho.
Features
- Echo Tool: Returns a greeting message with the input text
- ReverseEcho Tool: Returns the input text with characters reversed
- Built with the ModelContextProtocol.Server library
- Compatible with any MCP host (VS Code, Claude Desktop, etc.)
Prerequisites
- .NET 10.0 or later
- VS Code with GitHub Copilot extension (for VS Code integration)
Building the Server
-
Clone this repository:
git clone https://github.com/HemSoft/mcp-server-demo.git cd mcp-server-demo
-
Build the project:
dotnet build
-
Run the server (for testing):
dotnet run
Using with VS Code
To use this MCP server with VS Code and GitHub Copilot:
Method 1: Using the VS Code MCP Extension
- Install the MCP extension in VS Code
- Open VS Code settings and navigate to the MCP configuration
- Add a new server configuration:
{ "mcpServers": { "mcp-server-demo": { "command": "dotnet", "args": ["run", "--project", "path/to/mcp-server-demo/mcp-server-demo.csproj"], "env": {} } } }
Method 2: Using MCP Configuration File
-
Create or edit the MCP configuration file in your VS Code workspace (
.vscode/mcp.json
):{ "mcpServers": { "mcp-server-demo": { "command": "dotnet", "args": ["run", "--project", "./mcp-server-demo.csproj"], "cwd": "f:\\github\\HemSoft\\mcp-server-demo" } } }
-
Restart VS Code or reload the window
-
The MCP server will be automatically connected when GitHub Copilot starts
Using with Claude Desktop
To use this server with Claude Desktop:
-
Build the project in Release mode:
dotnet build -c Release
-
Edit your Claude Desktop configuration file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
- Linux:
~/.config/claude/claude_desktop_config.json
- Windows:
-
Add the server configuration:
{ "mcpServers": { "mcp-server-demo": { "command": "dotnet", "args": ["path/to/mcp-server-demo/bin/Release/net10.0/mcp-server-demo.dll"], "env": {} } } }
-
Restart Claude Desktop
Available Tools
Echo
- Description: Echoes the message back to the client with a greeting
- Parameters:
message
(string): The message to echo
- Example: Input "Hello World" returns "Hello from C#: Hello World"
ReverseEcho
- Description: Returns the input message with characters in reverse order
- Parameters:
message
(string): The message to reverse
- Example: Input "Hello World" returns "dlroW olleH"
Testing the Server
Once connected to an MCP host, you can test the tools by asking the AI assistant to:
- "Echo the message 'Hello MCP'"
- "Reverse the string 'Once upon a time'"
- "Use the echo tool to say something"
Troubleshooting
Server Not Connecting
- Ensure .NET 10.0 is installed and accessible via the
dotnet
command - Check that the file paths in your configuration are correct
- Verify the server builds without errors (
dotnet build
)
Tools Not Available
- Restart your MCP host application
- Check the MCP host logs for connection errors
- Ensure the configuration JSON is valid
Development
This project demonstrates the basic structure of an MCP server in C#:
Program.cs
: Main entry point and tool definitionsmcp-server-demo.csproj
: Project file with dependencies- Uses
ModelContextProtocol.Server
NuGet package
To add new tools:
- Create a new static method in the
EchoTool
class (or create a new class) - Decorate with
[McpServerTool]
and[Description]
attributes - Rebuild and restart the server
License
This project is licensed under the MIT License - see the LICENSE file for details.