
A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

A NestJS module that instantiates MCP server instances and manages SSE transports, letting developers focus on writing MCP tools.
NestJS dynamic module for building MCP servers over SSE transport is cataloged as an MCP server attributed to hxiny499. A NestJS module that instantiates MCP server instances and manages SSE transports, letting developers focus on writing MCP tools. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.
Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.
Catalog license label: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.
Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.
No reviewed records to display. This does not establish that upstream lacks this capability.
No reviewed records to display. This does not establish that upstream lacks this capability.
No reviewed records to display. This does not establish that upstream lacks this capability.
Email delivery is not connected. This page does not collect email addresses or create subscriptions.
Browse the registry for current listings instead.
Reviews for NestJS dynamic module for building MCP servers over SSE transport are not available yet
Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.
README.md · 9b7a38eb530a · Fetched 2026-11-13 10:30:53 UTC
Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.
Showing the last retrieved documentation snapshot; check the source for current changes.
这是一个用于在 NestJS 工程下快速开发 SSE 传输类型 McpServer 的动态模块,使用此模块,你将无需理会连接 Transport、生命周期管理、McpServer 实例化等杂事,聚焦于 MCP tool 的开发。
此模块没有过度封装🥳
只做了 MCP Server 实例管理和 SSE Transport 管理,没有对官方 sdk 的原生 MCP Server 的方法做任何封装,尽可能不增加学习成本。
# npm
npm install nest-mcp-sse @modelcontextprotocol/sdk zod
# yarn
yarn add nest-mcp-sse @modelcontextprotocol/sdk zod
# pnpm
pnpm add nest-mcp-sse @modelcontextprotocol/sdk zod
在你的模块中导入 McpModule
import { Module } from "@nestjs/common";
import { McpModule } from "nest-mcp-sse";
@Module({
imports: [
McpModule.register({
controllerBaseUrl: "api/mcp",
mcpServerConfigs: [
{
serverId: "my-mcp-server",
serverInfo: {
name: "my-mcp-server",
version: "1.0.0",
},
},
],
}),
],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
另外,你也可以通过forRoot和forFeature导入模块,区别如下:
创建 MCP Server 之后,你可以通过getServer方法获取到官方 sdk 的原生 MCP Server 实例,这个实例没有任何封装,完全是原生的。
比如,你可以注册工具
import { Controller } from "@nestjs/common";
import { McpServerService } from "nest-mcp-sse";
import { z } from "zod";
@Controller()
export class AppController {
constructor(private readonly mcpServerService: McpServerService) {
this.mcpServerService.getServer("server-id")?.tool(
"get-current-time",
{
format: z
.enum(["iso", "locale", "unix"])
.optional()
.default("iso")
.describe("时间格式: iso, locale, 或 unix"),
},
async ({ format }: { format: "iso" | "locale" | "unix" }) => {
const now = new Date();
let timeValue: string | number;
switch (format) {
case "iso":
timeValue = now.toISOString();
break;
case "locale":
timeValue = now.toLocaleString();
break;
case "unix":
timeValue = now.getTime();
break;
default:
timeValue = now.toISOString();
}
return {
content: [{ type: "text", text: String(timeValue) }],
};
}
);
}
}
上面的例子直接在McpModule.register中传入了mcpServerConfigs,这会在模块初始化时就创建 MCP Server。
当然这不是必需的,你可以不传入mcpServerConfigs,在 Controller 或 Service 中手动注册 MCP Server:
import { Controller } from "@nestjs/common";
import { McpServerService } from "nest-mcp-sse";
import { z } from "zod";
@Controller()
export class AppController {
constructor(private readonly mcpServerService: McpServerService) {
// 手动注册一个MCP Server实例
this.mcpServerService.registerServer({
serverId: "another-server",
serverInfo: {
name: "another-mcp-server",
version: "1.0.0",
},
});
}
}
注册模块后,将自动创建以下端点:
/{controllerBaseUrl}/{serverId}/sse/{controllerBaseUrl}/{serverId}/messages例如,如果你使用 controllerBaseUrl: 'api/mcp' 和 serverId: 'my-mcp-server',则访问 URL 为:
http://localhost:3000/api/mcp/my-mcp-server/sse - 用于 SSE 连接http://localhost:3000/api/mcp/my-mcp-server/messages - 用于消息处理ssemessagesforRoot 同 register,forFeature 只接收 mcpServerConfigs
McpModule 导出的 Service,用于管理多个 McpServer 实例。
你可以注入到你的 Controller 或 Service 中,使用以下方法:
McpModule.forRoot的mcpServerConfigsstring[] 所有已注册的 McpServer 实例 id 数组McpModule 导出的 Service,用于管理多个 SSEServerTransport 实例。
通常不需要使用,除非你希望手动管理连接。
以下仅列出可能使用到的方法,更多方法请参阅源码
string[] 所有活跃会话 ID 数组你可以在模块注册时自定义 SSE 和消息端点名称:
McpModule.register({
controllerBaseUrl: "api/mcp",
sseEndpoint: "connect", // 默认为 'sse'
messagesEndpoint: "rpc", // 默认为 'messages'
mcpServerConfigs: [
/* ... */
],
});
你可以 clone 该仓库,按以下步骤运行示例代码
pnpm install
cd example
pnpm install
pnpm start
Claim this server with your GitHub account to request manual ownership verification.
Link to the catalog listing for NestJS dynamic module for building MCP servers over SSE transport from your README. This badge does not certify ownership, compatibility or security.
[](https://awesome-mcp.com/servers/nest-mcp-sse)Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.
Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.
No reviewed package or image identity; download statistics are not listed yet.
Alternative and complementary servers in the same category

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.