You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Adds support for custom controllers
* Adds example using custom controllers with the advanced server
* Adds support for async configuration
* bump version to 1.8.1
@@ -5,7 +5,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
5
5
# NestJS MCP Server Module
6
6
7
7
## Project Overview
8
-
This is `@rekog/mcp-nest`, a NestJS module that transforms NestJS applications into Model Context Protocol (MCP) servers. It exposes tools, resources, and prompts for AI consumption via decorators, supporting multiple transport protocols (HTTP+SSE, Streamable HTTP, STDIO).
8
+
This is `@rekog/mcp-nest`, a NestJS module that transforms NestJS applications into Model Context Protocol (MCP) servers. It exposes tools, resources, and prompts for AI consumption via decorators, supporting multiple transport protocols (HTTP+SSE, Streamable HTTP, STDIO) with optional OAuth 2.1 authentication.
9
9
10
10
## Essential Development Commands
11
11
@@ -34,10 +34,51 @@ npx --node-options=--experimental-vm-modules jest tests/mcp-tool.e2e.spec.ts
34
34
npx --node-options=--experimental-vm-modules jest --testNamePattern="auth"
35
35
```
36
36
37
-
## Core Architecture Patterns
37
+
## Core Components
38
38
39
-
### 1. Decorator-Based Registration System
40
-
Tools, resources, and prompts are discovered through decorators using NestJS's reflection capabilities:
39
+
### 1. McpModule - The Primary MCP Server Module
40
+
Located at `src/mcp/mcp.module.ts:18`. This is the main module for creating MCP servers.
41
+
42
+
**Key Features**:
43
+
- Decorator-based tool/resource/prompt discovery via `McpRegistryService`
44
+
- Multi-transport support (HTTP+SSE, Streamable HTTP, STDIO)
45
+
- Dynamic controller generation for different transport types
46
+
- Module instance isolation with unique `moduleId` per `forRoot()` call
MCP tools should return standardized error format:
146
-
```typescript
147
-
return {
148
-
content: [{ type: 'text', text: error.message }],
149
-
isError: true,
150
-
};
151
-
```
152
-
153
-
### Registry Service Pattern
154
-
`McpRegistryService` discovers decorated methods at bootstrap using `DiscoveryService` and `MetadataScanner`. It maintains maps by `mcpModuleId` for isolation.
-`typeorm` (optional) - Database storage for OAuth data
227
+
228
+
## Key Architecture Principles
229
+
230
+
### Transform Pattern
231
+
The module transforms existing NestJS services into MCP servers through decorators, making business logic available to AI systems without modification.
232
+
233
+
### Transport Agnostic
234
+
Each `McpModule.forRoot()` can serve multiple transport protocols simultaneously, with clients choosing their preferred connection method.
235
+
236
+
### Security Integration
237
+
Authentication is handled at the transport level via NestJS Guards, ensuring all MCP endpoints respect the same security policies as the rest of the application.
178
238
179
-
## Important Notes from Copilot Instructions
239
+
### Stateful vs Stateless
240
+
Supports both stateful (session-based) and stateless operation modes, with configurable session ID generation for multi-user scenarios.
180
241
181
-
- This module transforms NestJS services into MCP servers through decorators, not the other way around
182
-
- The NestJS application hosts the MCP server, making existing business logic available to AI systems
183
-
- Each `McpModule.forRoot()` creates an isolated instance with unique endpoints
184
-
- Authentication uses standard NestJS Guards applied at the transport level
185
-
- Progress reporting is handled through the MCP context object passed to tools
242
+
- don't run linting, I don't care about it or formatting
Copy file name to clipboardExpand all lines: docs/README.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,10 @@
7
7
-[Resources Guide](./resources.md) — Defining and exposing resources.
8
8
-[Dependency Injection](docs/dependency-injection.md) — Leverage NestJS DI system throughout MCP components.
9
9
10
+
### Advanced Usage
11
+
12
+
-[Advanced Server Pattern](../playground/servers/advanced/README.md) — Direct service usage with custom controllers for maximum control over interceptors, guards, middleware, and endpoint configuration.
13
+
10
14
### OAuth & Authorization
11
15
12
16
-[Built-in Authorization Server](./built-in-authorization-server.md) — Using the built-in Authorization Server for simpler setups.
0 commit comments