McpServerAspNetCore
Minimal implementation of an MCP sample server featuring API Key authentication, CORS support, and example server-side tools for weather and time retrieval.
claude mcp add --transport stdio marcominerva-mcpserveraspnetcore docker run -d -p 5000:80 --env OpenWeatherMapAppId=YOUR_OPENWEATHERMAP_API_KEY --env OpenWeatherMapBaseUrl=https://api.openweathermap.org/data/2.5/ --env AzureOpenAIEndpoint=YOUR_AZURE_OPENAI_ENDPOINT --env AzureOpenAIKey=YOUR_AZURE_OPENAI_API_KEY marcominerva/mcpserveraspnetcore \ --env AzureOpenAIKey="YOUR_AZURE_OPENAI_API_KEY" \ --env AzureOpenAIEndpoint="YOUR_AZURE_OPENAI_ENDPOINT" \ --env OpenWeatherMapAppId="YOUR_OPENWEATHERMAP_API_KEY" \ --env OpenWeatherMapBaseUrl="https://api.openweathermap.org/data/2.5/"
How to use
This MCP server provides a minimal ASP.NET Core-based MCP implementation with automatic tool discovery and API documentation via OpenAPI/Swagger. It exposes two example MCP tools: Weather (retrieves current weather conditions for a given location) and Time (returns the current date and time, including time zone support). Access to the MCP endpoints is protected by an API key mechanism. After starting the server, you can discover available MCP tools through the Swagger UI or the automatic discovery endpoint, test tool calls, and integrate the discovered tools into MCP clients or agents.
To use the tools, first obtain a valid API key for the server (as configured in your deployment). Navigate to the Swagger UI (typically /swagger) to view available endpoints, input required parameters (e.g., location for Weather, or time zone for Time), and execute requests. Clients can auto-discover tools supported by the server and then invoke the corresponding MCP endpoints from your agent or automation workflow.
How to install
Prerequisites:
- Docker installed and running, or a .NET 6/7 development environment if choosing to run locally without Docker
- Access to an OpenWeatherMap API key for the Weather tool
- (Optional) Azure OpenAI credentials for the client samples included with the repository
Option A: Run with Docker (recommended)
- Pull and run the container (replace image name with the correct one if different):
docker run -d -p 5000:80
--env OpenWeatherMapAppId=YOUR_OPENWEATHERMAP_API_KEY
--env OpenWeatherMapBaseUrl=https://api.openweathermap.org/data/2.5/
--env AzureOpenAIEndpoint=YOUR_AZURE_OPENAI_ENDPOINT
--env AzureOpenAIKey=YOUR_AZURE_OPENAI_API_KEY
marcominerva/mcpserveraspnetcore - Access the server at http://localhost:5000
- (Optional) Open http://localhost:5000/swagger to view and test endpoints and discover available MCP tools.
Option B: Run locally with .NET (if provided as a self-hosted app)
- Ensure .NET SDKs compatible with ASP.NET Core 10 are installed.
- Clone the repository and navigate to the project folder.
- Restore and run: dotnet restore dotnet run --project src/McpServerAspNetCore
- Access http://localhost:5000 (or the configured port) and navigate to /swagger for API docs and tool discovery.
Additional notes
Notes and tips:
- OpenWeatherMapBaseUrl and OpenWeatherMapAppId must be configured for the Weather tool to function. In Docker, pass these as environment variables or update appsettings.json inside the container accordingly.
- The server uses an API Key security approach; ensure clients send the correct header or query parameter as defined by the server middleware.
- Swagger/OpenAPI UI is available for exploring endpoints and testing MCP tool calls. Use the Discovery endpoint to enumerate available tools.
- If you enable CORS for external clients, ensure you restrict origins to trusted clients or environments.
- For client integration, you can rely on the MCP discovery mechanism to automatically fetch tool metadata and generate adapters for Weather and Time tools.
- If Azure OpenAI credentials are used by the client samples, keep credentials secure (consider Azure Key Vault or environment-based secrets in production).
Related MCP Servers
ollama -bridge
Extend the Ollama API with dynamic AI tool integration from multiple MCP (Model Context Protocol) servers. Fully compatible, transparent, and developer-friendly, ideal for building powerful local LLM applications, AI agents, and custom chatbots
mcpcat-python-sdk
MCPcat is an analytics platform for MCP server owners 🐱.
muxi
An extensible AI agents framework
MCP-Manager-GUI
MCP Toggle is a simple GUI tool to help you manage MCP servers across clients seamlessly.
unity -template
Simple template project for controlling Unity via MCP
mcpd
A ~3MB MCP daemon that exposes any script as a tool for Claude, Cursor & AI assistants