# Mcp Template Dotnet

> This repository contains a template for creating a Model Context Protocol (MCP) applications in .NET.

- **Type:** MCP server
- **Install:** `agentstack add mcp-nikiforovall-mcp-template-dotnet`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [NikiforovAll](https://agentstack.voostack.com/s/nikiforovall)
- **Installs:** 0
- **Category:** [Integrations](https://agentstack.voostack.com/c/integrations)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [NikiforovAll](https://github.com/NikiforovAll)
- **Source:** https://github.com/NikiforovAll/mcp-template-dotnet
- **Website:** https://nikiforovall.blog/dotnet/2025/04/02/mcp-template-getting-started

## Install

```sh
agentstack add mcp-nikiforovall-mcp-template-dotnet
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Model Context Protocol .NET Template

  

  A protocol for seamless integration between LLM applications and external data sources

  Documentation |
  Specification |
  Discussions

This repository contains a [template](https://www.nuget.org/packages/Nall.ModelContextProtocol.Template) for creating a Model Context Protocol (MCP) application in .NET. It provides a basic structure and example code to help you get started with building your own MCP-enabled applications.

| Package                                              | Version                                                                                                                                                                          | Description                |
| ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
| `Nall.ModelContextProtocol.Template`                 | [](https://nuget.org/packages/Nall.ModelContextProtocol.Template)                                 | Templates                  |
| `Nall.ModelContextProtocol.Inspector.Aspire.Hosting` | [](https://nuget.org/packages/Nall.ModelContextProtocol.Inspector.Aspire.Hosting) | Aspire Hosting Integration |

## Getting Started

### Install:

```bash
dotnet new install Nall.ModelContextProtocol.Template
# dotnet new install ./Artefact/Nall.ModelContextProtocol.Template
```

Verify installation:

```bash
dotnet new list mcp
# These templates matched your input: 'mcp'

# Template Name      Short Name         Language  Tags
# -----------------  -----------------  --------  -------------
# Template Name         Short Name            Language  Tags
# --------------------  --------------------  --------  -------------
# MCP Server            mcp-server            [C#]      dotnet/ai/mcp
# MCP Server HTTP       mcp-server-http       [C#]      dotnet/ai/mcp
# MCP Server HTTP Auth  mcp-server-http-auth  [C#]      dotnet/ai/mcp
# MCP Server Hybrid     mcp-server-hybrid     [C#]      dotnet/ai/mcp
```

> [!TIP]
> Practically, you want to switch between modes, so I recommend using the `mcp-server-hybrid` template. It allows you to run the server in both *Stdio* and *HTTP* modes.

Verify output:

```bash
dotnet new mcp-server -o MyAwesomeMCPServer -n MyAwesomeMCPServer --dry-run
# File actions would have been taken:
#   Create: MyAwesomeMCPServer\.vscode\launch.json
#   Create: MyAwesomeMCPServer\MyAwesomeMCPServer.csproj
#   Create: MyAwesomeMCPServer\Program.cs
#   Create: MyAwesomeMCPServer\Properties\launchSettings.json
#   Create: MyAwesomeMCPServer\README.md
#   Create: MyAwesomeMCPServer\appsettings.Development.json
#   Create: MyAwesomeMCPServer\appsettings.json
```

Create from template:

```bash
dotnet new mcp-server -o MyAwesomeMCPServer -n MyAwesomeMCPServer
```

Here is a content of `Program.cs`:

```csharp
using Microsoft.Extensions.Hosting;

var builder = Host.CreateApplicationBuilder(args);
builder.Services
    .AddMcpServer()
    .WithStdioServerTransport()
    .WithToolsFromAssembly();

await builder.Build().RunAsync();

[McpServerToolType]
public static class EchoTool
{
    [McpServerTool, Description("Echoes the message back to the client.")]
    public static string Echo(string message) => $"hello {message}";
}
```

It is a simple echo server that listens for incoming messages and responds with a greeting. You can add more tools by creating additional methods with the `[McpServerTool]` attribute. The `WithToolsFromAssembly()` method automatically registers all tools in the assembly.

### Run Locally

Build from the project directory:

```bash
dotnet build -o Artefacts -c Release
```

Run the inspector:

```bash
npx @modelcontextprotocol/inspector -e DOTNET_ENVIRONMENT=Production dotnet "$(PWD)/Artefacts/MyAwesomeMCPServer.dll"
```

Open inspector in your browser and test the server:

  

### Distribute as .NET Tool

Pack from the project directory:

```bash
dotnet pack -o Artefacts -c Release
```

Install the tool globally:

```bash
dotnet tool install --global --add-source ./Artefacts MyAwesomeMCPServer
```

Now, after you installed this tool globally, you can run it from anywhere on your system. The tool will be available as `MyAwesomeMCPServer` (or `myawesomemcpserver`) in your terminal.

💡 You can also create local tool manifest and install MCPs as tools locally.

Run the inspector:

```bash
npx @modelcontextprotocol/inspector -e DOTNET_ENVIRONMENT=Production myawesomemcpserver
```

## Run with Aspire

### In `Stdio` mode

In `AppHost/Program.cs`:

```csharp
var builder = DistributedApplication.CreateBuilder(args);

builder.AddMCPInspector().WithStdio();

builder.Build().Run();
```

### In `HTTP` mode

In `AppHost/Program.cs`:

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var mcp = builder.AddProject("server");
builder.AddMCPInspector().WithMcp(mcp);

builder.Build().Run();
```

## Reference

- 
-

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [NikiforovAll](https://github.com/NikiforovAll)
- **Source:** [NikiforovAll/mcp-template-dotnet](https://github.com/NikiforovAll/mcp-template-dotnet)
- **License:** MIT
- **Homepage:** https://nikiforovall.blog/dotnet/2025/04/02/mcp-template-getting-started

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-nikiforovall-mcp-template-dotnet
- Seller: https://agentstack.voostack.com/s/nikiforovall
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
