@nest-mcp/client 1.0.1 → 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.
Files changed (54) hide show
  1. package/CHANGELOG.md +139 -0
  2. package/README.md +845 -69
  3. package/dist/ai-sdk/index.d.mts +14 -0
  4. package/dist/ai-sdk/index.d.mts.map +1 -0
  5. package/dist/ai-sdk/index.mjs +27 -0
  6. package/dist/ai-sdk/index.mjs.map +1 -0
  7. package/dist/bootstrap-BIAcDnHp.d.mts +394 -0
  8. package/dist/bootstrap-BIAcDnHp.d.mts.map +1 -0
  9. package/dist/index.d.mts +480 -0
  10. package/dist/index.d.mts.map +1 -0
  11. package/dist/index.mjs +1960 -0
  12. package/dist/index.mjs.map +1 -0
  13. package/dist/oauth/dynamic-registration.d.mts +92 -0
  14. package/dist/oauth/dynamic-registration.d.mts.map +1 -0
  15. package/dist/oauth/dynamic-registration.mjs +392 -0
  16. package/dist/oauth/dynamic-registration.mjs.map +1 -0
  17. package/dist/oauth/index.d.mts +422 -0
  18. package/dist/oauth/index.d.mts.map +1 -0
  19. package/dist/oauth/index.mjs +3349 -0
  20. package/dist/oauth/index.mjs.map +1 -0
  21. package/dist/scope-CxGBCDdr.mjs +22 -0
  22. package/dist/scope-CxGBCDdr.mjs.map +1 -0
  23. package/package.json +76 -50
  24. package/scripts/external-smoke.mjs +693 -0
  25. package/dist/decorators/inject-mcp-client.decorator.d.ts +0 -3
  26. package/dist/decorators/inject-mcp-client.decorator.js +0 -12
  27. package/dist/decorators/on-notification.decorator.d.ts +0 -7
  28. package/dist/decorators/on-notification.decorator.js +0 -13
  29. package/dist/health/mcp-client.health.d.ts +0 -20
  30. package/dist/health/mcp-client.health.js +0 -42
  31. package/dist/index.d.ts +0 -21
  32. package/dist/index.js +0 -64
  33. package/dist/interfaces/client-options.interface.d.ts +0 -139
  34. package/dist/interfaces/client-options.interface.js +0 -3
  35. package/dist/mcp-client.module.d.ts +0 -20
  36. package/dist/mcp-client.module.js +0 -188
  37. package/dist/mcp-client.service.d.ts +0 -558
  38. package/dist/mcp-client.service.js +0 -532
  39. package/dist/mcp-clients.service.d.ts +0 -39
  40. package/dist/mcp-clients.service.js +0 -104
  41. package/dist/testing/mock-client.d.ts +0 -67
  42. package/dist/testing/mock-client.js +0 -154
  43. package/dist/transport/apply-auth-headers.d.ts +0 -3
  44. package/dist/transport/apply-auth-headers.js +0 -13
  45. package/dist/transport/client-transport.factory.d.ts +0 -4
  46. package/dist/transport/client-transport.factory.js +0 -21
  47. package/dist/transport/sse-client.transport.d.ts +0 -4
  48. package/dist/transport/sse-client.transport.js +0 -15
  49. package/dist/transport/stdio-client.transport.d.ts +0 -4
  50. package/dist/transport/stdio-client.transport.js +0 -14
  51. package/dist/transport/streamable-client.transport.d.ts +0 -4
  52. package/dist/transport/streamable-client.transport.js +0 -17
  53. package/dist/utils/format-error-message.d.ts +0 -2
  54. package/dist/utils/format-error-message.js +0 -7
