MCP.so
ログイン

MCP .NET Template

@NikiforovAll

基本情報

カテゴリ

開発者ツール

ライセンス

MIT

トランスポート

stdio

作者

NikiforovAll

MCP .NET Template について

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

MCP .NET Template の設定

以下の設定を使って、このサーバーを MCP 対応クライアントに追加してください。

{
  "mcpServers": {
    "mcp-template-dotnet": {
      "command": "npx",
      "args": [
        "@modelcontextprotocol/inspector",
        "-e",
        "DOTNET_ENVIRONMENT=Production",
        "dotnet",
        "$(PWD)/Artefacts/MyAwesomeMCPServer.dll"
      ]
    }
  }
}

MCP .NET Template のツール

ツール一覧はまだありません

この掲載には表示できるツール一覧がまだありません。サーバーにツールがないという意味ではありません。対応機能はプロジェクトのドキュメントをご確認ください。

上のボタンで一時的なサンドボックスでこのサーバーを実行し、ツール一覧を取得できます。

概要

What is Model Context Protocol .NET Template?

A NuGet template for creating Model Context Protocol (MCP) applications in .NET. It provides a basic project structure and example code to help developers build MCP-enabled servers that integrate LLM applications with external data sources.

How to use Model Context Protocol .NET Template?

Install the template using dotnet new install Nall.ModelContextProtocol.Template, then create a new project with commands like dotnet new mcp-server -o MyProject -n MyProject. The generated code registers tools marked with the [McpServerTool] attribute automatically. Build and run locally, or distribute as a .NET tool.

Key features of Model Context Protocol .NET Template

  • Four templates: mcp-server, mcp-server-http, mcp-server-http-auth, and mcp-server-hybrid
  • Supports both Stdio and HTTP transport modes
  • Automatic tool discovery with WithToolsFromAssembly()
  • Can be packaged and distributed as a global .NET tool
  • Integrates with Aspire hosting for cloud-native scenarios

Use cases of Model Context Protocol .NET Template

  • Building a simple echo server to test MCP basics
  • Creating production MCP servers in .NET with tool registration
  • Switching between Stdio and HTTP modes for different deployment needs
  • Distributing MCP servers as globally installable .NET tools
  • Hosting MCP servers in Aspire orchestrations

よくある質問

1

What is the Model Context Protocol (MCP)?

A protocol for seamless integration between LLM applications and external data sources. The .NET template helps you create servers that implement this protocol.

2

What templates are available?

Four templates: `mcp-server` (Stdio), `mcp-server-http` (HTTP), `mcp-server-http-auth` (HTTP with authentication), and `mcp-server-hybrid` (supports both Stdio and HTTP modes). The hybrid template is recommended for flexibility.

3

How do I run the server locally?

Build the project with `dotnet build`, then use the inspector: `npx @modelcontextprotocol/inspector -e DOTNET_ENVIRONMENT=Production dotnet <path-to-dll>`. Alternatively, package as a .NET tool and run directly.

4

Can I distribute the server as a .NET tool?

Yes. Pack with `dotnet pack`, then install globally with `dotnet tool install --global --add-source <path>`. The tool will be available system-wide.

5

How does Aspire hosting work?

Add the server project and the MCP inspector to your AppHost. Use `WithStdio<Projects.MCPServer>()` for Stdio mode or `WithMcp(project)` for HTTP mode.

コメント

「開発者ツール」の他のコンテンツ