NestJS MCP Server Module
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Integrations
Provides a module for NestJS to create an MCP (Model Context Protocol) server with Server-Sent Events (SSE) transport, allowing services to be exposed as tools that clients can discover and execute.
Enables sending continuous progress updates from tools to clients, allowing for tracking of long-running operations with percentage completion indicators.
Integrates Zod schema validation for tool requests, enabling type-safe parameter validation for tools exposed through the MCP server.
NestJS MCP Server Module
A NestJS module for exposing your services as an MCP (Model Context Protocol) server with Server-Sent Events (SSE) transport. This package simplifies exposing tools that clients can discover and execute via SSE.
Features
- SSE Transport: Built-in
/sse
endpoint for streaming and/messages
for handling tool execution - Tool Discovery: Automatically discover and register tools using decorators
- Tool Request Validation: Define Zod schemas to validate tool requests.
- Progress Notifications: Send continuous progress updates from tools to clients.
Installation
Quick Start
1. Import Module
2. Define Tools
You are done!
Client Connection
Clients can connect using the MCP SDK:
API Endpoints
GET /sse
: SSE connection endpointPOST /messages
: Tool execution endpoint
Configuration Reference
McpOptions
Property | Type | Description | Default Value |
---|---|---|---|
name | string | Server name | - |
version | string | Server version | - |
capabilities | Record<string, any> | Server capabilities, defines what the server can do. | {} |
sseEndpoint | string (optional) | Endpoint for SSE connections. | 'sse' |
messagesEndpoint | string (optional) | Endpoint for handling tool execution. | 'messages' |
globalApiPrefix | string (optional) | Global API prefix for all endpoints. | '' |
Tool Decorator
The @Tool
decorator is used to define a method as an MCP tool.
name
: The name of the tool. This will be used to list it in thelistTools
request.description
: A description of the tool.parameters
: (Optional) A Zod schema defining the expected structure of the tool's input arguments.
This server cannot be installed
A NestJS module that allows services to be exposed as an MCP server with Server-Sent Events transport, facilitating tool discovery and execution by clients.