MCP Demo - .NET Web API with Model Context Protocol Server

Implements a .NET MCP server with basic auth, exposing MCP endpoints and sample tools for testing.
  • c#

0

GitHub Stars

c#

Language

7 months ago

First Indexed

3 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs

You run a .NET-based MCP server that implements the Model Context Protocol, providing MCP endpoints, tool execution, and resource management with Basic Authentication for secure access. This server enables you to initialize a session, list and invoke tools, and manage resources from an MCP client in a practical, REST-like workflow.

How to use

Start the server and connect with your MCP client. You will authenticate using Basic Authentication to access the MCP endpoints, initialize the MCP session, discover available tools, and then call tools or manage resources as needed. You can perform operations such as retrieving the current time, echoing a message, or performing basic arithmetic by invoking the corresponding MCP tools through the server. When you begin, ensure you target the MCP API endpoints over HTTPS if you require encryption.

How to install

Prerequisites include the .NET 8 SDK or later and a suitable development environment.

Install the .NET SDK if you have not already:.

Restore dependencies and build the project, then run the application.

dotnet restore
dotnet build
dotnet run

Other important notes

The server exposes a REST-like surface for MCP operations and includes sample tools such as time retrieval, echo, and calculator to demonstrate tool invocation and parameter passing.

By default, the server runs on both HTTPS and HTTP endpoints: https://localhost:5001 and http://localhost:5000. You can access Swagger UI at https://localhost:5001/swagger to inspect the available endpoints and test interactions.

Authentication uses Basic Authentication with a fixed credential set for demonstration. Use the Authorization header to supply credentials in your client requests.

Security considerations and usage guidance

This setup uses Basic Authentication with hardcoded credentials for demonstration purposes. In a production environment, replace this with a secure user store and proper password hashing, enable HTTPS exclusively, consider token-based authentication (such as JWT), and implement authorization policies. Always validate and sanitize inputs, and consider rate limiting to protect the API.

Troubleshooting and tips

If you encounter connection issues, verify that the server is running and listening on the expected ports. Check the development environment’s logs for authentication errors or misconfigurations. Ensure you use the correct base URL and include the required Authorization header for MCP operations.

Available tools

get_time

Returns the current date and time from the server.

echo

Echoes back the provided message or data for verification.

calculate

Performs basic arithmetic operations such as add, subtract, multiply, and divide.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational