@nest-mcp/nestjs 0.0.0-stage → 2.0.0-alpha.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 +7 -0
- package/LICENSE +28 -0
- package/README.md +768 -2
- package/dist/client/index.d.mts +3 -0
- package/dist/client/index.mjs +3 -0
- package/dist/decorateParam-DrdHz1Pv.mjs +127 -0
- package/dist/decorateParam-DrdHz1Pv.mjs.map +1 -0
- package/dist/index.d.mts +716 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +2262 -0
- package/dist/index.mjs.map +1 -0
- package/dist/manager/index.d.mts +47 -0
- package/dist/manager/index.d.mts.map +1 -0
- package/dist/manager/index.mjs +76 -0
- package/dist/manager/index.mjs.map +1 -0
- package/dist/mcp-client.module-D-EYsz9Y.mjs +220 -0
- package/dist/mcp-client.module-D-EYsz9Y.mjs.map +1 -0
- package/dist/mcp-client.service-kXzXDpg6.d.mts +132 -0
- package/dist/mcp-client.service-kXzXDpg6.d.mts.map +1 -0
- package/dist/mcp-provider.registry-dnQfMj1w.d.mts +29 -0
- package/dist/mcp-provider.registry-dnQfMj1w.d.mts.map +1 -0
- package/dist/testing/index.d.mts +2 -0
- package/dist/testing/index.mjs +2 -0
- package/package.json +89 -3
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,716 @@
|
|
|
1
|
+
import { a as McpModuleErrorCode, i as McpModuleError, n as McpNestCollaborators, r as McpProviderToken, t as McpProviderRegistry } from "./mcp-provider.registry-dnQfMj1w.mjs";
|
|
2
|
+
import { C as McpNestClientRuntimeOptions, E as McpNestStdioClientTransportDefinition, S as McpNestClientOptions, T as McpNestHttpClientTransportDefinition, _ as McpClientProgressObserver, a as McpClientAttributesResolverProvider, b as McpNestClientDefinition, c as McpClientConfiguratorProvider, d as McpClientLifecycleErrorReporter, f as McpClientMiddlewareProvider, g as McpClientPrincipalResolverProvider, h as McpClientOperationIdFactory, i as McpClientForRootOptions, l as McpClientFetchMiddlewareProvider, m as McpClientModuleOptions, n as McpClientModule, o as McpClientBootstrapOptions, p as McpClientModuleExtras, r as McpClientForRootAsyncOptions, s as McpClientClock, t as McpClientService, u as McpClientFetchProvider, v as McpClientReconnectionSchedulerProvider, w as McpNestClientTransportDefinition, x as McpNestClientLifecycleOptions, y as McpNestClientConnectOptions } from "./mcp-client.service-kXzXDpg6.mjs";
|
|
3
|
+
import { ControllerOptions, DynamicModule, InjectionToken, ModuleMetadata, OnApplicationBootstrap, OnModuleDestroy } from "@nestjs/common";
|
|
4
|
+
import { FetchLikeMcpHandler, ToNodeHandlerOptions } from "@modelcontextprotocol/node";
|
|
5
|
+
import { McpCorsOptions, McpHttpSecurityOptions, McpHttpSecurityOptions as McpHttpSecurityOptions$1, McpHttpSecurityPolicy } from "@nest-mcp/server/security";
|
|
6
|
+
import { McpGateway, McpGatewayAuthorizationContextResolver, McpGatewayClientResolver, McpGatewayDiscoveryCache, McpGatewayLifecycleObserver, McpGatewayMiddleware, McpGatewayNameCodec, McpGatewayOptions, McpGatewayPolicy, McpGatewayPromptNameCodec, McpGatewayResourceTemplateUriCodec, McpGatewayResourceUriCodec } from "@nest-mcp/gateway";
|
|
7
|
+
import { CacheHint, CacheHint as CacheHint$1, CallToolResult, CallToolResult as CallToolResult$1, CompletableSchema, CompleteCallback, CompleteResourceTemplateCallback, ElicitInputParams, GetPromptResult, GetPromptResult as GetPromptResult$1, Icon, Icon as Icon$1, InputRequiredResult, InputRequiredResult as InputRequiredResult$1, InputRequiredSpec, InputResponseView, McpServer, McpServerBuildContext, McpServerBuildContext as McpServerBuildContext$1, McpServerDefinition, McpServerFeature, McpServerMiddleware, McpServerMiddleware as McpServerMiddleware$1, McpServerOperationContext, McpServerPrincipal, McpServerPrincipal as McpServerPrincipal$1, McpServerPrincipalClaims, McpServerPrincipalClaimsResolver, McpServerRegistry, McpServerRuntime, McpServerRuntimeEvent, PromptCallback, PromptCallback as PromptCallback$1, ReadResourceCallback, ReadResourceCallback as ReadResourceCallback$1, ReadResourceResult, ReadResourceResult as ReadResourceResult$1, ReadResourceTemplateCallback, ReadResourceTemplateCallback as ReadResourceTemplateCallback$1, RequestStateCodec, RequestStateCodecOptions, ResourceMetadata, ResourceMetadata as ResourceMetadata$1, ResourceTemplate, ResourceTemplate as ResourceTemplate$1, ServerContext, StandardSchemaWithJSON, StandardSchemaWithJSON as StandardSchemaWithJSON$1, ToolAnnotations, ToolAnnotations as ToolAnnotations$1, ToolCallback, ToolCallback as ToolCallback$1, acceptedContent, completable, createRequestStateCodec, fromJsonSchema, inputRequired, inputResponse } from "@nest-mcp/server";
|
|
8
|
+
import { MaybePromise, McpAuthorizationDecision, McpAuthorizationPolicy, McpLifecycleObserver, McpOperationContext, McpOperationMiddleware, McpPassthroughMiddleware, allowMcpOperation, denyMcpOperation } from "@nest-mcp/core";
|
|
9
|
+
import { AuthInfo, CreateMcpHandlerOptions, OAuthMetadata, OAuthTokenVerifier, ServerContext as ServerContext$1, ServerEventBus, ServerOptions, Tool as Tool$1, jsonSchemaValidator } from "@modelcontextprotocol/server";
|
|
10
|
+
import { DiscoveryService, MetadataScanner, Reflector } from "@nestjs/core";
|
|
11
|
+
import { McpClientRuntime } from "@nest-mcp/client";
|
|
12
|
+
import { McpConsentRenderer, McpFetchLike, McpOAuthClientResolver, McpOAuthProxy, McpOAuthProxyTtl, McpOAuthStore, McpTokenKeyRing, McpUpstreamAuthorizationServer, McpUpstreamSubjectResolver } from "@nest-mcp/auth";
|
|
13
|
+
import { McpFetchHandler } from "@nest-mcp/server/auth";
|
|
14
|
+
//#region src/mcp-catalog-exposure.d.ts
|
|
15
|
+
declare const MCP_CATALOG_SEARCH_TOOL_NAME = "nest-mcp.catalog.search";
|
|
16
|
+
declare const MCP_CATALOG_SCHEMAS_TOOL_NAME = "nest-mcp.catalog.schemas";
|
|
17
|
+
type McpCatalogExposureKind = "eager" | "search" | "lazy";
|
|
18
|
+
/** Recursive readonly view used for detached catalog values. */
|
|
19
|
+
type McpCatalogReadonly<Value> = Value extends readonly unknown[] ? { readonly [Index in keyof Value]: McpCatalogReadonly<Value[Index]>; } : Value extends object ? { readonly [Key in keyof Value]: McpCatalogReadonly<Value[Key]>; } : Value;
|
|
20
|
+
/** A detached, deeply frozen public projection of one visible SDK tool. */
|
|
21
|
+
interface McpCatalogTool {
|
|
22
|
+
readonly tool: McpCatalogReadonly<Tool$1>;
|
|
23
|
+
readonly tags: readonly string[];
|
|
24
|
+
}
|
|
25
|
+
interface McpCatalogNameSelector {
|
|
26
|
+
readonly kind: "name";
|
|
27
|
+
readonly name: string;
|
|
28
|
+
}
|
|
29
|
+
interface McpCatalogTagSelector {
|
|
30
|
+
readonly kind: "tag";
|
|
31
|
+
readonly tag: string;
|
|
32
|
+
}
|
|
33
|
+
interface McpCatalogPredicateSelector {
|
|
34
|
+
readonly kind: "predicate";
|
|
35
|
+
readonly predicate: (tool: McpCatalogTool) => boolean;
|
|
36
|
+
}
|
|
37
|
+
type McpCatalogToolSelector = McpCatalogNameSelector | McpCatalogTagSelector | McpCatalogPredicateSelector;
|
|
38
|
+
interface McpCatalogEagerExposure {
|
|
39
|
+
readonly kind: "eager";
|
|
40
|
+
}
|
|
41
|
+
interface McpCatalogSearchExposure {
|
|
42
|
+
readonly kind: "search";
|
|
43
|
+
/** Selectors for tools advertised eagerly. Every other visible tool receives deferredMetadata. */
|
|
44
|
+
readonly eager?: readonly McpCatalogToolSelector[];
|
|
45
|
+
/** Explicit vendor-specific marker merged into deferred tools' existing `_meta`. */
|
|
46
|
+
readonly deferredMetadata: Readonly<Record<string, unknown>>;
|
|
47
|
+
}
|
|
48
|
+
interface McpCatalogLazyExposure {
|
|
49
|
+
readonly kind: "lazy";
|
|
50
|
+
/** Selectors for ordinary tools included in `tools/list` beside the bounded meta-tools. */
|
|
51
|
+
readonly eager?: readonly McpCatalogToolSelector[];
|
|
52
|
+
}
|
|
53
|
+
type McpCatalogExposureStrategy<Kind extends McpCatalogExposureKind = McpCatalogExposureKind> = Extract<McpCatalogEagerExposure | McpCatalogSearchExposure | McpCatalogLazyExposure, {
|
|
54
|
+
readonly kind: Kind;
|
|
55
|
+
}>;
|
|
56
|
+
/** Deliberately omits raw auth info, requests, callbacks, policies and registry definitions. */
|
|
57
|
+
interface McpCatalogExposureResolverInput {
|
|
58
|
+
readonly runtimeName: string;
|
|
59
|
+
readonly era: McpServerBuildContext$1["era"];
|
|
60
|
+
readonly principal?: Readonly<McpServerPrincipal$1>;
|
|
61
|
+
readonly signal?: AbortSignal;
|
|
62
|
+
readonly tools: readonly McpCatalogTool[];
|
|
63
|
+
}
|
|
64
|
+
type McpCatalogExposureResolver<Strategy extends McpCatalogExposureStrategy = McpCatalogExposureStrategy> = (input: McpCatalogExposureResolverInput) => MaybePromise<Strategy>;
|
|
65
|
+
/** Injectable Nest policy that selects the catalog projection for one serving unit. */
|
|
66
|
+
interface McpCatalogExposurePolicy<Strategy extends McpCatalogExposureStrategy = McpCatalogExposureStrategy> {
|
|
67
|
+
resolve(input: McpCatalogExposureResolverInput): MaybePromise<Strategy>;
|
|
68
|
+
}
|
|
69
|
+
/** Framework-internal callback adapter. Nest applications configure a policy provider token. */
|
|
70
|
+
interface McpCatalogExposureOptions {
|
|
71
|
+
readonly resolver: McpCatalogExposureResolver;
|
|
72
|
+
}
|
|
73
|
+
interface McpCatalogSearchResultTool {
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly title?: string;
|
|
76
|
+
readonly description?: string;
|
|
77
|
+
readonly tags: readonly string[];
|
|
78
|
+
}
|
|
79
|
+
interface McpCatalogSearchResult {
|
|
80
|
+
readonly tools: readonly McpCatalogSearchResultTool[];
|
|
81
|
+
readonly nextCursor?: string;
|
|
82
|
+
}
|
|
83
|
+
interface McpCatalogSchemasResult {
|
|
84
|
+
readonly tools: readonly McpCatalogReadonly<Tool$1>[];
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/mcp-capability.types.d.ts
|
|
88
|
+
/** Decides whether capabilities are installed on one freshly built request server. */
|
|
89
|
+
interface McpCapabilityVisibilityPolicy {
|
|
90
|
+
isVisible(context: Readonly<McpServerBuildContext$1>): MaybePromise<boolean>;
|
|
91
|
+
}
|
|
92
|
+
/** Static visibility or a singleton Nest provider evaluated once per server build. */
|
|
93
|
+
type McpCapabilityVisibility = boolean | InjectionToken<McpCapabilityVisibilityPolicy>;
|
|
94
|
+
/** A live dynamic registration backed by the registry's copy-on-write snapshot. */
|
|
95
|
+
interface McpDynamicHandlerRegistration<Handler> {
|
|
96
|
+
readonly source: string;
|
|
97
|
+
/** Atomically replaces only the callback while preserving capability metadata. */
|
|
98
|
+
replace(handler: Handler): boolean;
|
|
99
|
+
/** Atomically removes this exact registration. */
|
|
100
|
+
unregister(): boolean;
|
|
101
|
+
}
|
|
102
|
+
type McpCapabilityMutationKind = "tool" | "resource" | "prompt";
|
|
103
|
+
type McpCapabilityMutationType = "registered" | "replaced" | "unregistered";
|
|
104
|
+
/** Internal/publicly observable mutation description; contains no handler payload. */
|
|
105
|
+
interface McpCapabilityMutation {
|
|
106
|
+
readonly kind: McpCapabilityMutationKind;
|
|
107
|
+
readonly type: McpCapabilityMutationType;
|
|
108
|
+
readonly source: string;
|
|
109
|
+
readonly serverNames: readonly string[];
|
|
110
|
+
}
|
|
111
|
+
type McpCapabilityMutationObserver = (mutation: McpCapabilityMutation) => MaybePromise<void>;
|
|
112
|
+
/** Public, callback-free description of one registered capability. */
|
|
113
|
+
interface McpCapabilityDescriptor {
|
|
114
|
+
readonly kind: McpCapabilityMutationKind;
|
|
115
|
+
readonly name: string;
|
|
116
|
+
readonly source: string;
|
|
117
|
+
readonly serverNames: readonly string[];
|
|
118
|
+
}
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/decorators/mcp-handler.decorators.d.ts
|
|
121
|
+
interface HandlerTarget {
|
|
122
|
+
/** Runtime names receiving this handler. Omit for every configured server. */
|
|
123
|
+
readonly servers?: string | readonly string[];
|
|
124
|
+
/** Discovery visibility. Invocation authorization remains independently mandatory. */
|
|
125
|
+
readonly visibility?: McpCapabilityVisibility;
|
|
126
|
+
}
|
|
127
|
+
interface ToolOptions<InputSchema extends StandardSchemaWithJSON$1 | undefined = StandardSchemaWithJSON$1 | undefined> extends HandlerTarget {
|
|
128
|
+
readonly name: string;
|
|
129
|
+
readonly title?: string;
|
|
130
|
+
readonly description?: string;
|
|
131
|
+
readonly inputSchema?: InputSchema;
|
|
132
|
+
readonly outputSchema?: StandardSchemaWithJSON$1;
|
|
133
|
+
readonly annotations?: ToolAnnotations$1;
|
|
134
|
+
readonly icons?: Icon$1[];
|
|
135
|
+
readonly _meta?: Record<string, unknown>;
|
|
136
|
+
/** Searchable application labels used only by Nest MCP catalog selectors. */
|
|
137
|
+
readonly tags?: readonly string[];
|
|
138
|
+
}
|
|
139
|
+
interface ResourceOptions<Uri extends string | ResourceTemplate$1 = string | ResourceTemplate$1> extends HandlerTarget {
|
|
140
|
+
readonly name: string;
|
|
141
|
+
readonly uri: Uri;
|
|
142
|
+
readonly title?: string;
|
|
143
|
+
readonly description?: string;
|
|
144
|
+
readonly mimeType?: string;
|
|
145
|
+
readonly size?: number;
|
|
146
|
+
readonly icons?: Icon$1[];
|
|
147
|
+
readonly annotations?: ResourceMetadata$1["annotations"];
|
|
148
|
+
readonly _meta?: Record<string, unknown>;
|
|
149
|
+
readonly cacheHint?: CacheHint$1;
|
|
150
|
+
}
|
|
151
|
+
interface PromptOptions<ArgsSchema extends StandardSchemaWithJSON$1 | undefined = StandardSchemaWithJSON$1 | undefined> extends HandlerTarget {
|
|
152
|
+
readonly name: string;
|
|
153
|
+
readonly title?: string;
|
|
154
|
+
readonly description?: string;
|
|
155
|
+
readonly argsSchema?: ArgsSchema;
|
|
156
|
+
readonly icons?: Icon$1[];
|
|
157
|
+
readonly _meta?: Record<string, unknown>;
|
|
158
|
+
}
|
|
159
|
+
interface ToolHandlerDefinition {
|
|
160
|
+
readonly kind: "tool";
|
|
161
|
+
readonly options: ToolOptions;
|
|
162
|
+
}
|
|
163
|
+
interface ResourceHandlerDefinition {
|
|
164
|
+
readonly kind: "resource";
|
|
165
|
+
readonly options: ResourceOptions;
|
|
166
|
+
}
|
|
167
|
+
interface PromptHandlerDefinition {
|
|
168
|
+
readonly kind: "prompt";
|
|
169
|
+
readonly options: PromptOptions;
|
|
170
|
+
}
|
|
171
|
+
type HandlerDefinition = ToolHandlerDefinition | ResourceHandlerDefinition | PromptHandlerDefinition;
|
|
172
|
+
/** Legacy-decorator signature that checks the decorated method without replacing it. */
|
|
173
|
+
type TypedMethodDecorator<ExpectedHandler> = <Handler extends ExpectedHandler>(target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<Handler>) => void;
|
|
174
|
+
type ToolMethodDecorator<InputSchema extends StandardSchemaWithJSON$1 | undefined> = TypedMethodDecorator<ToolCallback$1<InputSchema>>;
|
|
175
|
+
type PromptMethodDecorator<ArgsSchema extends StandardSchemaWithJSON$1 | undefined> = TypedMethodDecorator<PromptCallback$1<ArgsSchema>>;
|
|
176
|
+
type ResourceMethodDecorator<Uri extends string | ResourceTemplate$1> = TypedMethodDecorator<Uri extends string ? ReadResourceCallback$1 : ReadResourceTemplateCallback$1>;
|
|
177
|
+
declare function Tool<const InputSchema extends StandardSchemaWithJSON$1 | undefined = undefined>(options: ToolOptions<InputSchema>): ToolMethodDecorator<InputSchema>;
|
|
178
|
+
declare function Resource<const Uri extends string | ResourceTemplate$1>(options: ResourceOptions<Uri>): ResourceMethodDecorator<Uri>;
|
|
179
|
+
declare function Prompt<const ArgsSchema extends StandardSchemaWithJSON$1 | undefined = undefined>(options: PromptOptions<ArgsSchema>): PromptMethodDecorator<ArgsSchema>;
|
|
180
|
+
/** Supplies a default server target for every MCP handler declared by a provider class. */
|
|
181
|
+
declare function Targets(...serverNames: readonly [string, ...string[]]): ClassDecorator;
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/http/mcp-http-route.types.d.ts
|
|
184
|
+
/** Public discovery routes backed by a server's configured oauth.resource metadata. */
|
|
185
|
+
interface McpHttpDiscoveryRoutes {
|
|
186
|
+
/** Include the path advertised by the resource server's bearer challenge; aliases are optional. */
|
|
187
|
+
readonly protectedResourcePaths?: readonly string[];
|
|
188
|
+
/** Explicit paths for the configured authorization-server metadata document. */
|
|
189
|
+
readonly authorizationServerPaths?: readonly string[];
|
|
190
|
+
/** Independent Nest class decorators; MCP route decorators are not copied to public discovery. */
|
|
191
|
+
readonly decorators?: readonly ClassDecorator[];
|
|
192
|
+
}
|
|
193
|
+
/** Static Nest routing metadata, supplied outside useFactory when using forRootAsync. */
|
|
194
|
+
interface McpHttpRoute {
|
|
195
|
+
readonly serverName: string;
|
|
196
|
+
/** A literal Nest path, with or without a leading slash. */
|
|
197
|
+
readonly path: string;
|
|
198
|
+
readonly version?: ControllerOptions["version"];
|
|
199
|
+
/** Nest class decorators such as UseGuards, UseInterceptors, and application route metadata. */
|
|
200
|
+
readonly decorators?: readonly ClassDecorator[];
|
|
201
|
+
/** Optional discovery endpoints. Requires oauth.resource.metadata on the named runtime. */
|
|
202
|
+
readonly discovery?: McpHttpDiscoveryRoutes;
|
|
203
|
+
}
|
|
204
|
+
//#endregion
|
|
205
|
+
//#region src/oauth/mcp-oauth.types.d.ts
|
|
206
|
+
/** Verifies a bearer access token; mirrors the SDK `OAuthTokenVerifier` contract. */
|
|
207
|
+
interface McpOAuthTokenVerifierProvider extends OAuthTokenVerifier {}
|
|
208
|
+
/**
|
|
209
|
+
* Fail-closed anonymous admission. Consulted only after bearer verification
|
|
210
|
+
* refuses a request; returning an `AuthInfo` admits the request under that
|
|
211
|
+
* identity, `undefined` preserves the original `401`/`403`.
|
|
212
|
+
*/
|
|
213
|
+
interface McpAnonymousAccessPolicy {
|
|
214
|
+
permit(request: Request): MaybePromise<AuthInfo | undefined>;
|
|
215
|
+
}
|
|
216
|
+
/** RFC 9728/8414 discovery metadata to publish alongside a protected resource. */
|
|
217
|
+
interface McpNestOAuthMetadataOptions {
|
|
218
|
+
/** Authorization-server metadata (RFC 8414) of the IdP this server trusts. */
|
|
219
|
+
readonly oauthMetadata: OAuthMetadata;
|
|
220
|
+
readonly serviceDocumentationUrl?: string;
|
|
221
|
+
readonly scopesSupported?: readonly string[];
|
|
222
|
+
readonly resourceName?: string;
|
|
223
|
+
}
|
|
224
|
+
interface McpNestOAuthResourceOptions {
|
|
225
|
+
/** Public URL of this MCP server; the RFC 9728 `resource` identifier. */
|
|
226
|
+
readonly resourceServerUrl: string;
|
|
227
|
+
readonly requiredScopes?: readonly string[];
|
|
228
|
+
/** Injectable bearer-token verifier (e.g. the proxy's own or a JWKS verifier). */
|
|
229
|
+
readonly verifier: McpProviderToken<McpOAuthTokenVerifierProvider>;
|
|
230
|
+
/** Publish protected-resource + authorization-server metadata. */
|
|
231
|
+
readonly metadata?: McpNestOAuthMetadataOptions;
|
|
232
|
+
/** Injectable fail-closed anonymous fallback; omit to require a valid token. */
|
|
233
|
+
readonly anonymous?: McpProviderToken<McpAnonymousAccessPolicy>;
|
|
234
|
+
}
|
|
235
|
+
/** Supplies the access-token signing key ring (from a config/secret provider). */
|
|
236
|
+
interface McpOAuthSigningKeyProvider {
|
|
237
|
+
getSigningKeys(): McpTokenKeyRing;
|
|
238
|
+
}
|
|
239
|
+
/** Supplies the HKDF master secret for cookies, CSRF, and subject pseudonyms. */
|
|
240
|
+
interface McpOAuthSecretProvider {
|
|
241
|
+
getMasterSecret(): Uint8Array | string;
|
|
242
|
+
}
|
|
243
|
+
/** Supplies the upstream authorization-server configuration (issuer, client, scopes). */
|
|
244
|
+
interface McpOAuthUpstreamProvider {
|
|
245
|
+
getUpstream(): McpUpstreamAuthorizationServer;
|
|
246
|
+
}
|
|
247
|
+
/** Supplies the consent screen. */
|
|
248
|
+
interface McpOAuthConsentProvider {
|
|
249
|
+
render: McpConsentRenderer;
|
|
250
|
+
}
|
|
251
|
+
/** Maps upstream tokens to a stable subject for non-OIDC providers. */
|
|
252
|
+
interface McpOAuthSubjectResolverProvider {
|
|
253
|
+
resolveSubject: McpUpstreamSubjectResolver;
|
|
254
|
+
}
|
|
255
|
+
/** Supplies the SSRF-guarded outbound fetch used for upstream discovery/token calls. */
|
|
256
|
+
interface McpOAuthFetchProvider {
|
|
257
|
+
fetch: McpFetchLike;
|
|
258
|
+
}
|
|
259
|
+
/** CIMD resolution options for the proxy's `/authorize` client lookup. */
|
|
260
|
+
interface McpNestClientIdMetadataOptions {
|
|
261
|
+
readonly enabled: boolean;
|
|
262
|
+
readonly allowedHosts?: readonly string[];
|
|
263
|
+
readonly maxDocumentBytes?: number;
|
|
264
|
+
readonly fetchTimeoutMs?: number;
|
|
265
|
+
}
|
|
266
|
+
interface McpNestOAuthProxyOptions {
|
|
267
|
+
/** This server's own issuer (origin, no trailing slash). */
|
|
268
|
+
readonly issuer: string;
|
|
269
|
+
readonly basePath?: string;
|
|
270
|
+
/** Canonical resource URL(s) the proxy mints tokens for. */
|
|
271
|
+
readonly resources: readonly string[];
|
|
272
|
+
readonly scopesSupported?: readonly string[];
|
|
273
|
+
readonly signingKeys: McpProviderToken<McpOAuthSigningKeyProvider>;
|
|
274
|
+
readonly secret: McpProviderToken<McpOAuthSecretProvider>;
|
|
275
|
+
readonly upstream: McpProviderToken<McpOAuthUpstreamProvider>;
|
|
276
|
+
/** Token/state storage. `McpOAuthStore` is itself the provider (structural). */
|
|
277
|
+
readonly stateStore: McpProviderToken<McpOAuthStore>;
|
|
278
|
+
readonly tokenStore?: McpProviderToken<McpOAuthStore>;
|
|
279
|
+
/** Resolver for preconfigured/registered (non-CIMD) clients. */
|
|
280
|
+
readonly clientResolver?: McpProviderToken<McpOAuthClientResolver>;
|
|
281
|
+
readonly consent?: McpProviderToken<McpOAuthConsentProvider>;
|
|
282
|
+
readonly subjectResolver?: McpProviderToken<McpOAuthSubjectResolverProvider>;
|
|
283
|
+
/** SSRF-guarded outbound fetch for upstream discovery/token calls; defaults to the built-in guard. */
|
|
284
|
+
readonly fetch?: McpProviderToken<McpOAuthFetchProvider>;
|
|
285
|
+
readonly cimd?: McpNestClientIdMetadataOptions;
|
|
286
|
+
readonly ttl?: McpOAuthProxyTtl;
|
|
287
|
+
/** Bearer scopes required to reach the protected MCP handler. */
|
|
288
|
+
readonly requiredScopes?: readonly string[];
|
|
289
|
+
/** Fail-closed anonymous fallback for the resource gate. */
|
|
290
|
+
readonly anonymous?: McpProviderToken<McpAnonymousAccessPolicy>;
|
|
291
|
+
}
|
|
292
|
+
/** Per-server OAuth configuration group on `McpNestServerDefinition`. */
|
|
293
|
+
interface McpNestServerOAuthOptions {
|
|
294
|
+
/** Resource-server protection (bearer verification + discovery metadata). */
|
|
295
|
+
readonly resource?: McpNestOAuthResourceOptions;
|
|
296
|
+
/** Authorization-server proxy in front of a real upstream IdP. */
|
|
297
|
+
readonly proxy?: McpNestOAuthProxyOptions;
|
|
298
|
+
}
|
|
299
|
+
//#endregion
|
|
300
|
+
//#region src/server/mcp-server.types.d.ts
|
|
301
|
+
interface McpRequestStateVerifier {
|
|
302
|
+
verify(state: string, context: ServerContext$1): MaybePromise<unknown>;
|
|
303
|
+
}
|
|
304
|
+
interface McpNestServerOptions extends Omit<ServerOptions, "jsonSchemaValidator" | "requestState"> {
|
|
305
|
+
readonly jsonSchemaValidator?: McpProviderToken<jsonSchemaValidator>;
|
|
306
|
+
readonly requestState?: Omit<NonNullable<ServerOptions["requestState"]>, "verify"> & {
|
|
307
|
+
readonly verifier?: McpProviderToken<McpRequestStateVerifier>;
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
interface McpNestServerHttpOptions extends Omit<CreateMcpHandlerOptions, "bus" | "onerror"> {
|
|
311
|
+
/** Injectable long-lived event bus used by modern change subscriptions. */
|
|
312
|
+
readonly eventBus?: McpProviderToken<ServerEventBus>;
|
|
313
|
+
}
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/mcp.types.d.ts
|
|
316
|
+
interface McpHandlerInvocationInput {
|
|
317
|
+
readonly kind: "tool" | "resource" | "prompt";
|
|
318
|
+
readonly name: string;
|
|
319
|
+
readonly serverName: string;
|
|
320
|
+
readonly source: string;
|
|
321
|
+
/** Validated callback arguments, excluding the official SDK handler context. */
|
|
322
|
+
readonly arguments: readonly unknown[];
|
|
323
|
+
}
|
|
324
|
+
type McpHandlerOperationContext = McpOperationContext<McpServerPrincipal$1>;
|
|
325
|
+
type McpHandlerInvocationOutputMap = Readonly<{
|
|
326
|
+
tool: CallToolResult$1 | InputRequiredResult$1;
|
|
327
|
+
resource: ReadResourceResult$1;
|
|
328
|
+
prompt: GetPromptResult$1 | InputRequiredResult$1;
|
|
329
|
+
}>;
|
|
330
|
+
type McpHandlerInvocationOutputFor<Input extends McpHandlerInvocationInput> = McpHandlerInvocationOutputMap[Input["kind"]];
|
|
331
|
+
type McpHandlerInvocationOutput = McpHandlerInvocationOutputFor<McpHandlerInvocationInput>;
|
|
332
|
+
type McpHandlerMiddleware = McpOperationMiddleware<McpHandlerInvocationInput, McpHandlerInvocationOutput, McpHandlerOperationContext>;
|
|
333
|
+
type McpHandlerPassthroughMiddleware = McpPassthroughMiddleware<McpHandlerInvocationInput, McpHandlerOperationContext>;
|
|
334
|
+
type McpHandlerAuthorizationPolicy = McpAuthorizationPolicy<McpHandlerInvocationInput, McpHandlerOperationContext>;
|
|
335
|
+
type McpHandlerLifecycleObserver = McpLifecycleObserver<McpHandlerOperationContext>;
|
|
336
|
+
interface McpHandlerMiddlewareProvider {
|
|
337
|
+
handle: McpHandlerMiddleware;
|
|
338
|
+
}
|
|
339
|
+
interface McpServerMiddlewareProvider {
|
|
340
|
+
handle: McpServerMiddleware$1;
|
|
341
|
+
}
|
|
342
|
+
type McpServerLifecycleObserver = McpLifecycleObserver<McpServerOperationContext>;
|
|
343
|
+
interface McpServerPrincipalClaimsProvider {
|
|
344
|
+
resolvePrincipalClaims: McpServerPrincipalClaimsResolver;
|
|
345
|
+
}
|
|
346
|
+
interface McpServerRuntimeObserverProvider {
|
|
347
|
+
observe(event: McpServerRuntimeEvent): MaybePromise<void>;
|
|
348
|
+
}
|
|
349
|
+
interface McpServerErrorReporter {
|
|
350
|
+
report(error: Error): MaybePromise<void>;
|
|
351
|
+
}
|
|
352
|
+
/** Nest provider that contributes low-level capabilities to one configured server. */
|
|
353
|
+
interface McpServerContributor {
|
|
354
|
+
contribute(server: McpServer, context: McpServerBuildContext$1): MaybePromise<void>;
|
|
355
|
+
}
|
|
356
|
+
interface McpNestGatewayUpstream {
|
|
357
|
+
/** Name of a client configured in the imported `McpClientModule`. */
|
|
358
|
+
readonly clientName: string;
|
|
359
|
+
/** Optional public namespace exposed by the aggregate gateway. */
|
|
360
|
+
readonly gatewayName?: string;
|
|
361
|
+
}
|
|
362
|
+
/** Nest provider that selects an authorization-isolated gateway client per request. */
|
|
363
|
+
interface McpGatewayClientProvider {
|
|
364
|
+
resolveClient: McpGatewayClientResolver;
|
|
365
|
+
}
|
|
366
|
+
/** Context-aware upstream whose client selection is owned by a Nest provider. */
|
|
367
|
+
interface McpNestGatewayProviderUpstream {
|
|
368
|
+
readonly name: string;
|
|
369
|
+
readonly clientProvider: McpProviderToken<McpGatewayClientProvider>;
|
|
370
|
+
}
|
|
371
|
+
type McpNestGatewayUpstreamDefinition = string | McpNestGatewayUpstream | McpNestGatewayProviderUpstream;
|
|
372
|
+
interface McpGatewayNameCodecProvider extends McpGatewayNameCodec {}
|
|
373
|
+
interface McpGatewayPromptNameCodecProvider extends McpGatewayPromptNameCodec {}
|
|
374
|
+
interface McpGatewayResourceUriCodecProvider extends McpGatewayResourceUriCodec {}
|
|
375
|
+
interface McpGatewayResourceTemplateUriCodecProvider extends McpGatewayResourceTemplateUriCodec {}
|
|
376
|
+
interface McpGatewayDiscoveryCacheProvider extends McpGatewayDiscoveryCache {}
|
|
377
|
+
interface McpGatewayAuthorizationContextProvider {
|
|
378
|
+
resolveAuthorizationContext: McpGatewayAuthorizationContextResolver;
|
|
379
|
+
}
|
|
380
|
+
interface McpGatewayMiddlewareProvider {
|
|
381
|
+
handle: McpGatewayMiddleware;
|
|
382
|
+
}
|
|
383
|
+
interface McpGatewayLifecycleObserverProvider extends McpGatewayLifecycleObserver {}
|
|
384
|
+
interface McpGatewayObserverErrorReporter {
|
|
385
|
+
report(error: unknown): MaybePromise<void>;
|
|
386
|
+
}
|
|
387
|
+
/** Gateway options resolved against Nest-owned clients and an injectable policy. */
|
|
388
|
+
interface McpNestGatewayOptions extends Omit<McpGatewayOptions, "authorizationContextResolver" | "discoveryCache" | "lifecycleObserver" | "middleware" | "nameCodec" | "onObserverError" | "policy" | "promptNameCodec" | "resourceTemplateNameCodec" | "resourceTemplateUriCodec" | "resourceUriCodec" | "upstreams"> {
|
|
389
|
+
/** Compose gateway tools with local handlers on one server. Other gateway capabilities stay private. */
|
|
390
|
+
readonly composition?: "tools";
|
|
391
|
+
readonly upstreams: readonly McpNestGatewayUpstreamDefinition[];
|
|
392
|
+
readonly policy: McpProviderToken<McpGatewayPolicy>;
|
|
393
|
+
readonly nameCodec?: McpProviderToken<McpGatewayNameCodecProvider>;
|
|
394
|
+
readonly promptNameCodec?: McpProviderToken<McpGatewayPromptNameCodecProvider>;
|
|
395
|
+
readonly resourceUriCodec?: McpProviderToken<McpGatewayResourceUriCodecProvider>;
|
|
396
|
+
readonly resourceTemplateUriCodec?: McpProviderToken<McpGatewayResourceTemplateUriCodecProvider>;
|
|
397
|
+
readonly resourceTemplateNameCodec?: McpProviderToken<McpGatewayNameCodecProvider>;
|
|
398
|
+
readonly discoveryCache?: McpProviderToken<McpGatewayDiscoveryCacheProvider>;
|
|
399
|
+
readonly authorizationContextResolver?: McpProviderToken<McpGatewayAuthorizationContextProvider>;
|
|
400
|
+
readonly middleware?: readonly McpProviderToken<McpGatewayMiddlewareProvider>[];
|
|
401
|
+
readonly lifecycleObserver?: McpProviderToken<McpGatewayLifecycleObserverProvider>;
|
|
402
|
+
readonly onObserverError?: McpProviderToken<McpGatewayObserverErrorReporter>;
|
|
403
|
+
}
|
|
404
|
+
interface McpNestCatalogExposureOptions {
|
|
405
|
+
/** Singleton Nest provider that selects the projection for each serving unit. */
|
|
406
|
+
readonly policy: McpProviderToken<McpCatalogExposurePolicy>;
|
|
407
|
+
}
|
|
408
|
+
/** Nest-owned server configuration. Raw feature callbacks remain in `@nest-mcp/server`. */
|
|
409
|
+
interface McpNestServerDefinition extends Omit<McpServerDefinition, "features" | "http" | "lifecycleObserver" | "middleware" | "observer" | "onError" | "principalClaims" | "serverOptions"> {
|
|
410
|
+
readonly serverOptions?: McpNestServerOptions;
|
|
411
|
+
readonly http?: McpNestServerHttpOptions;
|
|
412
|
+
/** Injectable low-level contributors resolved once during application bootstrap. */
|
|
413
|
+
readonly contributors?: readonly McpProviderToken<McpServerContributor>[];
|
|
414
|
+
/** Injectable projection of verified provider claims onto the safe MCP principal. */
|
|
415
|
+
readonly principalClaims?: McpProviderToken<McpServerPrincipalClaimsProvider>;
|
|
416
|
+
/** Injectable HTTP-exchange middleware providers. */
|
|
417
|
+
readonly middleware?: readonly McpProviderToken<McpServerMiddlewareProvider>[];
|
|
418
|
+
readonly lifecycleObserver?: McpProviderToken<McpServerLifecycleObserver>;
|
|
419
|
+
readonly observer?: McpProviderToken<McpServerRuntimeObserverProvider>;
|
|
420
|
+
readonly onError?: McpProviderToken<McpServerErrorReporter>;
|
|
421
|
+
/** Runs before custom handler middleware and cannot be bypassed by short-circuit middleware. */
|
|
422
|
+
readonly handlerAuthorization?: McpProviderToken<McpHandlerAuthorizationPolicy>;
|
|
423
|
+
readonly handlerMiddleware?: readonly McpProviderToken<McpHandlerMiddlewareProvider>[];
|
|
424
|
+
/** Payload-free lifecycle events for validated tool/resource/prompt invocations. */
|
|
425
|
+
readonly handlerLifecycleObserver?: McpProviderToken<McpHandlerLifecycleObserver>;
|
|
426
|
+
/** Maximum duration of one per-request capability visibility wave. Defaults to 30 seconds. */
|
|
427
|
+
readonly handlerVisibilityTimeoutMs?: number;
|
|
428
|
+
/** Optional authorization-safe projection of the post-visibility tool catalog. */
|
|
429
|
+
readonly catalogExposure?: McpNestCatalogExposureOptions;
|
|
430
|
+
/** Optional aggregate gateway backed by clients owned by this Nest module. */
|
|
431
|
+
readonly gateway?: McpNestGatewayOptions;
|
|
432
|
+
/** Optional OAuth resource-server protection composed around the HTTP handler. */
|
|
433
|
+
readonly oauth?: McpNestServerOAuthOptions;
|
|
434
|
+
}
|
|
435
|
+
interface McpModuleOptions {
|
|
436
|
+
/** Server runtimes compiled at application bootstrap. */
|
|
437
|
+
readonly servers?: readonly McpNestServerDefinition[];
|
|
438
|
+
/** Discover decorated Nest providers and attach them to matching servers. Defaults to true. */
|
|
439
|
+
readonly autoDiscover?: boolean;
|
|
440
|
+
}
|
|
441
|
+
interface McpModuleExtras {
|
|
442
|
+
/** Static Nest routes generated at module registration, outside an async useFactory. */
|
|
443
|
+
readonly httpRoutes?: readonly McpHttpRoute[];
|
|
444
|
+
/** Make the runtime services globally injectable. Defaults to false. */
|
|
445
|
+
readonly isGlobal?: boolean;
|
|
446
|
+
/** Nest modules whose exported providers are consumed by the MCP root. */
|
|
447
|
+
readonly imports?: ModuleMetadata["imports"];
|
|
448
|
+
/** Singleton collaborators whose lifecycle must surround the MCP runtimes they serve. */
|
|
449
|
+
readonly collaborators?: McpNestCollaborators;
|
|
450
|
+
}
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region src/discovery/mcp-handler.registry.d.ts
|
|
453
|
+
type McpDiscoveredHandler = (...arguments_: unknown[]) => MaybePromise<McpHandlerInvocationOutput>;
|
|
454
|
+
interface McpHandlerPipelineOptions {
|
|
455
|
+
readonly serverName: string;
|
|
456
|
+
readonly authorization?: McpHandlerAuthorizationPolicy;
|
|
457
|
+
readonly middleware?: readonly McpHandlerMiddleware[];
|
|
458
|
+
readonly lifecycleObserver?: McpHandlerLifecycleObserver;
|
|
459
|
+
readonly visibilityTimeoutMs?: number;
|
|
460
|
+
readonly catalogExposure?: McpCatalogExposureOptions;
|
|
461
|
+
}
|
|
462
|
+
declare class McpHandlerRegistry {
|
|
463
|
+
#private;
|
|
464
|
+
private readonly providers;
|
|
465
|
+
constructor(providers: McpProviderRegistry);
|
|
466
|
+
/** Adds one discovered handler. Prefer the typed capability methods for live registration. */
|
|
467
|
+
register(definition: HandlerDefinition, handler: McpDiscoveredHandler, source: string): void;
|
|
468
|
+
/** Atomically installs a live tool for future per-request server builds. */
|
|
469
|
+
registerTool<const InputSchema extends StandardSchemaWithJSON$1 | undefined = undefined>(options: ToolOptions<InputSchema>, handler: ToolCallback$1<InputSchema>, source?: string): McpDynamicHandlerRegistration<ToolCallback$1<InputSchema>>;
|
|
470
|
+
/** Atomically installs a live prompt for future per-request server builds. */
|
|
471
|
+
registerPrompt<const ArgsSchema extends StandardSchemaWithJSON$1 | undefined = undefined>(options: PromptOptions<ArgsSchema>, handler: PromptCallback$1<ArgsSchema>, source?: string): McpDynamicHandlerRegistration<PromptCallback$1<ArgsSchema>>;
|
|
472
|
+
/** Atomically installs a fixed or templated resource for future server builds. */
|
|
473
|
+
registerResource<const Uri extends string | ResourceTemplate$1>(options: ResourceOptions<Uri>, handler: Uri extends string ? ReadResourceCallback$1 : ReadResourceTemplateCallback$1, source?: string): McpDynamicHandlerRegistration<Uri extends string ? ReadResourceCallback$1 : ReadResourceTemplateCallback$1>;
|
|
474
|
+
list(): readonly McpCapabilityDescriptor[];
|
|
475
|
+
/** Locks target validation to the runtimes declared by the root module. */
|
|
476
|
+
configureRuntimes(serverNames: readonly string[], gatewayNames?: readonly string[], catalogRuntimeNames?: readonly string[]): void;
|
|
477
|
+
/** Observes committed live mutations. The returned unsubscriber is idempotent. */
|
|
478
|
+
onMutation(observer: McpCapabilityMutationObserver): () => void;
|
|
479
|
+
/** Seals live mutation APIs and releases handler callbacks during application shutdown. */
|
|
480
|
+
close(): void;
|
|
481
|
+
assertNoCollisions(runtimeName: string): void;
|
|
482
|
+
/** Whether discovery found any decorated handler targeting one runtime. */
|
|
483
|
+
hasHandlersFor(runtimeName: string): boolean;
|
|
484
|
+
asServerFeature(options: McpHandlerPipelineOptions): McpServerFeature;
|
|
485
|
+
}
|
|
486
|
+
//#endregion
|
|
487
|
+
//#region src/mcp-capabilities.service.d.ts
|
|
488
|
+
/** Public Nest service for live capability registration after application bootstrap. */
|
|
489
|
+
declare class McpCapabilitiesService {
|
|
490
|
+
private readonly registry;
|
|
491
|
+
constructor(registry: McpHandlerRegistry);
|
|
492
|
+
list(): readonly McpCapabilityDescriptor[];
|
|
493
|
+
registerTool<const InputSchema extends StandardSchemaWithJSON$1 | undefined = undefined>(options: ToolOptions<InputSchema>, handler: ToolCallback$1<InputSchema>, source?: string): McpDynamicHandlerRegistration<ToolCallback$1<InputSchema>>;
|
|
494
|
+
registerPrompt<const ArgsSchema extends StandardSchemaWithJSON$1 | undefined = undefined>(options: PromptOptions<ArgsSchema>, handler: PromptCallback$1<ArgsSchema>, source?: string): McpDynamicHandlerRegistration<PromptCallback$1<ArgsSchema>>;
|
|
495
|
+
registerResource<const Uri extends string | ResourceTemplate$1>(options: ResourceOptions<Uri>, handler: Uri extends string ? ReadResourceCallback$1 : ReadResourceTemplateCallback$1, source?: string): McpDynamicHandlerRegistration<Uri extends string ? ReadResourceCallback$1 : ReadResourceTemplateCallback$1>;
|
|
496
|
+
onMutation(observer: McpCapabilityMutationObserver): () => void;
|
|
497
|
+
}
|
|
498
|
+
//#endregion
|
|
499
|
+
//#region src/discovery/mcp-handler.explorer.d.ts
|
|
500
|
+
declare class McpHandlerExplorer {
|
|
501
|
+
#private;
|
|
502
|
+
private readonly discovery;
|
|
503
|
+
private readonly metadataScanner;
|
|
504
|
+
private readonly reflector;
|
|
505
|
+
private readonly registry;
|
|
506
|
+
constructor(discovery: DiscoveryService, metadataScanner: MetadataScanner, reflector: Reflector, registry: McpHandlerRegistry);
|
|
507
|
+
assertSingleRoot(): void;
|
|
508
|
+
scan(): void;
|
|
509
|
+
}
|
|
510
|
+
//#endregion
|
|
511
|
+
//#region src/mcp-runtime.service.d.ts
|
|
512
|
+
declare class McpRuntimeService implements OnApplicationBootstrap, OnModuleDestroy {
|
|
513
|
+
#private;
|
|
514
|
+
private readonly options;
|
|
515
|
+
private readonly clientService;
|
|
516
|
+
private readonly servers;
|
|
517
|
+
private readonly explorer;
|
|
518
|
+
private readonly handlerRegistry;
|
|
519
|
+
/** Public live-capability service used by future request server builds. */
|
|
520
|
+
readonly capabilities: McpCapabilitiesService;
|
|
521
|
+
private readonly providers;
|
|
522
|
+
constructor(options: McpModuleOptions, clientService: McpClientService | undefined, servers: McpServerRegistry, explorer: McpHandlerExplorer, handlerRegistry: McpHandlerRegistry,
|
|
523
|
+
/** Public live-capability service used by future request server builds. */
|
|
524
|
+
capabilities: McpCapabilitiesService, providers: McpProviderRegistry);
|
|
525
|
+
onApplicationBootstrap(): Promise<void>;
|
|
526
|
+
/**
|
|
527
|
+
* Composes the configured OAuth resource-server protection around a runtime's
|
|
528
|
+
* fetch handler. Returns the runtime untouched when the server has no `oauth`
|
|
529
|
+
* group, so the HTTP controller's default composition seam is a no-op unless
|
|
530
|
+
* OAuth is configured.
|
|
531
|
+
*/
|
|
532
|
+
composeHttpHandler(serverName: string, runtime: McpServerRuntime): McpFetchHandler;
|
|
533
|
+
/** The OAuth authorization-server proxy for a server, when `oauth.proxy` is configured. */
|
|
534
|
+
oauthProxy(serverName: string): McpOAuthProxy | undefined;
|
|
535
|
+
server(name: string): McpServerRuntime;
|
|
536
|
+
client(name: string): ReturnType<McpClientRuntime["requireClient"]>;
|
|
537
|
+
/** Named client runtime imported through `McpClientModule`. */
|
|
538
|
+
get clients(): McpClientRuntime;
|
|
539
|
+
/** Returns the aggregate gateway owned by one configured inbound server. */
|
|
540
|
+
gateway(serverName: string): McpGateway;
|
|
541
|
+
listGateways(): readonly McpGateway[];
|
|
542
|
+
isReady(): boolean;
|
|
543
|
+
/** Last cleanup failure contained by the Nest lifecycle hook, if any. */
|
|
544
|
+
get shutdownError(): AggregateError | undefined;
|
|
545
|
+
/** Explicit shutdown API. Unlike the Nest hook, this rejects on cleanup failure. */
|
|
546
|
+
close(): Promise<void>;
|
|
547
|
+
onModuleDestroy(): Promise<void>;
|
|
548
|
+
}
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region src/mcp-http.controller.d.ts
|
|
551
|
+
/** Constructor returned by {@link McpHttpControllerFor}. */
|
|
552
|
+
type McpHttpControllerClass = abstract new (runtimeService: McpRuntimeService) => McpHttpController;
|
|
553
|
+
/**
|
|
554
|
+
* Nest-native HTTP entry point for a named MCP server runtime.
|
|
555
|
+
*
|
|
556
|
+
* Extend this class through {@link McpHttpControllerFor}, then put `@Controller`
|
|
557
|
+
* and any guards, interceptors, or version metadata on the concrete subclass.
|
|
558
|
+
* The inherited catch-all route deliberately leaves HTTP method semantics to
|
|
559
|
+
* the MCP handler.
|
|
560
|
+
*/
|
|
561
|
+
declare abstract class McpHttpController {
|
|
562
|
+
#private;
|
|
563
|
+
private readonly runtimeService;
|
|
564
|
+
constructor(runtimeService: McpRuntimeService);
|
|
565
|
+
protected get mcpServerName(): string;
|
|
566
|
+
handleMcpRequest(request: unknown, response: unknown): Promise<unknown>;
|
|
567
|
+
/**
|
|
568
|
+
* Optional Nest-native interception seam before the Node/Web adapter takes ownership.
|
|
569
|
+
* Returning a value short-circuits MCP dispatch and lets Nest serialize that value;
|
|
570
|
+
* returning `undefined` delegates to the named MCP runtime.
|
|
571
|
+
*/
|
|
572
|
+
protected interceptMcpRequest(_request: unknown, _response: unknown): unknown;
|
|
573
|
+
/**
|
|
574
|
+
* Override to compose another fetch-shaped facade around the named runtime.
|
|
575
|
+
* The default applies any configured `oauth` resource-server protection and
|
|
576
|
+
* otherwise returns the runtime untouched.
|
|
577
|
+
*/
|
|
578
|
+
protected createMcpHttpHandler(runtime: McpServerRuntime): FetchLikeMcpHandler;
|
|
579
|
+
/** Override to observe conversion-layer failures handled as HTTP 500 responses. */
|
|
580
|
+
protected getNodeAdapterOptions(): Readonly<ToNodeHandlerOptions> | undefined;
|
|
581
|
+
/**
|
|
582
|
+
* Override to replace the runtime's configured HTTP security posture for
|
|
583
|
+
* this route. The posture is enforced outside `createMcpHttpHandler()`
|
|
584
|
+
* composition, so a rejected request never reaches a composed facade.
|
|
585
|
+
*/
|
|
586
|
+
protected getHttpSecurityOptions(): McpHttpSecurityOptions$1 | undefined;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Creates a controller base bound to one named `McpRuntimeService` server.
|
|
590
|
+
*
|
|
591
|
+
* @example
|
|
592
|
+
* ```ts
|
|
593
|
+
* const ArtifactMcpControllerBase = McpHttpControllerFor("artifact");
|
|
594
|
+
*
|
|
595
|
+
* @Controller({ path: "mcp", version: "1" })
|
|
596
|
+
* @UseGuards(ArtifactGuard)
|
|
597
|
+
* export class ArtifactMcpController extends ArtifactMcpControllerBase {}
|
|
598
|
+
* ```
|
|
599
|
+
*
|
|
600
|
+
* Override `createMcpHttpHandler()` or `getNodeAdapterOptions()` on the concrete
|
|
601
|
+
* controller when composition requires additional Nest-injected providers.
|
|
602
|
+
*/
|
|
603
|
+
declare function McpHttpControllerFor(serverName: string): McpHttpControllerClass;
|
|
604
|
+
//#endregion
|
|
605
|
+
//#region src/mcp-cors.d.ts
|
|
606
|
+
interface McpCorsInput {
|
|
607
|
+
/** Full browser origins (`https://app.example.com`), not bare hostnames. */
|
|
608
|
+
readonly origins: readonly string[];
|
|
609
|
+
/** Allows cookies/credentialed requests. Cookie-authenticated MCP endpoints are CSRF-able; leave off unless required. */
|
|
610
|
+
readonly credentials?: boolean;
|
|
611
|
+
readonly maxAgeSeconds?: number;
|
|
612
|
+
readonly additionalAllowedHeaders?: readonly string[];
|
|
613
|
+
readonly additionalExposedHeaders?: readonly string[];
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Structurally compatible with Nest's `CorsOptions` for `app.enableCors()`.
|
|
617
|
+
* Arrays are mutable because Nest's own option types require `string[]`.
|
|
618
|
+
*/
|
|
619
|
+
interface McpNestCorsOptions {
|
|
620
|
+
origin: string[];
|
|
621
|
+
methods: string[];
|
|
622
|
+
allowedHeaders: string[];
|
|
623
|
+
exposedHeaders: string[];
|
|
624
|
+
credentials: boolean;
|
|
625
|
+
maxAge: number;
|
|
626
|
+
}
|
|
627
|
+
/**
|
|
628
|
+
* CORS options preconfigured for the 2026-07-28 MCP revision, whose
|
|
629
|
+
* `Mcp-Method`/`Mcp-Name` request headers make every browser MCP POST
|
|
630
|
+
* CORS-preflighted. Pass the result to `app.enableCors()` when Nest owns CORS
|
|
631
|
+
* for the whole app; keep exactly one CORS owner per route — with
|
|
632
|
+
* `app.enableCors()` active, the runtime's built-in `httpSecurity.cors`
|
|
633
|
+
* preflight handling never runs, so disable one of the two.
|
|
634
|
+
*/
|
|
635
|
+
declare function mcpCorsOptions(input: McpCorsInput): McpNestCorsOptions;
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region src/oauth/mcp-oauth.controller.d.ts
|
|
638
|
+
/** Constructor returned by {@link McpOAuthControllerFor}. */
|
|
639
|
+
type McpOAuthControllerClass = abstract new (runtimeService: McpRuntimeService) => McpOAuthController;
|
|
640
|
+
/**
|
|
641
|
+
* Nest-native host for a server's OAuth authorization-server proxy endpoints.
|
|
642
|
+
* Each route is an explicit method that calls its proxy operation directly —
|
|
643
|
+
* there is no path matching against a base path, so a Nest global prefix,
|
|
644
|
+
* versioning, or a controller path never desynchronizes from the router. The
|
|
645
|
+
* well-known documents must resolve at the origin root, so mount the concrete
|
|
646
|
+
* controller at `@Controller()` and exclude those paths from any global prefix.
|
|
647
|
+
* Requires the server to configure `oauth.proxy`.
|
|
648
|
+
*/
|
|
649
|
+
declare abstract class McpOAuthController {
|
|
650
|
+
#private;
|
|
651
|
+
private readonly runtimeService;
|
|
652
|
+
constructor(runtimeService: McpRuntimeService);
|
|
653
|
+
protected get mcpServerName(): string;
|
|
654
|
+
authorizationServerMetadata(response: unknown): Promise<void>;
|
|
655
|
+
jwks(response: unknown): Promise<void>;
|
|
656
|
+
protectedResourceMetadata(response: unknown): Promise<void>;
|
|
657
|
+
authorize(request: unknown, response: unknown): Promise<void>;
|
|
658
|
+
consent(request: unknown, response: unknown): Promise<void>;
|
|
659
|
+
callback(request: unknown, response: unknown): Promise<void>;
|
|
660
|
+
token(request: unknown, response: unknown): Promise<void>;
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Creates an OAuth controller base bound to one named `McpRuntimeService`
|
|
664
|
+
* server whose definition configures `oauth.proxy`.
|
|
665
|
+
*
|
|
666
|
+
* @example
|
|
667
|
+
* ```ts
|
|
668
|
+
* const AuthControllerBase = McpOAuthControllerFor("artifact");
|
|
669
|
+
*
|
|
670
|
+
* @Controller()
|
|
671
|
+
* export class ArtifactOAuthController extends AuthControllerBase {}
|
|
672
|
+
* ```
|
|
673
|
+
*/
|
|
674
|
+
declare function McpOAuthControllerFor(serverName: string): McpOAuthControllerClass;
|
|
675
|
+
//#endregion
|
|
676
|
+
//#region src/oauth/mcp-oauth.service.d.ts
|
|
677
|
+
/**
|
|
678
|
+
* Read access to a server's OAuth authorization-server proxy. Its primary use
|
|
679
|
+
* is retrieving the upstream tokens behind a verified access token — the
|
|
680
|
+
* credential source a gateway needs for user-delegated upstream calls.
|
|
681
|
+
*/
|
|
682
|
+
declare class McpOAuthService {
|
|
683
|
+
private readonly runtimeService;
|
|
684
|
+
constructor(runtimeService: McpRuntimeService);
|
|
685
|
+
/**
|
|
686
|
+
* Loads the upstream tokens for the grant referenced by a verified
|
|
687
|
+
* `AuthInfo` (via its `gid` claim). Returns `undefined` when the server has
|
|
688
|
+
* no proxy, the token carries no grant id, or the grant has been revoked.
|
|
689
|
+
*/
|
|
690
|
+
upstreamTokens(serverName: string, authInfo: Readonly<AuthInfo>): Promise<{
|
|
691
|
+
readonly accessToken: string;
|
|
692
|
+
readonly refreshToken?: string;
|
|
693
|
+
readonly expiresAt?: number;
|
|
694
|
+
} | undefined>;
|
|
695
|
+
}
|
|
696
|
+
//#endregion
|
|
697
|
+
//#region src/mcp.module-definition.d.ts
|
|
698
|
+
declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<McpModuleOptions, "forRoot", "createMcpOptions", McpModuleExtras>, OPTIONS_TYPE: McpModuleOptions & Partial<McpModuleExtras>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<McpModuleOptions, "createMcpOptions"> & Partial<McpModuleExtras>;
|
|
699
|
+
type McpForRootOptions = typeof OPTIONS_TYPE;
|
|
700
|
+
type McpForRootAsyncOptions = typeof ASYNC_OPTIONS_TYPE;
|
|
701
|
+
//#endregion
|
|
702
|
+
//#region src/mcp.module.d.ts
|
|
703
|
+
declare class McpModule extends ConfigurableModuleClass {
|
|
704
|
+
static forRoot(options?: McpForRootOptions): DynamicModule;
|
|
705
|
+
static forRootAsync(options: McpForRootAsyncOptions): DynamicModule;
|
|
706
|
+
}
|
|
707
|
+
//#endregion
|
|
708
|
+
//#region src/mcp-handler.middleware.d.ts
|
|
709
|
+
/**
|
|
710
|
+
* Creates handler middleware that can observe the validated invocation while
|
|
711
|
+
* preserving the exact SDK result produced by the downstream capability.
|
|
712
|
+
*/
|
|
713
|
+
declare function createMcpHandlerPassthroughMiddleware(middleware: McpHandlerPassthroughMiddleware): McpHandlerMiddleware;
|
|
714
|
+
//#endregion
|
|
715
|
+
export { type CacheHint, type CallToolResult, type CompletableSchema, type CompleteCallback, type CompleteResourceTemplateCallback, type ElicitInputParams, type GetPromptResult, type Icon, type InputRequiredResult, type InputRequiredSpec, type InputResponseView, MCP_CATALOG_SCHEMAS_TOOL_NAME, MCP_CATALOG_SEARCH_TOOL_NAME, type McpAnonymousAccessPolicy, type McpAuthorizationDecision, McpCapabilitiesService, type McpCapabilityDescriptor, type McpCapabilityMutation, type McpCapabilityMutationKind, type McpCapabilityMutationObserver, type McpCapabilityMutationType, type McpCapabilityVisibility, type McpCapabilityVisibilityPolicy, type McpCatalogEagerExposure, type McpCatalogExposureKind, type McpCatalogExposurePolicy, type McpCatalogExposureResolverInput, type McpCatalogExposureStrategy, type McpCatalogLazyExposure, type McpCatalogNameSelector, type McpCatalogPredicateSelector, type McpCatalogReadonly, type McpCatalogSchemasResult, type McpCatalogSearchExposure, type McpCatalogSearchResult, type McpCatalogSearchResultTool, type McpCatalogTagSelector, type McpCatalogTool, type McpCatalogToolSelector, type McpClientAttributesResolverProvider, type McpClientBootstrapOptions, type McpClientClock, type McpClientConfiguratorProvider, type McpClientFetchMiddlewareProvider, type McpClientFetchProvider, type McpClientForRootAsyncOptions, type McpClientForRootOptions, type McpClientLifecycleErrorReporter, type McpClientMiddlewareProvider, McpClientModule, type McpClientModuleExtras, type McpClientModuleOptions, type McpClientOperationIdFactory, type McpClientPrincipalResolverProvider, type McpClientProgressObserver, type McpClientReconnectionSchedulerProvider, McpClientService, type McpCorsInput, type McpCorsOptions, type McpDynamicHandlerRegistration, type McpForRootAsyncOptions, type McpForRootOptions, type McpGatewayAuthorizationContextProvider, type McpGatewayClientProvider, type McpGatewayDiscoveryCacheProvider, type McpGatewayLifecycleObserverProvider, type McpGatewayMiddlewareProvider, type McpGatewayNameCodecProvider, type McpGatewayObserverErrorReporter, type McpGatewayPromptNameCodecProvider, type McpGatewayResourceTemplateUriCodecProvider, type McpGatewayResourceUriCodecProvider, type McpHandlerAuthorizationPolicy, type McpHandlerInvocationInput, type McpHandlerInvocationOutput, type McpHandlerInvocationOutputFor, type McpHandlerInvocationOutputMap, type McpHandlerLifecycleObserver, type McpHandlerMiddleware, type McpHandlerMiddlewareProvider, type McpHandlerOperationContext, type McpHandlerPassthroughMiddleware, McpHttpController, type McpHttpControllerClass, McpHttpControllerFor, type McpHttpDiscoveryRoutes, type McpHttpRoute, type McpHttpSecurityOptions, type McpHttpSecurityPolicy, McpModule, McpModuleError, type McpModuleErrorCode, type McpModuleExtras, type McpModuleOptions, type McpNestCatalogExposureOptions, type McpNestClientConnectOptions, type McpNestClientDefinition, type McpNestClientIdMetadataOptions, type McpNestClientLifecycleOptions, type McpNestClientOptions, type McpNestClientRuntimeOptions, type McpNestClientTransportDefinition, type McpNestCollaborators, type McpNestCorsOptions, type McpNestGatewayOptions, type McpNestGatewayProviderUpstream, type McpNestGatewayUpstream, type McpNestGatewayUpstreamDefinition, type McpNestHttpClientTransportDefinition, type McpNestOAuthMetadataOptions, type McpNestOAuthProxyOptions, type McpNestOAuthResourceOptions, type McpNestServerDefinition, type McpNestServerHttpOptions, type McpNestServerOAuthOptions, type McpNestServerOptions, type McpNestStdioClientTransportDefinition, type McpOAuthConsentProvider, McpOAuthController, type McpOAuthControllerClass, McpOAuthControllerFor, type McpOAuthFetchProvider, type McpOAuthSecretProvider, McpOAuthService, type McpOAuthSigningKeyProvider, type McpOAuthSubjectResolverProvider, type McpOAuthTokenVerifierProvider, type McpOAuthUpstreamProvider, type McpProviderToken, type McpRequestStateVerifier, McpRuntimeService, type McpServerBuildContext, type McpServerContributor, type McpServerErrorReporter, type McpServerLifecycleObserver, type McpServerMiddleware, type McpServerMiddlewareProvider, type McpServerPrincipal, type McpServerPrincipalClaims, type McpServerPrincipalClaimsProvider, type McpServerRuntimeObserverProvider, Prompt, type PromptCallback, type PromptMethodDecorator, type PromptOptions, type ReadResourceCallback, type ReadResourceResult, type ReadResourceTemplateCallback, type RequestStateCodec, type RequestStateCodecOptions, Resource, type ResourceMetadata, type ResourceMethodDecorator, type ResourceOptions, ResourceTemplate, type ServerContext, type StandardSchemaWithJSON, Targets, Tool, type ToolAnnotations, type ToolCallback, type ToolMethodDecorator, type ToolOptions, acceptedContent, allowMcpOperation, completable, createMcpHandlerPassthroughMiddleware, createRequestStateCodec, denyMcpOperation, fromJsonSchema, inputRequired, inputResponse, mcpCorsOptions };
|
|
716
|
+
//# sourceMappingURL=index.d.mts.map
|