@rekog/mcp-nest 1.9.5 → 1.9.6

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/README.md CHANGED
@@ -34,6 +34,10 @@ With `@rekog/mcp-nest` you define tools, resources, and prompts in a way that's
34
34
  **Are you interested to build ChatGPT widgets (with the OpenAI SDK) or MCP apps?**
35
35
  Find out how to do that with `@rekog/MCP-Nest` in this repository [MCP-Nest-Samples](https://github.com/rinormaloku/MCP-Nest-Samples)
36
36
 
37
+
38
+ > [!TIP]
39
+ > You can easily learn about this package using the `chat` tab in [Context7](https://context7.com/rekog-labs/mcp-nest?tab=chat). Better yet, connect the [Context7 MCP server](https://github.com/upstash/context7#installation) to allow your AI agents to access the documentation and implement MCP-Nest for you.
40
+
37
41
  ## Installation
38
42
 
39
43
  ```bash
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-prompts.handler.d.ts","sourceRoot":"","sources":["../../../../src/mcp/services/handlers/mcp-prompts.handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAQpE,OAAO,EAEL,2BAA2B,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAOzE,qBACa,iBAAkB,SAAQ,cAAc;IAKxB,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAHrD,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,2BAA2B,EACrC,SAAS,EAAE,SAAS,EACsB,WAAW,EAAE,MAAM,EAC1B,OAAO,CAAC,EAAE,UAAU;IAKzD,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW;CA4GhE"}
1
+ {"version":3,"file":"mcp-prompts.handler.d.ts","sourceRoot":"","sources":["../../../../src/mcp/services/handlers/mcp-prompts.handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAQpE,OAAO,EAEL,2BAA2B,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAOzE,qBACa,iBAAkB,SAAQ,cAAc;IAKxB,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAHrD,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,2BAA2B,EACrC,SAAS,EAAE,SAAS,EACsB,WAAW,EAAE,MAAM,EAC1B,OAAO,CAAC,EAAE,UAAU;IAKzD,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW;CA2GhE"}
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-prompts.handler.js","sourceRoot":"","sources":["../../../../src/mcp/services/handlers/mcp-prompts.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAqE;AACrE,uCAAsE;AAEtE,iEAM4C;AAC5C,sFAG2C;AAC3C,yDAAoD;AAIpD,kFAGyC;AAGlC,IAAM,iBAAiB,yBAAvB,MAAM,iBAAkB,SAAQ,iCAAc;IACnD,YACE,SAAoB,EACpB,QAAqC,EACrC,SAAoB,EACsB,WAAmB,EAC1B,OAAoB;QAEvD,KAAK,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,mBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAH7B,gBAAW,GAAX,WAAW,CAAQ;IAI/D,CAAC;IAED,gB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AEF,IAAI,CAAC,cAAc,EAAE,CAAC;oBACpB,MAAM,IAAI,mBAAQ,CAChB,oBAAS,CAAC,cAAc,EACxB,mBAAmB,IAAI,EAAE,CAC1B,CAAC;gBACJ,CAAC;gBAED,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;gBAEzC,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,UAAU,CAAC,CAAC,IAAI,CAClD,cAAc,EACd,OAAO,CAAC,MAAM,CAAC,SAAS,EACxB,OAAO,EACP,WAAW,CAAC,GAAG,CAChB,CAAC;gBAEF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE,MAAM,CAAC,CAAC;gBAG3D,OAAO,MAAM,CAAC;YAChB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,WAAW,CAAC,KAAc,EAAE,UAAW,EAAE,WAAW,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF,CAAA;AAvHY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,OAAO,EAAE,CAAC;IAMhC,WAAA,IAAA,eAAM,EAAC,eAAe,CAAC,CAAA;IACvB,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,aAAa,CAAC,CAAA;qCAJvB,gBAAS;QACV,4DAA2B;QAC1B,gBAAS;GAJX,iBAAiB,CAuH7B","sourcesContent":["import { Inject, Injectable, Optional, Scope } from '@nestjs/common';\nimport { ContextIdFactory, ModuleRef, Reflector } from '@nestjs/core';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport {\n ErrorCode,\n GetPromptRequestSchema,\n ListPromptsRequestSchema,\n McpError,\n PromptArgument,\n} from '@modelcontextprotocol/sdk/types.js';\nimport {\n DiscoveredCapability,\n McpRegistryDiscoveryService,\n} from '../mcp-registry-discovery.service';\nimport { McpHandlerBase } from './mcp-handler.base';\nimport { HttpRequest } from '../../interfaces/http-adapter.interface';\nimport type { McpOptions } from '../../interfaces/mcp-options.interface';\nimport { PromptMetadata } from '../../decorators';\nimport {\n McpRegistryService,\n DYNAMIC_PROMPT_HANDLER_TOKEN,\n} from '../mcp-dynamic-registry.service';\n\n@Injectable({ scope: Scope.REQUEST })\nexport class McpPromptsHandler extends McpHandlerBase {\n constructor(\n moduleRef: ModuleRef,\n registry: McpRegistryDiscoveryService,\n reflector: Reflector,\n @Inject('MCP_MODULE_ID') private readonly mcpModuleId: string,\n @Optional() @Inject('MCP_OPTIONS') options?: McpOptions,\n ) {\n super(moduleRef, registry, reflector, McpPromptsHandler.name, options);\n }\n\n registerHandlers(mcpServer: McpServer, httpRequest: HttpRequest) {\n if (this.registry.getPrompts(this.mcpModuleId).length === 0) {\n this.logger.debug('No prompts registered, skipping prompt handlers');\n return;\n }\n mcpServer.server.setRequestHandler(ListPromptsRequestSchema, () => {\n this.logger.debug('ListPromptsRequestSchema is being called');\n\n const prompts = this.registry\n .getPrompts(this.mcpModuleId)\n .map((prompt) => ({\n name: prompt.metadata.name,\n description: prompt.metadata.description,\n arguments: prompt.metadata.parameters\n ? Object.entries(prompt.metadata.parameters.shape).map(\n ([name, field]): PromptArgument => ({\n name,\n description: field.description,\n required: !field.isOptional(),\n }),\n )\n : [],\n }));\n\n return {\n prompts,\n };\n });\n\n mcpServer.server.setRequestHandler(\n GetPromptRequestSchema,\n async (request) => {\n this.logger.debug('GetPromptRequestSchema is being called');\n let promptInfo: DiscoveredCapability<PromptMetadata> | undefined;\n\n try {\n const name = request.params.name;\n promptInfo = this.registry.findPrompt(this.mcpModuleId, name);\n\n if (!promptInfo) {\n throw new McpError(\n ErrorCode.MethodNotFound,\n `Unknown prompt: ${name}`,\n );\n }\n\n const context = this.createContext(mcpServer, request);\n\n if (promptInfo.providerClass === DYNAMIC_PROMPT_HANDLER_TOKEN) {\n const handler =\n McpRegistryService.getPromptHandlerByModuleId(\n this.mcpModuleId,\n name,\n );\n\n if (!handler) {\n throw new McpError(\n ErrorCode.MethodNotFound,\n `Handler not found for dynamic prompt: ${name}`,\n );\n }\n\n const result = await handler(\n request.params.arguments,\n context,\n httpRequest.raw,\n );\n\n this.logger.debug('GetPromptRequestSchema result', result);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return result;\n }\n\n const contextId = ContextIdFactory.getByRequest(httpRequest);\n this.moduleRef.registerRequestByContextId(httpRequest, contextId);\n\n const promptInstance = await this.moduleRef.resolve(\n promptInfo.providerClass,\n contextId,\n { strict: false },\n );\n\n if (!promptInstance) {\n throw new McpError(\n ErrorCode.MethodNotFound,\n `Unknown prompt: ${name}`,\n );\n }\n\n const methodName = promptInfo.methodName;\n\n const result = await promptInstance[methodName].call(\n promptInstance,\n request.params.arguments,\n context,\n httpRequest.raw,\n );\n\n this.logger.debug('GetPromptRequestSchema result', result);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return result;\n } catch (error) {\n this.handleError(error as Error, promptInfo!, httpRequest);\n }\n },\n );\n }\n}\n"]}
1
+ {"version":3,"file":"mcp-prompts.handler.js","sourceRoot":"","sources":["../../../../src/mcp/services/handlers/mcp-prompts.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAqE;AACrE,uCAAsE;AAEtE,iEAM4C;AAC5C,sFAG2C;AAC3C,yDAAoD;AAIpD,kFAGyC;AAGlC,IAAM,iBAAiB,yBAAvB,MAAM,iBAAkB,SAAQ,iCAAc;IACnD,YACE,SAAoB,EACpB,QAAqC,EACrC,SAAoB,EACsB,WAAmB,EAC1B,OAAoB;QAEvD,KAAK,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,mBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAH7B,gBAAW,GAAX,WAAW,CAAQ;IAI/D,CAAC;IAED,gBAAgB,CAAC,SAAoB,EAAE,WAAwB;QAC7D,IAAI,IAAI,CAAC,Q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Q,CAChB,oBAAS,CAAC,cAAc,EACxB,mBAAmB,IAAI,EAAE,CAC1B,CAAC;gBACJ,CAAC;gBAED,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;gBAEzC,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,UAAU,CAAC,CAAC,IAAI,CAClD,cAAc,EACd,OAAO,CAAC,MAAM,CAAC,SAAS,EACxB,OAAO,EACP,WAAW,CAAC,GAAG,CAChB,CAAC;gBAEF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE,MAAM,CAAC,CAAC;gBAG3D,OAAO,MAAM,CAAC;YAChB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,WAAW,CAAC,KAAc,EAAE,UAAW,EAAE,WAAW,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF,CAAA;AAtHY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,OAAO,EAAE,CAAC;IAMhC,WAAA,IAAA,eAAM,EAAC,eAAe,CAAC,CAAA;IACvB,WAAA,IAAA,iBAAQ,GAAE,CAAA;IAAE,WAAA,IAAA,eAAM,EAAC,aAAa,CAAC,CAAA;qCAJvB,gBAAS;QACV,4DAA2B;QAC1B,gBAAS;GAJX,iBAAiB,CAsH7B","sourcesContent":["import { Inject, Injectable, Optional, Scope } from '@nestjs/common';\nimport { ContextIdFactory, ModuleRef, Reflector } from '@nestjs/core';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport {\n ErrorCode,\n GetPromptRequestSchema,\n ListPromptsRequestSchema,\n McpError,\n PromptArgument,\n} from '@modelcontextprotocol/sdk/types.js';\nimport {\n DiscoveredCapability,\n McpRegistryDiscoveryService,\n} from '../mcp-registry-discovery.service';\nimport { McpHandlerBase } from './mcp-handler.base';\nimport { HttpRequest } from '../../interfaces/http-adapter.interface';\nimport type { McpOptions } from '../../interfaces/mcp-options.interface';\nimport { PromptMetadata } from '../../decorators';\nimport {\n McpRegistryService,\n DYNAMIC_PROMPT_HANDLER_TOKEN,\n} from '../mcp-dynamic-registry.service';\n\n@Injectable({ scope: Scope.REQUEST })\nexport class McpPromptsHandler extends McpHandlerBase {\n constructor(\n moduleRef: ModuleRef,\n registry: McpRegistryDiscoveryService,\n reflector: Reflector,\n @Inject('MCP_MODULE_ID') private readonly mcpModuleId: string,\n @Optional() @Inject('MCP_OPTIONS') options?: McpOptions,\n ) {\n super(moduleRef, registry, reflector, McpPromptsHandler.name, options);\n }\n\n registerHandlers(mcpServer: McpServer, httpRequest: HttpRequest) {\n if (this.registry.getPrompts(this.mcpModuleId).length === 0) {\n this.logger.debug('No prompts registered, skipping prompt handlers');\n return;\n }\n mcpServer.server.setRequestHandler(ListPromptsRequestSchema, () => {\n this.logger.debug('ListPromptsRequestSchema is being called');\n\n const prompts = this.registry\n .getPrompts(this.mcpModuleId)\n .map((prompt) => ({\n name: prompt.metadata.name,\n description: prompt.metadata.description,\n arguments: prompt.metadata.parameters\n ? Object.entries(prompt.metadata.parameters.shape).map(\n ([name, field]): PromptArgument => ({\n name,\n description: field.description,\n required: !field.isOptional(),\n }),\n )\n : [],\n }));\n\n return {\n prompts,\n };\n });\n\n mcpServer.server.setRequestHandler(\n GetPromptRequestSchema,\n async (request) => {\n this.logger.debug('GetPromptRequestSchema is being called');\n let promptInfo: DiscoveredCapability<PromptMetadata> | undefined;\n\n try {\n const name = request.params.name;\n promptInfo = this.registry.findPrompt(this.mcpModuleId, name);\n\n if (!promptInfo) {\n throw new McpError(\n ErrorCode.MethodNotFound,\n `Unknown prompt: ${name}`,\n );\n }\n\n const context = this.createContext(mcpServer, request);\n\n if (promptInfo.providerClass === DYNAMIC_PROMPT_HANDLER_TOKEN) {\n const handler = McpRegistryService.getPromptHandlerByModuleId(\n this.mcpModuleId,\n name,\n );\n\n if (!handler) {\n throw new McpError(\n ErrorCode.MethodNotFound,\n `Handler not found for dynamic prompt: ${name}`,\n );\n }\n\n const result = await handler(\n request.params.arguments,\n context,\n httpRequest.raw,\n );\n\n this.logger.debug('GetPromptRequestSchema result', result);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return result;\n }\n\n const contextId = ContextIdFactory.getByRequest(httpRequest);\n this.moduleRef.registerRequestByContextId(httpRequest, contextId);\n\n const promptInstance = await this.moduleRef.resolve(\n promptInfo.providerClass,\n contextId,\n { strict: false },\n );\n\n if (!promptInstance) {\n throw new McpError(\n ErrorCode.MethodNotFound,\n `Unknown prompt: ${name}`,\n );\n }\n\n const methodName = promptInfo.methodName;\n\n const result = await promptInstance[methodName].call(\n promptInstance,\n request.params.arguments,\n context,\n httpRequest.raw,\n );\n\n this.logger.debug('GetPromptRequestSchema result', result);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return result;\n } catch (error) {\n this.handleError(error as Error, promptInfo!, httpRequest);\n }\n },\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"stdio.service.d.ts","sourceRoot":"","sources":["../../../src/mcp/transport/stdio.service.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAIzF,qBACa,YAAa,YAAW,sBAAsB;IAIhC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACtB,OAAO,CAAC,QAAQ,CAAC,WAAW;IACrD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAN/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAGU,OAAO,EAAE,UAAU,EACjB,WAAW,EAAE,MAAM,EAC5C,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,2BAA2B;IAKtD,sBAAsB;CA4C7B"}
1
+ {"version":3,"file":"stdio.service.d.ts","sourceRoot":"","sources":["../../../src/mcp/transport/stdio.service.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAoB,SAAS,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAIzF,qBACa,YAAa,YAAW,sBAAsB;IAIhC,OAAO,CAAC,QAAQ,CAAC,OAAO;IACtB,OAAO,CAAC,QAAQ,CAAC,WAAW;IACrD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAN/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAGU,OAAO,EAAE,UAAU,EACjB,WAAW,EAAE,MAAM,EAC5C,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,2BAA2B;IAKtD,sBAAsB;CA8C7B"}
@@ -31,9 +31,11 @@ let StdioService = StdioService_1 = class StdioService {
31
31
  this.logger = (0, mcp_logger_factory_1.createMcpLogger)(StdioService_1.name, this.options);
32
32
  }
33
33
  async onApplicationBootstrap() {
34
- if (this.options.transport !== interfaces_1.McpTransportType.STDIO) {
34
+ const transports = Array.isArray(this.options.transport)
35
+ ? this.options.transport
36
+ : [this.options.transport];
37
+ if (!transports.includes(interfaces_1.McpTransportType.STDIO))
35
38
  return;
36
- }
37
39
  this.logger.log('Bootstrapping MCP STDIO...');
38
40
  const toolsWithGuards = this.toolRegistry
39
41
  .getTools(this.mcpModuleId)
@@ -1 +1 @@
1
- {"version":3,"file":"stdio.service.js","sourceRoot":"","sources":["../../../src/mcp/transport/stdio.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wEAAiF;AACjF,2CAKwB;AACxB,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IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,MAAM,CACZ,CAAC;QAEF,MAAM,SAAS,GAAG,uBAAgB,CAAC,MAAM,EAAE,CAAC;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAC3C,yCAAkB,EAClB,SAAS,EACT,EAAE,MAAM,EAAE,KAAK,EAAE,CAClB,CAAC;QAGF,QAAQ,CAAC,uBAAuB,CAAC,SAAS,EAAE,EAAS,CAAC,CAAC;QAEvD,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;QAC7C,MAAM,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEnC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF,CAAA;AAxDY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,eAAM,EAAC,aAAa,CAAC,CAAA;IACrB,WAAA,IAAA,eAAM,EAAC,eAAe,CAAC,CAAA;qDACI,gBAAS;QACN,4DAA2B;GAPjD,YAAY,CAwDxB","sourcesContent":["import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport {\n Inject,\n Injectable,\n Logger,\n OnApplicationBootstrap,\n} from '@nestjs/common';\nimport { ContextIdFactory, ModuleRef } from '@nestjs/core';\nimport { McpTransportType } from '../interfaces';\nimport type { McpOptions } from '../interfaces';\nimport { McpExecutorService } from '../services/mcp-executor.service';\nimport { McpRegistryDiscoveryService } from '../services/mcp-registry-discovery.service';\nimport { createMcpLogger } from '../utils/mcp-logger.factory';\nimport { createMcpServer } from '../utils/mcp-server.factory';\n\n@Injectable()\nexport class StdioService implements OnApplicationBootstrap {\n private readonly logger: Logger;\n\n constructor(\n @Inject('MCP_OPTIONS') private readonly options: McpOptions,\n @Inject('MCP_MODULE_ID') private readonly mcpModuleId: string,\n private readonly moduleRef: ModuleRef,\n private readonly toolRegistry: McpRegistryDiscoveryService,\n ) {\n this.logger = createMcpLogger(StdioService.name, this.options);\n }\n\n async onApplicationBootstrap() {\n if (this.options.transport !== McpTransportType.STDIO) {\n return;\n }\n this.logger.log('Bootstrapping MCP STDIO...');\n\n // Warn about tools with @ToolGuards() - they require HTTP context\n const toolsWithGuards = this.toolRegistry\n .getTools(this.mcpModuleId)\n .filter(\n (tool) => tool.metadata.guards && tool.metadata.guards.length > 0,\n );\n\n if (toolsWithGuards.length > 0) {\n const toolNames = toolsWithGuards.map((t) => t.metadata.name).join(', ');\n this.logger.warn(\n `@ToolGuards() are not supported with STDIO transport. ` +\n `The following tools have guards configured and will be hidden: ${toolNames}. ` +\n `Consider using HTTP transport.`,\n );\n }\n\n const mcpServer = createMcpServer(\n this.mcpModuleId,\n this.toolRegistry,\n this.options,\n this.logger,\n );\n\n const contextId = ContextIdFactory.create();\n const executor = await this.moduleRef.resolve(\n McpExecutorService,\n contextId,\n { strict: false },\n );\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n executor.registerRequestHandlers(mcpServer, {} as any);\n\n const transport = new StdioServerTransport();\n await mcpServer.connect(transport);\n\n this.logger.log('MCP STDIO ready');\n }\n}\n"]}
1
+ {"version":3,"file":"stdio.service.js","sourceRoot":"","sources":["../../../src/mcp/transport/stdio.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wEAAiF;AACjF,2CAKwB;AACxB,uCAA2D;AAC3D,8CAAiD;AAEjD,2EAAsE;AACtE,+FAAyF;AACzF,oEAA8D;AAC9D,oEAA8D;AAGvD,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAGvB,YAC0C,OAAmB,EACjB,WAAmB,EAC5C,SAAoB,EACpB,YAAyC;QAHlB,YAAO,GAAP,OAAO,CAAY;QACjB,gBAAW,GAAX,WAAW,CAAQ;QAC5C,cAAS,GAAT,SAAS,CAAW;QACpB,iBAAY,GAAZ,YAAY,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BAAgB,CAAC,MAAM,EAAE,CAAC;QAC5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAC3C,yCAAkB,EAClB,SAAS,EACT,EAAE,MAAM,EAAE,KAAK,EAAE,CAClB,CAAC;QAGF,QAAQ,CAAC,uBAAuB,CAAC,SAAS,EAAE,EAAS,CAAC,CAAC;QAEvD,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;QAC7C,MAAM,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEnC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF,CAAA;AA1DY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,eAAM,EAAC,aAAa,CAAC,CAAA;IACrB,WAAA,IAAA,eAAM,EAAC,eAAe,CAAC,CAAA;qDACI,gBAAS;QACN,4DAA2B;GAPjD,YAAY,CA0DxB","sourcesContent":["import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport {\n Inject,\n Injectable,\n Logger,\n OnApplicationBootstrap,\n} from '@nestjs/common';\nimport { ContextIdFactory, ModuleRef } from '@nestjs/core';\nimport { McpTransportType } from '../interfaces';\nimport type { McpOptions } from '../interfaces';\nimport { McpExecutorService } from '../services/mcp-executor.service';\nimport { McpRegistryDiscoveryService } from '../services/mcp-registry-discovery.service';\nimport { createMcpLogger } from '../utils/mcp-logger.factory';\nimport { createMcpServer } from '../utils/mcp-server.factory';\n\n@Injectable()\nexport class StdioService implements OnApplicationBootstrap {\n private readonly logger: Logger;\n\n constructor(\n @Inject('MCP_OPTIONS') private readonly options: McpOptions,\n @Inject('MCP_MODULE_ID') private readonly mcpModuleId: string,\n private readonly moduleRef: ModuleRef,\n private readonly toolRegistry: McpRegistryDiscoveryService,\n ) {\n this.logger = createMcpLogger(StdioService.name, this.options);\n }\n\n async onApplicationBootstrap() {\n const transports = Array.isArray(this.options.transport)\n ? this.options.transport\n : [this.options.transport];\n if (!transports.includes(McpTransportType.STDIO)) return;\n\n this.logger.log('Bootstrapping MCP STDIO...');\n\n // Warn about tools with @ToolGuards() - they require HTTP context\n const toolsWithGuards = this.toolRegistry\n .getTools(this.mcpModuleId)\n .filter(\n (tool) => tool.metadata.guards && tool.metadata.guards.length > 0,\n );\n\n if (toolsWithGuards.length > 0) {\n const toolNames = toolsWithGuards.map((t) => t.metadata.name).join(', ');\n this.logger.warn(\n `@ToolGuards() are not supported with STDIO transport. ` +\n `The following tools have guards configured and will be hidden: ${toolNames}. ` +\n `Consider using HTTP transport.`,\n );\n }\n\n const mcpServer = createMcpServer(\n this.mcpModuleId,\n this.toolRegistry,\n this.options,\n this.logger,\n );\n\n const contextId = ContextIdFactory.create();\n const executor = await this.moduleRef.resolve(\n McpExecutorService,\n contextId,\n { strict: false },\n );\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n executor.registerRequestHandlers(mcpServer, {} as any);\n\n const transport = new StdioServerTransport();\n await mcpServer.connect(transport);\n\n this.logger.log('MCP STDIO ready');\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rekog/mcp-nest",
3
- "version": "1.9.5",
3
+ "version": "1.9.6",
4
4
  "description": "NestJS module for creating Model Context Protocol (MCP) servers",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -82,11 +82,10 @@ export class McpPromptsHandler extends McpHandlerBase {
82
82
  const context = this.createContext(mcpServer, request);
83
83
 
84
84
  if (promptInfo.providerClass === DYNAMIC_PROMPT_HANDLER_TOKEN) {
85
- const handler =
86
- McpRegistryService.getPromptHandlerByModuleId(
87
- this.mcpModuleId,
88
- name,
89
- );
85
+ const handler = McpRegistryService.getPromptHandlerByModuleId(
86
+ this.mcpModuleId,
87
+ name,
88
+ );
90
89
 
91
90
  if (!handler) {
92
91
  throw new McpError(
@@ -27,9 +27,11 @@ export class StdioService implements OnApplicationBootstrap {
27
27
  }
28
28
 
29
29
  async onApplicationBootstrap() {
30
- if (this.options.transport !== McpTransportType.STDIO) {
31
- return;
32
- }
30
+ const transports = Array.isArray(this.options.transport)
31
+ ? this.options.transport
32
+ : [this.options.transport];
33
+ if (!transports.includes(McpTransportType.STDIO)) return;
34
+
33
35
  this.logger.log('Bootstrapping MCP STDIO...');
34
36
 
35
37
  // Warn about tools with @ToolGuards() - they require HTTP context