@nest-mcp/nestjs 0.0.0-stage → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,205 @@
1
+ # @nest-mcp/nestjs
2
+
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 4ddbd56: First stable release of the 2.x line. The packages build on the v2 MCP TypeScript SDK, implement the `2026-07-28` protocol revision, target NestJS 12 and Node.js 22.13 or newer, and are ESM-only. From this release the line follows Semantic Versioning: no breaking changes to the public API within 2.x.
8
+
9
+ The 1.x line stays available under a `1` version range (`@nest-mcp/server@1`, `@nest-mcp/client@1`, `@nest-mcp/gateway@1`). 2.x has a different package layout and API, so moving to it is a migration rather than an in-place upgrade.
10
+
11
+ ### Minor Changes
12
+
13
+ - fea134c: Add optional static `httpRoutes` to `McpModule.forRoot` and `forRootAsync`. The module generates Nest
14
+ controllers for named MCP runtimes and optional OAuth resource discovery documents, preserving
15
+ class decorators, guards, interceptors, versioning, and the existing authenticated HTTP pipeline.
16
+ Applications can remove boilerplate MCP transport controllers while keeping their own consent,
17
+ upload, and other product routes. Existing controller factories and direct handlers remain supported.
18
+ - fea134c: Add process-local dynamic gateway topology with revision-fenced attach, detach, and atomic replace
19
+ operations. Dynamic gateways advertise list-change support from an empty topology while retaining
20
+ collision-free tool, prompt, resource, and resource-template routing.
21
+ - fea134c: **Breaking default:** MCP HTTP serving now applies a fail-closed security posture. Browser requests
22
+ from routable origins are rejected until their hostnames are listed in
23
+ `httpSecurity.allowedOriginHostnames` (requests without an `Origin` header are unaffected); opt out
24
+ entirely with `allowedOriginHostnames: false`. Request bodies are capped at 1 MiB by default
25
+ (`maxBodyBytes`), enforced on the raw Node stream before the SDK buffers it and again at the fetch
26
+ layer.
27
+
28
+ Added MCP-aware CORS: the 2026-07-28 revision's `Mcp-Method`/`Mcp-Name` headers make every browser
29
+ MCP POST CORS-preflighted, and the SDK handler answers preflights with 405 — the runtime now
30
+ answers them for allowed origins and decorates responses. `@nest-mcp/server/security` gains
31
+ `resolveMcpHttpSecurity`, `hardenMcpFetch`, `McpHardenedServer`, `withMcpNodeBodyLimit`, and the
32
+ `MCP_CORS_*` header constants; runtime observers see pre-dispatch rejections as `request:rejected`
33
+ events. `@nest-mcp/nestjs` adds `mcpCorsOptions()` for `app.enableCors()` and a
34
+ `getHttpSecurityOptions()` controller override that replaces the runtime posture for one route.
35
+
36
+ - fea134c: Bootstrap the Nest MCP v2 runtime, client, server, observability, gateway, and NestJS module packages.
37
+ - fea134c: Add a published, framework-neutral manager for bounded dynamic MCP client generations, including
38
+ deterministic draining, cleanup quarantine, key-free state lifecycle subscriptions, catalog and
39
+ operation delegation, a lease-scoped client-runtime integration callback, and optional lifecycle
40
+ observation for every managed client runtime.
41
+
42
+ Expose a thin Nest adapter at `@nest-mcp/nestjs/manager` with synchronous and asynchronous module
43
+ configuration, provider-token generation resolvers and observers, an injectable manager service,
44
+ and deterministic module shutdown.
45
+
46
+ - fea134c: Add a standalone Nest-owned `McpClientModule` and injectable `McpClientService` with synchronous
47
+ and asynchronous configuration, module-local collaborators, optional `bootstrap.connectAll`
48
+ connection, failed bootstrap rollback, and deterministic shutdown. The framework-neutral
49
+ `McpClientRuntime` remains directly constructible from `@nest-mcp/client`.
50
+
51
+ Compose outbound clients into `McpModule` through Nest module imports instead of embedding raw
52
+ client runtime options in the inbound server root. Resolve callback-bearing client, gateway, and
53
+ server collaborators from explicit singleton provider tokens, including transport/auth factories,
54
+ middleware and lifecycle observers, gateway codecs and caches, request-state verification, JSON
55
+ schema validators, and distributed server event buses. Context-aware gateway upstream selection is
56
+ now supplied by an injectable `McpGatewayClientProvider`; raw structural upstreams remain available
57
+ only from the framework-neutral gateway package. The neutral client's default implementation
58
+ identity now derives its version from package metadata so prerelease bumps cannot drift. Provider
59
+ binding also preserves client and gateway exact-transform identity and its typed continuation
60
+ guarantees.
61
+
62
+ `McpHttpControllerFor()` now accepts only the server name. Compose HTTP wrappers and Node-adapter
63
+ error reporting through the controller's protected overrides so those paths can use injected Nest
64
+ providers instead of factory-captured callbacks. Nest client configuration no longer accepts a raw
65
+ singleton `runtime.principal`; use the provider-backed `principalResolver` seam.
66
+
67
+ - fea134c: Narrow the Nest integration to a Nest-native public surface and remove redundant construction
68
+ aliases across the lower runtimes.
69
+
70
+ `@nest-mcp/nestjs` now exports its module, decorators, application services, Nest configuration types,
71
+ and a deliberately small set of callback helpers instead of mirroring every core, client, server,
72
+ gateway, and observability export. Import framework-neutral APIs from their owning packages.
73
+ `McpModule` is local by default, ordinary Nest modules replace `forFeature()`, low-level server
74
+ registration uses injectable contributors, server collaborators are configured through provider
75
+ tokens, catalog and gateway policies are singleton Nest providers, and internal registries/options
76
+ tokens are no longer public application services. A second configured root fails bootstrap; put all
77
+ clients and servers in the application's single shared root. Use `McpCapabilitiesService` for supported live
78
+ capability registration. Collaborators are explicitly registered under `McpModule` so Nest module
79
+ isolation and lifecycle ordering are preserved.
80
+
81
+ Remove the no-op `defineMcpServer`, `defineMcpServerFeature`, and
82
+ `defineMcpCatalogExposureResolver` helpers; use contextual typing or `satisfies` instead. Remove
83
+ the redundant `createMcpGateway`, `createMcpGatewayFeature`, and
84
+ `createDefaultMcpClientTransportFactory` factories; construct `McpGateway` directly and use the
85
+ shared default client transport factory. Remove `withMcpBearerAuth` and
86
+ `withMcpRequestValidation`; construct `McpResourceServer` and `McpValidatedServer` directly.
87
+
88
+ - fea134c: Add `@nest-mcp/auth`, a framework-neutral OAuth toolkit for MCP resource servers, and wire it into
89
+ the Nest adapter through a per-server `oauth` option group (Phase 1 of the authorization-server
90
+ proxy roadmap).
91
+
92
+ - **`@nest-mcp/auth`**: Client ID Metadata Document resolution (SEP-991) with strict URL admission,
93
+ document validation against `@modelcontextprotocol/core` schemas, and an SSRF-hardened `node:https`
94
+ fetcher that pins DNS at connect time (no `undici` dependency); a bounded, TTL-first
95
+ `McpOAuthStore` contract that maps onto Redis primitives, plus a capacity-rejecting in-memory
96
+ implementation; an asymmetric-by-default (EdDSA/ES256, HS256 for dev) JWT key ring, issuer, and
97
+ verifier with JWKS publication and algorithm pinning; `createMcpProxyTokenVerifier` and
98
+ `createJwksTokenVerifier` (`OAuthTokenVerifier`); and a token-free principal-claims projection.
99
+ Subpaths `./cimd`, `./stores`, and `./testing`; `jose` is an optional peer needed only for JWKS
100
+ verification.
101
+ - **`@nest-mcp/server`**: `McpResourceServer` gains an optional fail-closed `anonymous` policy,
102
+ consulted only after bearer verification refuses a request.
103
+ - **`@nest-mcp/nestjs`**: `McpNestServerDefinition.oauth.resource` composes `McpResourceServer` bearer
104
+ verification and RFC 9728/8414 metadata around the HTTP handler using injected provider tokens
105
+ (`verifier`, optional `anonymous`), exposed via `McpRuntimeService.composeHttpHandler()` and the
106
+ HTTP controller's default composition seam.
107
+
108
+ Adds the OAuth 2.1 **authorization-server proxy** in front of a real upstream IdP: `@nest-mcp/auth`
109
+ gains `McpOAuthProxy` (authorize → consent → callback → token, refresh rotation with reuse
110
+ detection, two-tier PKCE, RFC 8707 resource binding, RFC 9207 `iss` validation via the client SDK),
111
+ `createMcpOAuthRouter`, `McpOAuthServer`, `McpUpstreamAdapter` over the official client OAuth
112
+ helpers, provider presets (`googleUpstream`/`githubUpstream`/`azureUpstream`/`genericUpstream`), a
113
+ bounded `McpMemoryOAuthStore`, and an SSRF-guarded `createSsrfGuardedFetch`. `@nest-mcp/nestjs` adds the
114
+ `oauth.proxy` option group (all extensibility via provider tokens — no key material in options),
115
+ `McpOAuthControllerFor` (explicit per-endpoint routes, dispatch by handler identity), and
116
+ `McpOAuthService.upstreamTokens()` for gateway user-delegation. The proxy holds upstream tokens
117
+ server-side and mints its own EdDSA/ES256 access tokens, so the downstream MCP client never receives
118
+ an upstream credential. Adversarially reviewed (56-agent workflow); all confirmed findings fixed
119
+ before merge.
120
+
121
+ - fea134c: Rename the Nest capability decorators to `Tool`, `Prompt`, `Resource`, and `Targets`, and remove the redundant `Mcp` prefix from their option, definition, and method-decorator types. Module, runtime, and protocol-level names remain MCP-qualified.
122
+ - fea134c: Return a real Zod v4 schema from `createMcpClientToolSchema`. Its Zod refinement retains exact
123
+ Draft 2020-12 validation and identity parsing through the official MCP validator, while the schema
124
+ continues to implement Standard Schema and preserve the immutable, detached remote JSON Schema
125
+ definition. Explicit older dialects fail closed, and the previous async Standard Schema surface
126
+ remains compatible.
127
+ - fea134c: Publish `MCP_RUNTIME_PHASES` and `MCP_RUNTIME_PROTOCOL_ERAS` as frozen tuples that mirror the
128
+ `McpRuntimePhase` and `McpRuntimeProtocolEra` unions through a compile-time exhaustiveness fence,
129
+ together with `mcpRuntimeStateSnapshotSchema`, `mcpRuntimeProbeSnapshotSchema`, and
130
+ `mcpRuntimeCapabilitiesSnapshotSchema`. The validators implement Standard Schema v1 without adding
131
+ a runtime dependency: they accept exactly what the manager emits, reject unknown properties and
132
+ unpublished phases, eras, or state error codes, and return a frozen normalized snapshot so hosts
133
+ can validate persisted projections on the way back in.
134
+
135
+ Accept an `McpRuntimeToolCallOptions` object as the fourth `callTool` argument. A positional
136
+ `AbortSignal` stays source compatible as the cancellation-only form, and pinning `toolDefinition`
137
+ threads that exact definition to the managed client runtime so structured output is validated
138
+ against it instead of a cached `tools/list` view. `McpManagerService` from `@nest-mcp/nestjs/manager`
139
+ inherits the widened call surface.
140
+
141
+ - fea134c: Add authorization-safe per-request tool catalog exposure for Nest servers and exact method- or
142
+ operation-specific transform helpers for client and gateway middleware. Manual input-required
143
+ client calls now expose their continuation result in method-keyed and high-level return types.
144
+
145
+ ### Patch Changes
146
+
147
+ - fea134c: Add opt-in bounded concurrent admission across process and connector capacity, nullable connector ceilings, fair FIFO scheduling across connector keys, and distinct queue-full and admission-timeout diagnostics. Reserve transports against the existing lease ledger and retain charges through cleanup; cancellation, retirement, and shutdown remove queued work without redispatch. Expose key-free admission timing and capacity notifications.
148
+ - fea134c: Declare `@nest-mcp/auth` as a runtime dependency so production installs can import the built Nest
149
+ module's OAuth integration without relying on development dependencies. Add a first-class
150
+ `@nest-mcp/nestjs/client` entrypoint for outbound-only Nest applications without loading inbound server,
151
+ gateway, or OAuth implementation code.
152
+ - fea134c: Declare stable NestJS 12 peer support and refresh the validated dependency toolchain.
153
+ - fea134c: Publish fixed-group packages sequentially and verify each registry tarball before continuing so
154
+ trusted-publisher credential exchanges cannot leave a release only partially available.
155
+ - fea134c: Support explicit tools-only gateway composition with local MCP handlers on one authenticated server. Gateway and native tool policies remain independent, SDK registrations reject exact name collisions, and local prompts/resources retain their handlers.
156
+ - Updated dependencies [fea134c]
157
+ - Updated dependencies [fea134c]
158
+ - Updated dependencies [fea134c]
159
+ - Updated dependencies [4ddbd56]
160
+ - Updated dependencies [fea134c]
161
+ - Updated dependencies [fea134c]
162
+ - Updated dependencies [fea134c]
163
+ - Updated dependencies [fea134c]
164
+ - Updated dependencies [fea134c]
165
+ - Updated dependencies [fea134c]
166
+ - Updated dependencies [fea134c]
167
+ - Updated dependencies [fea134c]
168
+ - Updated dependencies [fea134c]
169
+ - Updated dependencies [fea134c]
170
+ - Updated dependencies [fea134c]
171
+ - Updated dependencies [fea134c]
172
+ - Updated dependencies [fea134c]
173
+ - Updated dependencies [fea134c]
174
+ - Updated dependencies [fea134c]
175
+ - Updated dependencies [fea134c]
176
+ - Updated dependencies [fea134c]
177
+ - Updated dependencies [fea134c]
178
+ - Updated dependencies [fea134c]
179
+ - Updated dependencies [fea134c]
180
+ - Updated dependencies [fea134c]
181
+ - Updated dependencies [fea134c]
182
+ - Updated dependencies [fea134c]
183
+ - Updated dependencies [fea134c]
184
+ - Updated dependencies [fea134c]
185
+ - Updated dependencies [fea134c]
186
+ - Updated dependencies [fea134c]
187
+ - Updated dependencies [fea134c]
188
+ - Updated dependencies [fea134c]
189
+ - Updated dependencies [fea134c]
190
+ - Updated dependencies [fea134c]
191
+ - Updated dependencies [fea134c]
192
+ - Updated dependencies [fea134c]
193
+ - Updated dependencies [fea134c]
194
+ - @nest-mcp/auth@2.0.0
195
+ - @nest-mcp/server@2.0.0
196
+ - @nest-mcp/core@2.0.0
197
+ - @nest-mcp/client@2.0.0
198
+ - @nest-mcp/manager@2.0.0
199
+ - @nest-mcp/gateway@2.0.0
200
+
201
+ ## 2.0.0-alpha.0
202
+
203
+ ### Major Changes
204
+
205
+ - First prerelease of the 2.x line, built on the official MCP TypeScript SDK v2 and NestJS 12.
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, btwld
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.