Skip to main content
Glama
kasirajan22

DotNet MCP Server Demo

by kasirajan22
WeatherController.cs2.01 kB
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace MCPDemo.Controllers { /// <summary> /// Sample Weather API endpoints for demonstration /// </summary> [ApiController] [Route("api/[controller]")] public class WeatherController : ControllerBase { private static readonly string[] Summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" }; private readonly ILogger<WeatherController> _logger; public WeatherController(ILogger<WeatherController> logger) { _logger = logger; } /// <summary> /// Get weather forecast (requires authentication) /// </summary> /// <returns>Weather forecast data</returns> /// <response code="200">Returns weather forecast</response> /// <response code="401">Unauthorized - Invalid credentials</response> [HttpGet] [Authorize] [ProducesResponseType(200)] [ProducesResponseType(401)] public IActionResult GetWeather() { var forecast = Enumerable.Range(1, 5).Select(index => new { Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), TemperatureC = Random.Shared.Next(-20, 55), Summary = Summaries[Random.Shared.Next(Summaries.Length)] }).ToArray(); return Ok(forecast); } /// <summary> /// Get public weather information (no authentication required) /// </summary> /// <returns>Basic weather information</returns> /// <response code="200">Returns public weather data</response> [HttpGet("public")] [ProducesResponseType(200)] public IActionResult GetPublicWeather() { return Ok(new { message = "Public weather data", temperature = "25°C", condition = "Sunny" }); } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kasirajan22/DotnetMCPServer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server