Dotnet Template Mcp

io.github.YuliiaKovalova由 GitHub 帳號 YuliiaKovalova 發布v2.0.0更新於 Oct 24, 2026

MCP server for dotnet new: discover, inspect, preview and create .NET projects from templates.

已驗證STDIO僅桌面檔案與儲存開發者工具

概覽

AI 產生的概覽

針對 dotnet new 的 MCP 伺服器,讓助理用自然語言搜尋、檢視、預覽並建立 .NET 專案與範本。

可以做什麼
  • 在本機與 NuGet.org 上搜尋、列出範本,並檢視其參數與限制
  • 依意圖建立專案、在不寫入磁碟的情況下預覽產生的檔案,並在一次流程中組合多個範本
  • 安裝、解除安裝與清點範本套件,缺少時自動從 NuGet 解析
  • 驗證與比較範本,並從現有專案產生可重複使用的範本
  • 分析解決方案結構,掃描過時的 NuGet 版本並回報或套用升級
適用情境
適合讓助理建立 .NET 專案、挑選合適的範本與參數,或在發佈前檢查自訂範本,而不必記住 dotnet new 的各種旗標。也適合檢視解決方案結構與套件版本。
執行需求
以 .NET 工具形式透過 stdio 在本機執行(全域安裝需 .NET 8+,或以 dnx 免安裝需 .NET 10+);需要 .NET SDK 與連線 NuGet 的網路。可選的 HTTP 模式需在 MCP_TEMPLATE_HTTP_TOKEN 設定共用權杖,或明確允許匿名存取。
安裝前請注意
工具會寫入檔案並安裝 NuGet 套件,伺服器本身說明開放的 HTTP 端點會成為遠端程式碼執行面;應設定權杖,且不要將單一執行個體暴露給互不信任的使用者,因為它不支援多租戶。建立專案與升級套件會修改磁碟檔案,範本搜尋會連線 NuGet.org。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Dotnet Template Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

DotnetTemplateMCP

An MCP server that lets AI agents work with dotnet new templates — search, inspect, preview, and create projects through natural conversation instead of memorizing CLI flags.

[DotnetTemplateMCP MCP server]

Instead of this:

bash
dotnet new list --language C#dotnet new webapi --helpdotnet new webapi --auth Individual --use-controllers --name MyApi --output ./MyApi

Your AI agent just says: "I need a web API with authentication and controllers" — and the MCP server figures out the rest.

Template Validation for Authors

Building a custom dotnet new template? template_validate catches mistakes before you publish — no more guessing if your template.json is correct:

Agent calls: template_validate("./my-template")
← Returns:{  "valid": false,  "summary": "2 error(s), 1 warning(s), 3 suggestion(s)",  "errors": [    "Missing required field 'shortName'.",    "Parameter 'Framework': default value 'net7.0' is not in the choices list."  ],  "warnings": [    "Missing 'sourceName'. Without it, the generated project name won't be customizable via --name."  ],  "suggestions": [    "Consider adding a 'description' field to help users understand what this template creates.",    "Consider adding 'language' tag (e.g., 'C#') for better discoverability.",    "Consider adding 'type' tag (e.g., 'project', 'item') for filtering."  ]}

What it catches: missing required fields, invalid identity format, short name conflicts with CLI commands, parameter issues (missing defaults, empty choices, prefix collisions, type mismatches), broken computed symbols, constraint misconfiguration, and missing tags.

How this relates to the official tooling. Microsoft ships template authoring validation already, and you should know about it:

Official toolWhat it gives you
Microsoft.TemplateEngine.Authoring.CLIdotnet template-authoring validate — the reference validator
Microsoft.TemplateEngine.Authoring.TasksValidation at build time, as an MSBuild task
Microsoft.TemplateEngine.Authoring.TemplateVerifierSnapshot testing of template output

What template_validate adds is not the validation itself — it is the delivery: a single structured JSON payload, split into errors/warnings/suggestions with fix-oriented messages, returned in-band to an agent that is already editing the template. No install step, no output parsing, no second tool in the loop. If you are a human authoring templates in CI, prefer the official tools above; they are the reference implementation and cover cases this does not.

Tools

ToolWhat it does
template_searchSearch locally and on NuGet.org — one call, ranked results
template_listList what's installed, filter by language/type/classification
template_inspectParameters, constraints, post-actions — all in one shot
template_instantiateCreate a project. Not installed? Auto-resolves from NuGet. Elicits missing params interactively
template_dry_runPreview files without touching disk
template_installInstall a package (idempotent — skips if already there)
template_uninstallRemove a template package
templates_installedInventory of everything installed
template_from_intent"web API with auth" → webapi + auth=Individual — no LLM needed
template_create_from_existingAnalyze a .csproj → generate a reusable template matching repo conventions
template_composeExecute a sequence of templates (project + items) in one workflow
template_suggest_parametersSuggest parameter values with rationale based on cross-parameter relationships
template_validateValidate a local template directory for authoring issues before publishing
template_compareCompare 2+ templates side by side — parameters, features, frameworks
solution_analyzeAnalyze a solution/workspace — project structure, frameworks, CPM status
packages_upgradeScan a project/solution/folder for outdated NuGet versions and report or apply upgrades (CPM-aware)

📖 Full tool reference →

Hosted deployment

A hosted deployment is available on Fronteir AI.

Quick Start

Global tool (.NET 8+)

bash
dotnet tool install --global DotnetTemplateMCP --version 2.0.0

Zero-install with dnx (.NET 10+)

bash
dnx -y DotnetTemplateMCP --version 2.0.0

VS Code / GitHub Copilot

Add to mcp.json:

json
{  "servers": {    "dotnet-templates": {      "type": "stdio",      "command": "dnx",      "args": ["-y", "DotnetTemplateMCP", "--version", "2.0.0"]    }  }}

📖 Claude Desktop, Cursor, and more →

Transport Modes

Stdio (default)

Standard I/O transport for local CLI and tool usage:

bash
template-engine-mcp                     # stdio is the defaulttemplate-engine-mcp --transport stdio   # explicit

HTTP (remote / team-shared)

Streamable HTTP transport for remote or CI/CD deployment.

Authentication is mandatory. Every tool in this server writes files and installs NuGet packages, so an open endpoint is a remote code execution surface. The server refuses to start the HTTP transport unless you either set a token or explicitly opt in to anonymous access:

bash
# RecommendedMCP_TEMPLATE_HTTP_TOKEN=<shared-secret> template-engine-mcp --transport http
# Only for a trusted, isolated networkMCP_TEMPLATE_HTTP_ALLOW_ANONYMOUS=true template-engine-mcp --transport http

Clients authenticate with Authorization: Bearer <shared-secret>. Requests to /mcp are rate limited per client (default 120/minute, MCP_TEMPLATE_HTTP_RATE_LIMIT=0 disables). /health stays anonymous for probes.

Not multi-tenant. TemplateEngineService is a process-wide singleton with virtualizeSettings: false, so the installed-template set is shared by every caller, and the workspace root is process-wide. Run one instance per trusted team or per tenant — do not expose a single instance to mutually untrusting users.

bash
template-engine-mcp --transport http# or via environment variable:MCP_TEMPLATE_TRANSPORT=http template-engine-mcp

The HTTP server exposes:

  • /mcp — MCP streamable HTTP endpoint (bearer token required)
  • /health — Health check endpoint (anonymous)

Configure the listen URL:

bash
MCP_TEMPLATE_HTTP_URL=http://0.0.0.0:8080 template-engine-mcp --transport http

Connect your MCP client:

json
{  "servers": {    "dotnet-templates": {      "type": "http",      "url": "http://localhost:5005/mcp"    }  }}

Interactive Elicitation

When a template has required parameters that weren't provided, the server asks the user interactively via MCP elicitation — instead of failing. Template parameter types are mapped to form fields:

Template ParameterElicitation Field
stringText input
bool / booleanCheckbox
int / numberNumber input
Choice parameterSingle-select dropdown

Disable with MCP_TEMPLATE_ELICITATION=false.

How it works

You: "I need a web API with authentication, controllers, and Docker support"
→ template_from_intent extracts keywords: web api, authentication, controllers, docker→ Matches: webapi (confidence: 0.85)→ Resolves: auth=Individual, UseControllers=true, EnableDocker=true→ template_instantiate creates the project

The server also does smart defaults (AOT → latest framework, auth → HTTPS stays on), parameter validation before writing files, constraint checking (OS, SDK, workload), interactive elicitation of missing required parameters, and auto-resolves templates from NuGet if they're not installed.

CPM & Latest Package Versions

When creating a project inside a solution that uses Central Package Management, the server automatically:

  1. Detects Directory.Packages.props by walking up the directory tree
  2. Strips Version attributes from generated .csproj PackageReferences
  3. Adds missing <PackageVersion> entries to Directory.Packages.props
  4. Resolves latest stable NuGet versions — no more stale hardcoded versions from templates
Before (what dotnet new generates):  <PackageReference Include="Serilog" Version="3.1.0" />    ← stale, breaks CPM
After (what template_instantiate produces):  .csproj:                    <PackageReference Include="Serilog" />  Directory.Packages.props:   <PackageVersion Include="Serilog" Version="4.2.0" />

Works for standalone projects too — versions are updated directly in the .csproj.

Multi-Template Composition

Chain multiple templates in one call with template_compose:

json
[  {"templateName": "webapi", "name": "MyApi", "parametersJson": "{\"auth\": \"Individual\"}"},  {"templateName": "gitignore", "target": "."}]

📖 Architecture & smart behaviors →

Tool Profiles (Lite vs Full)

By default, all 15 tools are available. If your agent works better with fewer tools, set the MCP_TEMPLATE_TOOL_PROFILE environment variable:

ProfileToolsWhen to use
full (default)All 15 toolsFull control — advanced workflows, composition, custom templates
lite5 core toolsSimpler agents that just need to find and create projects

Lite profile tools: template_from_intent, template_instantiate, template_inspect, template_search, template_dry_run

json
{  "servers": {    "dotnet-template-mcp": {      "command": "dotnet-template-mcp",      "env": {        "MCP_TEMPLATE_TOOL_PROFILE": "lite"      }    }  }}

Non-lite tools will return a helpful message explaining they're disabled and how to enable them.

Documentation

DocWhat's in it
ConfigurationVS Code, Claude Desktop, Cursor setup + troubleshooting
Tool ReferenceEvery tool's parameters, types, and examples
ArchitectureTemplate cache, smart behaviors, telemetry, project structure
MCP vs SkillsWhy MCP over Copilot Skills — benefits and downsides
Plain LLM vs MCPSide-by-side: what a plain LLM does vs. the MCP tool (4 scenarios)
Skills EquivalentWhat it'd take to cover this with Skills instead

Building & Testing

bash
dotnet builddotnet test    # 185+ tests — unit, integration, and E2E

CI runs on push/PR via GitHub Actions (Ubuntu + Windows).

Contributing

Contributions are welcome! Please open an issue to discuss proposed changes before submitting a PR.

bash
# Setupdotnet restoredotnet build
# Run testsdotnet test
# Pack locallydotnet pack src/DotnetTemplateMcp -o nupkg/

Changelog

See CHANGELOG.md for release history.

License

MIT

來源:README.md,提交 a8a4980

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v2.0.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分