package/CHANGELOG.md ADDED
@@ -0,0 +1,139 @@
1
+ # @nest-mcp/client
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: Bootstrap the Nest MCP v2 runtime, client, server, observability, gateway, and NestJS module packages.
14
+ - fea134c: Narrow the Nest integration to a Nest-native public surface and remove redundant construction
15
+ aliases across the lower runtimes.
16
+
17
+ `@nest-mcp/nestjs` now exports its module, decorators, application services, Nest configuration types,
18
+ and a deliberately small set of callback helpers instead of mirroring every core, client, server,
19
+ gateway, and observability export. Import framework-neutral APIs from their owning packages.
20
+ `McpModule` is local by default, ordinary Nest modules replace `forFeature()`, low-level server
21
+ registration uses injectable contributors, server collaborators are configured through provider
22
+ tokens, catalog and gateway policies are singleton Nest providers, and internal registries/options
23
+ tokens are no longer public application services. A second configured root fails bootstrap; put all
24
+ clients and servers in the application's single shared root. Use `McpCapabilitiesService` for supported live
25
+ capability registration. Collaborators are explicitly registered under `McpModule` so Nest module
26
+ isolation and lifecycle ordering are preserved.
27
+
28
+ Remove the no-op `defineMcpServer`, `defineMcpServerFeature`, and
29
+ `defineMcpCatalogExposureResolver` helpers; use contextual typing or `satisfies` instead. Remove
30
+ the redundant `createMcpGateway`, `createMcpGatewayFeature`, and
31
+ `createDefaultMcpClientTransportFactory` factories; construct `McpGateway` directly and use the
32
+ shared default client transport factory. Remove `withMcpBearerAuth` and
33
+ `withMcpRequestValidation`; construct `McpResourceServer` and `McpValidatedServer` directly.
34
+
35
+ - fea134c: Add a pure OAuth provisioning planner over captured discovery, public client provenance, and explicit host strategy order, plus a bounded challenge probe over host-admitted fetch. Hosts retain credential custody, browser consent, endpoint admission, atomic state transitions, and registration dispatch fences.
36
+
37
+ Expose configurable duration histogram arithmetic with JSON-safe, geometry-checked snapshots and lossless sufficient-statistic merging. The fixed-memory collector now shares this arithmetic with durable consumers without selecting their persistence, dimensions, or telemetry policy.
38
+
39
+ - fea134c: Add a bounded, framework-neutral `McpClientLeaseManager` for opaque, non-secret identity keys. It
40
+ deduplicates concurrent resource creation, maintains active reference counts, drains retired
41
+ generations safely, supports explicit idle reuse, and defaults every resource to close on final
42
+ release.
43
+ - fea134c: Add passive MCP authentication detection over host-admitted fetch. Validate anonymous modern discovery or a complete legacy handshake through the official SDK, or require validated OAuth bootstrap evidence after an authorization denial. Keep unsupported authentication, unreachable endpoints, invalid responses, and failed metadata discovery indeterminate. Bound streaming response reads, deadlines, and legacy session cleanup without performing registration, token acquisition, or feature invocation.
44
+
45
+ Hosts may supply a separate guarded OAuth metadata fetch while retaining endpoint-only admission for MCP traffic. Existing challenge probing and OAuth enrollment APIs are unchanged.
46
+
47
+ - fea134c: Add bounded OAuth storage snapshot parsers, passive catalog inspection, and exact tool catalog preparation so hosts can consume shared MCP mechanics without reimplementing them.
48
+
49
+ The client OAuth surface parses authorities, authorization transactions (including authority-digest verification), and bootstrap discovery results as detached immutable values. Parsing performs no network I/O and does not replace host endpoint admission, credential encryption, callback/session binding, expiry, or atomic transaction consumption.
50
+
51
+ The client provides fresh bounded raw discovery on an already acquired runtime and a per-run inspection target. Conformance provides seven passive discovery checks, ambiguity-first tool selection, exact definition capture, and domain-separated input/output schema identities. The conformance kernel remains independent of the SDK, client, manager, Nest, and product state; the client reuses its existing bounded capture implementation.
52
+
53
+ Manager refresh retains official SDK aggregation, cache population, and protocol filtering. Passive inspection intentionally inspects raw definitions and does not populate that execution cache.
54
+
55
+ - fea134c: Return a real Zod v4 schema from `createMcpClientToolSchema`. Its Zod refinement retains exact
56
+ Draft 2020-12 validation and identity parsing through the official MCP validator, while the schema
57
+ continues to implement Standard Schema and preserve the immutable, detached remote JSON Schema
58
+ definition. Explicit older dialects fail closed, and the previous async Standard Schema surface
59
+ remains compatible.
60
+ - fea134c: Add authorization-safe per-request tool catalog exposure for Nest servers and exact method- or
61
+ operation-specific transform helpers for client and gateway middleware. Manual input-required
62
+ client calls now expose their continuation result in method-keyed and high-level return types.
63
+ - fea134c: Add a dedicated `@nest-mcp/client/oauth` surface for strict, host-managed outbound OAuth. It
64
+ provides exact resource and issuer discovery, mandatory endpoint policy checks, PKCE and
65
+ digest-only state transactions, pre-registered client authentication, revisioned credential CAS,
66
+ durable pre-dispatch refresh claims, bounded refresh coordination, invalidation hooks for runtime
67
+ lease eviction, and a per-binding minimal transport provider without implicit redirects or Dynamic
68
+ Client Registration.
69
+ - fea134c: Add opt-in bounded FIFO admission for exclusive operations with `exclusiveContention: "queue"`.
70
+ Concurrent callers each acquire fresh admitted transport material after prior cleanup, while the
71
+ existing exclusive default remains fail-fast. Queue waiting shares the request deadline, respects
72
+ caller cancellation, and is fenced by retirement, shutdown, and cleanup quarantine. Expose a global
73
+ `maxQueuedOperations` bound and key-free queue diagnostics.
74
+
75
+ Add `awaitCleanupOnCancel` to client lease acquisition. Exclusive manager operations select it so
76
+ cancellation during acquisition drains their abandoned material before a queued operation starts;
77
+ ordinary client acquisitions retain immediate, caller-local cancellation by default.
78
+
79
+ - fea134c: Add a host-managed OAuth bootstrap that parses bounded Bearer challenges, discovers
80
+ protected-resource and authorization-server metadata, returns explicit issuer-selection and
81
+ strict-compatibility results, honors challenged scope priority, and exposes CIMD and legacy DCR
82
+ capabilities without performing registration. Add an explicit dynamic-registration compatibility
83
+ subpath that performs one policy-approved public-client registration POST without retries or host
84
+ state.
85
+
86
+ ### Patch Changes
87
+
88
+ - fea134c: Add the optional AI SDK tool adapter for sanitized descriptors and host-protected invocation, preserving exact names, inputs and cancellation without adding AI to core consumers.
89
+ - 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.
90
+ - fea134c: Accept OAuth authorization servers that do not advertise RFC 9207 response issuer support. The
91
+ callback still requires an exact `iss` when support is advertised and rejects every mismatched
92
+ `iss` value when one is returned.
93
+ - fea134c: Allow native OAuth clients to use RFC 8252 loopback HTTP redirect URIs throughout authorization and token exchange while continuing to reject non-loopback HTTP callbacks.
94
+ - fea134c: Add a standalone Nest-owned `McpClientModule` and injectable `McpClientService` with synchronous
95
+ and asynchronous configuration, module-local collaborators, optional `bootstrap.connectAll`
96
+ connection, failed bootstrap rollback, and deterministic shutdown. The framework-neutral
97
+ `McpClientRuntime` remains directly constructible from `@nest-mcp/client`.
98
+
99
+ Compose outbound clients into `McpModule` through Nest module imports instead of embedding raw
100
+ client runtime options in the inbound server root. Resolve callback-bearing client, gateway, and
101
+ server collaborators from explicit singleton provider tokens, including transport/auth factories,
102
+ middleware and lifecycle observers, gateway codecs and caches, request-state verification, JSON
103
+ schema validators, and distributed server event buses. Context-aware gateway upstream selection is
104
+ now supplied by an injectable `McpGatewayClientProvider`; raw structural upstreams remain available
105
+ only from the framework-neutral gateway package. The neutral client's default implementation
106
+ identity now derives its version from package metadata so prerelease bumps cannot drift. Provider
107
+ binding also preserves client and gateway exact-transform identity and its typed continuation
108
+ guarantees.
109
+
110
+ `McpHttpControllerFor()` now accepts only the server name. Compose HTTP wrappers and Node-adapter
111
+ error reporting through the controller's protected overrides so those paths can use injected Nest
112
+ providers instead of factory-captured callbacks. Nest client configuration no longer accepts a raw
113
+ singleton `runtime.principal`; use the provider-backed `principalResolver` seam.
114
+
115
+ - fea134c: Preserve optional MCP tool fields by explicitly disabling provider strict-schema normalization in the AI SDK adapter. This prevents Responses API calls from requiring optional or mutually exclusive query options. Inputs and protected execution validation remain unchanged; consumers require no code changes.
116
+ - fea134c: Add an optional exact credential revision to the minimal OAuth auth provider. Pinned operations fail closed after rotation, and delayed concurrent authentication failures cannot refresh or adopt a replacement credential. Existing unpinned providers retain their binding-following behavior.
117
+ - fea134c: Accept successful legacy dynamic-registration responses that follow the MCP SDK schema while still rejecting conflicting security-sensitive metadata.
118
+ - fea134c: Enforce the RFC 6749 ASCII NQCHAR grammar for configured, discovered, registered, and returned
119
+ OAuth scope tokens, while preserving valid punctuation such as commas. Token exchange now retains
120
+ the pinned requested scope when the response omits it; refresh can retain a caller-supplied current
121
+ scope, and both flows reject an explicit scope that widens the bound grant.
122
+ - Updated dependencies [4ddbd56]
123
+ - Updated dependencies [fea134c]
124
+ - Updated dependencies [fea134c]
125
+ - Updated dependencies [fea134c]
126
+ - Updated dependencies [fea134c]
127
+ - Updated dependencies [fea134c]
128
+ - Updated dependencies [fea134c]
129
+ - Updated dependencies [fea134c]
130
+ - Updated dependencies [fea134c]
131
+ - Updated dependencies [fea134c]
132
+ - @nest-mcp/core@2.0.0
133
+ - @nest-mcp/conformance@2.0.0
134
+
135
+ ## 2.0.0-alpha.0
136
+
137
+ ### Major Changes
138
+
139
+ - First prerelease of the 2.x line, built on the official MCP TypeScript SDK v2 and NestJS 12.