Get the FREE Ultimate OpenClaw Setup Guide →

csharp -sample

csharp-mcp-server-sample

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio bluetsys-csharp-mcp-server-sample dotnet run --project ./SampleMcpServer/SampleMcpServer.csproj \
  --env DOTNET_ENVIRONMENT="Development" \
  --env ASPNETCORE_ENVIRONMENT="Development"

How to use

This MCP server sample provides a C#/.NET 6+ utility that calls JsonPlaceholder API endpoints to fetch data. It can be integrated into a console application or an ASP.NET Core project as part of an MCP server, exposing tools that query endpoints such as posts, comments, albums, photos, todos, and users. The sample demonstrates how to wire an MCP server with HttpClient management, single-item and list retrieval methods, and how to expose those operations as MCP tools that can be invoked by the MCP runtime.

To use it, build the project and run the MCP server. The server exposes tools for interacting with the JsonPlaceholder API via the MCP framework. You can extend SampleTools to add additional endpoints or custom logic, and then invoke these tools through the MCP proxy or controller in your environment.

How to install

Prerequisites:

  • .NET 6.0+ SDK installed on your machine
  • A suitable IDE (e.g., Visual Studio, VS Code) for .NET development
  • Access to the project repository containing the SampleMcpServer.csproj file

Installation steps:

  1. Clone the repository containing the C# MCP server sample.
  2. Navigate to the project directory that contains SampleMcpServer.csproj.
  3. Restore dependencies and build the project:
dotnet restore
dotnet build
  1. Run the MCP server:
dotnet run --project ./SampleMcpServer/SampleMcpServer.csproj
  1. The MCP server will start and listen for MCP tool invocations based on the SampleTools configuration.

Additional notes

Notes and tips:

  • Ensure you have the correct .NET 6+ SDK installed; the sample targets .NET 6 or higher as indicated in the README.
  • The sample uses HttpClient to access the JsonPlaceholder API endpoints (/posts, /comments, /albums, /photos, /todos, /users). You can extend or modify the endpoints as needed.
  • If you change tooling or endpoints, update the MCP tools declaration in SampleTools accordingly.
  • Environment variables such as ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT can be used to toggle development vs. production behavior.
  • If you run into port or binding issues, verify any URL binding settings in the hosting configuration and ensure no other process is occupying the required port.

Related MCP Servers

Sponsor this space

Reach thousands of developers