Token导航 LogoToken导航TokenDH.com
Aspire MCP Templates logo
开发工具未说明官方级别未说明来源级核验

Aspire MCP Templates

MCP Server

提供用于将Model Context Protocol (MCP)服务器与.NET Aspire和MCP Inspector集成的模板和可重用组件。

工具数

0

提示词数

0

GitHub Stars

1

资源数

0
开发工具C#本地部署

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

JakeRadMSFT

提供方

JakeRadMSFT

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

Aspire MCP模板

此存储库提供模板和可重用组件,用于将模型上下文协议(MCP)服务器与集成。NET Aspire和MCP检查器。

概述

存储库分为两个主要部分:

可重用组件

这些库可以在任何地方使用。NET项目添加MCP和Aspire集成:

  • Mcp.NamedPipeTransport -MCP服务器的命名管道服务器传输实现
  • Mcp.NamedPipeProxy -用于将MCP检查器连接到基于Stdio的MCP服务器的命名管桥
  • Mcp.Aspire.McpInspector -Aspire AppHost扩展用于添加MCP检查器集成
  • Mcp.AspireIntegration -用于透明Aspire支持的MCP服务器扩展

模板

AspireWithMcp/ -与集成的MCP服务器的完整工作示例。NET Aspire:

  • AspireWithMcp。McpServer -支持Aspire Inspector的MCP服务器
  • AspireWithMcp。AppHost -使用MCP服务器和检查器进行Aspire编排
  • AspireWithMcp。服务默认值 -标准Aspire服务默认值

入门指南

先决条件

  • .NET 9.0 SDK
  • MCP检查员 全局安装: npm install -g @modelcontextprotocol/inspector

运行模板

  1. 克隆此存储库:
   git clone https://github.com/JakeRadMSFT/Aspire-MCP-Templates.git
   cd Aspire-MCP-Templates
  1. 构建解决方案:
   dotnet build AspireWithMcp/AspireWithMcp.sln
  1. 运行Aspire AppHost:
   dotnet run --project AspireWithMcp/AspireWithMcp.AppHost
  1. 打开Aspire仪表板(控制台输出中显示的URL)
  1. MCP检查器将自动启动并连接到MCP服务器

运作原理

MCP服务器集成

MCP服务器使用一个简单的扩展来启用Aspire集成:

builder.Services
    .AddMcpServer()
    .WithStdioServerTransport()
    .WithTools()
    .WithAspireMcpInspectorSupport();  // Enables Aspire integration

.WithAspireMcpInspectorSupport() 扩展名:

  • 在Aspire中运行时检测(通过 --pipe-name 论点)
  • 透明地将stdio传输替换为命名管道传输
  • 允许MCP服务器代码保持不变

AppHost配置

Aspire AppHost连接MCP服务器和检查器:

// Add MCP server with named pipe argument
var mcpServer = builder.AddProject
("mcp-server")
    .WithArgs(["--pipe-name=aspire-mcp-server"]);

// Add MCP Inspector that connects via proxy
var proxyPath = Path.GetFullPath("../../Mcp.NamedPipeProxy/bin/Debug/net9.0/Mcp.NamedPipeProxy.exe");
builder.AddMcpInspector("mcp-inspector", mcpServer, proxyPath, "aspire-mcp-server");

建筑


   MCP Inspector     
   (Web UI)          

            stdio

  NamedPipeProxy     
  (stdio  pipes)    

            named pipes

   MCP Server        
  (NamedPipe         
   Transport)        
  1. MCP服务器 由Aspire启动时,使用命名管道传输运行
  2. NamedPipeProxy 将stdio(由检查员使用)连接到指定的管道
  3. MCP检查员 通过stdio连接到代理并提供web UI

使用可重用组件

在您的MCP服务器中

  1. 添加包引用:
   dotnet add package ModelContextProtocol
   dotnet add reference path/to/Mcp.AspireIntegration/Mcp.AspireIntegration.csproj
  1. 将扩展添加到MCP服务器:
   builder.Services
       .AddMcpServer()
       .WithStdioServerTransport()
       .WithTools()
       .WithAspireMcpInspectorSupport();

在您的Aspire AppHost中

  1. 添加项目引用:
   dotnet add reference path/to/Mcp.Aspire.McpInspector/Mcp.Aspire.McpInspector.csproj
  1. 配置AppHost:
   using Mcp.Aspire.McpInspector;

   var mcpServer = builder.AddProject
("mcp-server")
       .WithArgs(["--pipe-name=your-pipe-name"]);

   var proxyPath = "path/to/Mcp.NamedPipeProxy.exe";
   builder.AddMcpInspector("mcp-inspector", mcpServer, proxyPath, "your-pipe-name");

组件详细信息

麦克。名称管道运输

提供 WithNamedPipeServerTransport() MCP服务器使用命名管道而不是stdio的扩展。使用双管架构(单独的输入/输出管道)进行双向通信。

麦克。NamedPipeProxy

将MCP服务器的stdio连接到命名管道的控制台应用程序。接受 --pipe-name= argument并创建两个管道: ` (输入)和 -out` (输出)。

麦克。向往。McpInspector

Aspire扩展,将MCP Inspector添加到您的分布式应用程序中。这 AddMcpInspector() 方法:

  • 启动MCP检查器(需要全局npm安装)
  • 通过NamedPipeProxy将其连接到MCP服务器
  • 管理依赖关系以确保正确的启动顺序

麦克。Aspire集成

提供 WithAspireMcpInspectorSupport() MCP服务器的扩展。当 --pipe-name 检测到:

  • 从DI中删除stdio传输
  • 改为添加命名管道传输
  • 记录传输覆盖

许可证

MIT许可证-有关详细信息,请参阅许可证文件

贡献

欢迎投稿!请随时提交问题和拉取请求。

目录标签

目录标签

开发工具C#本地部署MCP服务器集成模板Aspire集成MCPInspector

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP