@rekog/mcp-nest 1.9.7-alpha.0 → 1.9.7

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 (77) hide show
  1. package/dist/mcp/services/handlers/mcp-tools.handler.js +1 -1
  2. package/dist/mcp/services/handlers/mcp-tools.handler.js.map +1 -1
  3. package/package.json +3 -4
  4. package/src/mcp/services/handlers/mcp-tools.handler.spec.ts +41 -0
  5. package/src/mcp/services/handlers/mcp-tools.handler.ts +1 -1
  6. package/dist/elicitation/elicitation.controller.d.ts +0 -38
  7. package/dist/elicitation/elicitation.controller.d.ts.map +0 -1
  8. package/dist/elicitation/elicitation.controller.js +0 -222
  9. package/dist/elicitation/elicitation.controller.js.map +0 -1
  10. package/dist/elicitation/index.d.ts +0 -13
  11. package/dist/elicitation/index.d.ts.map +0 -1
  12. package/dist/elicitation/index.js +0 -26
  13. package/dist/elicitation/index.js.map +0 -1
  14. package/dist/elicitation/interfaces/elicitation-options.interface.d.ts +0 -36
  15. package/dist/elicitation/interfaces/elicitation-options.interface.d.ts.map +0 -1
  16. package/dist/elicitation/interfaces/elicitation-options.interface.js +0 -20
  17. package/dist/elicitation/interfaces/elicitation-options.interface.js.map +0 -1
  18. package/dist/elicitation/interfaces/elicitation-store.interface.d.ts +0 -14
  19. package/dist/elicitation/interfaces/elicitation-store.interface.d.ts.map +0 -1
  20. package/dist/elicitation/interfaces/elicitation-store.interface.js +0 -5
  21. package/dist/elicitation/interfaces/elicitation-store.interface.js.map +0 -1
  22. package/dist/elicitation/interfaces/elicitation.interface.d.ts +0 -31
  23. package/dist/elicitation/interfaces/elicitation.interface.d.ts.map +0 -1
  24. package/dist/elicitation/interfaces/elicitation.interface.js +0 -3
  25. package/dist/elicitation/interfaces/elicitation.interface.js.map +0 -1
  26. package/dist/elicitation/interfaces/index.d.ts +0 -4
  27. package/dist/elicitation/interfaces/index.d.ts.map +0 -1
  28. package/dist/elicitation/interfaces/index.js +0 -20
  29. package/dist/elicitation/interfaces/index.js.map +0 -1
  30. package/dist/elicitation/mcp-elicitation.module.d.ts +0 -10
  31. package/dist/elicitation/mcp-elicitation.module.d.ts.map +0 -1
  32. package/dist/elicitation/mcp-elicitation.module.js +0 -141
  33. package/dist/elicitation/mcp-elicitation.module.js.map +0 -1
  34. package/dist/elicitation/services/elicitation.service.d.ts +0 -28
  35. package/dist/elicitation/services/elicitation.service.d.ts.map +0 -1
  36. package/dist/elicitation/services/elicitation.service.js +0 -146
  37. package/dist/elicitation/services/elicitation.service.js.map +0 -1
  38. package/dist/elicitation/services/index.d.ts +0 -2
  39. package/dist/elicitation/services/index.d.ts.map +0 -1
  40. package/dist/elicitation/services/index.js +0 -18
  41. package/dist/elicitation/services/index.js.map +0 -1
  42. package/dist/elicitation/stores/index.d.ts +0 -2
  43. package/dist/elicitation/stores/index.d.ts.map +0 -1
  44. package/dist/elicitation/stores/index.js +0 -18
  45. package/dist/elicitation/stores/index.js.map +0 -1
  46. package/dist/elicitation/stores/memory-elicitation.store.d.ts +0 -19
  47. package/dist/elicitation/stores/memory-elicitation.store.d.ts.map +0 -1
  48. package/dist/elicitation/stores/memory-elicitation.store.js +0 -132
  49. package/dist/elicitation/stores/memory-elicitation.store.js.map +0 -1
  50. package/dist/elicitation/templates/api-key-form.template.d.ts +0 -12
  51. package/dist/elicitation/templates/api-key-form.template.d.ts.map +0 -1
  52. package/dist/elicitation/templates/api-key-form.template.js +0 -32
  53. package/dist/elicitation/templates/api-key-form.template.js.map +0 -1
  54. package/dist/elicitation/templates/base.template.d.ts +0 -9
  55. package/dist/elicitation/templates/base.template.d.ts.map +0 -1
  56. package/dist/elicitation/templates/base.template.js +0 -239
  57. package/dist/elicitation/templates/base.template.js.map +0 -1
  58. package/dist/elicitation/templates/confirmation.template.d.ts +0 -13
  59. package/dist/elicitation/templates/confirmation.template.d.ts.map +0 -1
  60. package/dist/elicitation/templates/confirmation.template.js +0 -24
  61. package/dist/elicitation/templates/confirmation.template.js.map +0 -1
  62. package/dist/elicitation/templates/index.d.ts +0 -5
  63. package/dist/elicitation/templates/index.d.ts.map +0 -1
  64. package/dist/elicitation/templates/index.js +0 -21
  65. package/dist/elicitation/templates/index.js.map +0 -1
  66. package/dist/elicitation/templates/success.template.d.ts +0 -21
  67. package/dist/elicitation/templates/success.template.d.ts.map +0 -1
  68. package/dist/elicitation/templates/success.template.js +0 -57
  69. package/dist/elicitation/templates/success.template.js.map +0 -1
  70. package/dist/mcp/services/mcp-registry.service.d.ts +0 -62
  71. package/dist/mcp/services/mcp-registry.service.d.ts.map +0 -1
  72. package/dist/mcp/services/mcp-registry.service.js +0 -381
  73. package/dist/mcp/services/mcp-registry.service.js.map +0 -1
  74. package/dist/mcp/services/mcp-tool-builder.service.d.ts +0 -15
  75. package/dist/mcp/services/mcp-tool-builder.service.d.ts.map +0 -1
  76. package/dist/mcp/services/mcp-tool-builder.service.js +0 -70
  77. package/dist/mcp/services/mcp-tool-builder.service.js.map +0 -1
@@ -50,7 +50,7 @@ let McpToolsHandler = McpToolsHandler_1 = class McpToolsHandler extends mcp_hand
50
50
  throw new types_js_1.McpError(types_js_1.ErrorCode.InternalError, `Tool result does not match outputSchema: ${validation.error.message}`);
51
51
  }
52
52
  return {
53
- structuredContent: result,
53
+ structuredContent: validation.data,
54
54
  content: this.buildDefaultContentBlock(result),
55
55
  };
56
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-tools.handler.js","sourceRoot":"","sources":["../../../../src/mcp/services/handlers/mcp-tools.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,iEAM4C;AAC5C,2CAOwB;AACxB,uCAAsE;AACtE,sFAG2C;AAE3C,yDAAoD;AAIpD,8EAAyE;AACzE,0GAAgG;AAChG,kFAAuF;AAEvF,kFAGyC;AAGlC,IAAM,eAAe,uBAArB,MAAM,eAAgB,SAAQ,iCAAc;IAGjD,YACE,SAAoB,EACpB,QAAqC,EACrC,SAAoB,EACsB,WAAmB,EACrB,OAAmB,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EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,OAAO,EAAE,CAAC;IAQhC,WAAA,IAAA,eAAM,EAAC,eAAe,CAAC,CAAA;IACvB,WAAA,IAAA,eAAM,EAAC,aAAa,CAAC,CAAA;qCAJX,gBAAS;QACV,4DAA2B;QAC1B,gBAAS,kBAGU,qDAAwB;GAT7C,eAAe,CA6X3B","sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport {\n CallToolRequestSchema,\n CallToolResult,\n ErrorCode,\n ListToolsRequestSchema,\n McpError,\n} from '@modelcontextprotocol/sdk/types.js';\nimport {\n CanActivate,\n ExecutionContext,\n Inject,\n Injectable,\n Scope,\n Type,\n} from '@nestjs/common';\nimport { ContextIdFactory, ModuleRef, Reflector } from '@nestjs/core';\nimport {\n DiscoveredCapability,\n McpRegistryDiscoveryService,\n} from '../mcp-registry-discovery.service';\nimport { ToolGuardExecutionContext, ToolMetadata } from '../../decorators';\nimport { McpHandlerBase } from './mcp-handler.base';\nimport { ZodType } from 'zod';\nimport { HttpRequest } from '../../interfaces/http-adapter.interface';\nimport { McpRequestWithUser } from 'src/authz';\nimport { ToolAuthorizationService } from '../tool-authorization.service';\nimport { toJsonSchemaCompat } from '@modelcontextprotocol/sdk/server/zod-json-schema-compat.js';\nimport { normalizeObjectSchema } from '@modelcontextprotocol/sdk/server/zod-compat.js';\nimport type { McpOptions } from '../../interfaces/mcp-options.interface';\nimport {\n McpRegistryService,\n DYNAMIC_TOOL_HANDLER_TOKEN,\n} from '../mcp-dynamic-registry.service';\n\n@Injectable({ scope: Scope.REQUEST })\nexport class McpToolsHandler extends McpHandlerBase {\n private readonly moduleHasGuards: boolean;\n\n constructor(\n moduleRef: ModuleRef,\n registry: McpRegistryDiscoveryService,\n reflector: Reflector,\n @Inject('MCP_MODULE_ID') private readonly mcpModuleId: string,\n @Inject('MCP_OPTIONS') private readonly options: McpOptions,\n private readonly authService: ToolAuthorizationService,\n ) {\n super(moduleRef, registry, reflector, McpToolsHandler.name, options);\n this.moduleHasGuards =\n this.options.guards !== undefined && this.options.guards.length > 0;\n }\n\n private buildDefaultContentBlock(result: any) {\n return [\n {\n type: 'text',\n text: JSON.stringify(result),\n },\n ];\n }\n\n private formatToolResult(result: any, outputSchema?: ZodType): any {\n if (result && typeof result === 'object' && Array.isArray(result.content)) {\n return result;\n }\n\n if (outputSchema) {\n const validation = outputSchema.safeParse(result);\n if (!validation.success) {\n throw new McpError(\n ErrorCode.InternalError,\n `Tool result does not match outputSchema: ${validation.error.message}`,\n );\n }\n return {\n structuredContent: result,\n content: this.buildDefaultContentBlock(result),\n };\n }\n\n return {\n content: this.buildDefaultContentBlock(result),\n };\n }\n\n protected override createErrorResponse(\n errorText: string,\n ): CallToolResult | never {\n return {\n content: [{ type: 'text', text: errorText }],\n isError: true,\n };\n }\n\n /**\n * Creates an ExecutionContext for @ToolGuards() evaluation.\n *\n * Only the fields documented in ToolGuardExecutionContext are available.\n * Invalid fields throw with a descriptive message rather than silently\n * returning garbage.\n */\n private createToolGuardExecutionContext(\n httpRequest: HttpRequest,\n tool: DiscoveredCapability<ToolMetadata>,\n ): ToolGuardExecutionContext & ExecutionContext {\n const providerClass = tool.providerClass as Type;\n const methodHandler =\n providerClass.prototype?.[tool.methodName] ?? (() => {});\n\n const unavailable = (method: string): never => {\n throw new Error(\n `${method} is not available in @ToolGuards() context. ` +\n `MCP tools share a single HTTP endpoint, so only a limited API is available.` +\n `See ToolGuardExecutionContext for the supported API.`,\n );\n };\n\n return {\n switchToHttp: () => ({\n getRequest: <T = unknown>() => httpRequest.raw as T,\n getResponse: () => unavailable('switchToHttp().getResponse()'),\n getNext: () => unavailable('switchToHttp().getNext()'),\n }),\n getClass: <T = unknown>() => providerClass as Type<T>,\n getHandler: () => methodHandler as () => void,\n getArgs: () => unavailable('getArgs()'),\n getArgByIndex: () => unavailable('getArgByIndex()'),\n getType: <TContext extends string = string>() => 'http' as TContext,\n switchToRpc: () => unavailable('switchToRpc()'),\n switchToWs: () => unavailable('switchToWs()'),\n };\n }\n\n /**\n * Evaluates all @ToolGuards() for a tool.\n * Returns true if the tool has no guards or all guards pass.\n */\n private async checkToolGuards(\n tool: DiscoveredCapability<ToolMetadata>,\n httpRequest: HttpRequest,\n ): Promise<boolean> {\n const guards = tool.metadata.guards;\n if (!guards || guards.length === 0) {\n return true;\n }\n\n // Guards require HTTP context - not available on STDIO\n if (!httpRequest.raw) {\n this.logger.warn(\n `@ToolGuards() on tool '${tool.metadata.name}' cannot be evaluated without HTTP context (STDIO transport). ` +\n `The tool will be hidden. Use HTTP transport to support guarded tools.`,\n );\n return false;\n }\n\n const context = this.createToolGuardExecutionContext(httpRequest, tool);\n\n for (const GuardClass of guards) {\n try {\n const guard = this.moduleRef.get<CanActivate>(GuardClass, {\n strict: false,\n });\n const result = guard.canActivate(context);\n const canActivate = result instanceof Promise ? await result : result;\n if (!canActivate) {\n return false;\n }\n } catch (error) {\n this.logger.warn(\n `@ToolGuards() guard ${GuardClass.name} threw on tool '${tool.metadata.name}': ${error.message}. ` +\n `The tool will be hidden. If this is unexpected, ensure the guard only uses ` +\n `the API available in ToolGuardExecutionContext.`,\n );\n return false;\n }\n }\n\n return true;\n }\n registerHandlers(mcpServer: McpServer, httpRequest: HttpRequest) {\n if (this.registry.getTools(this.mcpModuleId).length === 0) {\n this.logger.debug('No tools registered, skipping tool handlers');\n return;\n }\n\n mcpServer.server.setRequestHandler(ListToolsRequestSchema, async () => {\n // Extract user from request (may be undefined if not authenticated or STDIO)\n // For STDIO transport, httpRequest.raw is undefined, so bypass auth entirely\n const user = httpRequest.raw\n ? (httpRequest.raw as McpRequestWithUser).user\n : undefined;\n\n // Get all tools and filter based on user permissions\n // STDIO: If no httpRequest.raw, disable guards (local dev mode)\n const allTools = this.registry.getTools(this.mcpModuleId);\n const effectiveModuleHasGuards = httpRequest.raw\n ? this.moduleHasGuards\n : false;\n const allowUnauthenticatedAccess =\n this.options.allowUnauthenticatedAccess ?? false;\n\n // Filter by JWT-based authorization (scopes, roles, public)\n const jwtAuthorizedTools = allTools.filter((tool) =>\n this.authService.canAccessTool(\n user,\n tool,\n effectiveModuleHasGuards,\n allowUnauthenticatedAccess,\n ),\n );\n\n // Filter by @ToolGuards() - evaluate each tool's guards\n const authorizedTools: typeof jwtAuthorizedTools = [];\n for (const tool of jwtAuthorizedTools) {\n if (await this.checkToolGuards(tool, httpRequest)) {\n authorizedTools.push(tool);\n }\n }\n\n const tools = authorizedTools.map((tool) => {\n // Create base schema\n const toolSchema = {\n name: tool.metadata.name,\n description: tool.metadata.description,\n annotations: tool.metadata.annotations,\n _meta: tool.metadata._meta,\n };\n\n // Add security schemes\n const securitySchemes = this.authService.generateSecuritySchemes(\n tool,\n effectiveModuleHasGuards,\n );\n if (securitySchemes.length > 0) {\n toolSchema['securitySchemes'] = securitySchemes;\n // Note: Currently securitySchemes are not supported in MCP sdk, adding to _meta as workaround\n // (see https://developers.openai.com/apps-sdk/reference/)\n toolSchema._meta = {\n ...toolSchema._meta,\n securitySchemes,\n };\n }\n\n // Add input schema if defined\n const normalizedInputParameters = normalizeObjectSchema(\n tool.metadata.parameters,\n );\n if (normalizedInputParameters) {\n toolSchema['inputSchema'] = toJsonSchemaCompat(\n normalizedInputParameters,\n );\n }\n\n // Add output schema if defined, ensuring it has type: 'object'\n const normalizedOutputSchema = normalizeObjectSchema(\n tool.metadata.outputSchema,\n );\n if (normalizedOutputSchema) {\n const outputSchema = toJsonSchemaCompat(normalizedOutputSchema);\n\n // Create a new object that explicitly includes type: 'object'\n const jsonSchema = {\n ...outputSchema,\n type: 'object',\n };\n\n toolSchema['outputSchema'] = jsonSchema;\n }\n\n return toolSchema;\n });\n\n return {\n tools,\n };\n });\n\n mcpServer.server.setRequestHandler(\n CallToolRequestSchema,\n async (request) => {\n this.logger.debug('CallToolRequestSchema is being called');\n\n const toolInfo = this.registry.findTool(\n this.mcpModuleId,\n request.params.name,\n );\n\n if (!toolInfo) {\n throw new McpError(\n ErrorCode.MethodNotFound,\n `Unknown tool: ${request.params.name}`,\n );\n }\n\n // Validate authorization before execution\n // For STDIO transport, bypass auth entirely (local dev mode)\n const user = httpRequest.raw\n ? (httpRequest.raw as McpRequestWithUser).user\n : undefined;\n const effectiveModuleHasGuards = httpRequest.raw\n ? this.moduleHasGuards\n : false;\n const allowUnauthenticatedAccess =\n this.options.allowUnauthenticatedAccess ?? false;\n this.authService.validateToolAccess(\n user,\n toolInfo,\n effectiveModuleHasGuards,\n allowUnauthenticatedAccess,\n );\n\n // Validate @ToolGuards()\n const guardsPassed = await this.checkToolGuards(toolInfo, httpRequest);\n if (!guardsPassed) {\n throw new McpError(\n ErrorCode.InvalidRequest,\n `Access denied: insufficient permissions for tool '${request.params.name}'`,\n );\n }\n\n try {\n // Validate input parameters against the tool's schema\n if (toolInfo.metadata.parameters) {\n const validation = toolInfo.metadata.parameters.safeParse(\n request.params.arguments || {},\n );\n if (!validation.success) {\n const issues = validation.error.issues\n .map((issue) => {\n const path =\n issue.path.length > 0 ? issue.path.join('.') : '';\n const location = path ? `[${path}]: ` : '';\n return `${location}${issue.message}`;\n })\n .join('; ');\n return {\n content: [\n {\n type: 'text',\n text: `Invalid parameters: ${issues}`,\n },\n ],\n isError: true,\n };\n }\n // Use validated arguments to ensure defaults and transformations are applied\n request.params.arguments = validation.data as Record<\n string,\n unknown\n >;\n }\n\n const contextId = ContextIdFactory.getByRequest(httpRequest);\n this.moduleRef.registerRequestByContextId(httpRequest, contextId);\n\n const context = this.createContext(mcpServer, request);\n let result: any;\n\n // Check if this is a dynamic tool (registered via McpRegistryService)\n if (toolInfo.providerClass === DYNAMIC_TOOL_HANDLER_TOKEN) {\n // Dynamic tool - get handler using static method with the correct moduleId\n const handler = McpRegistryService.getHandlerByModuleId(\n this.mcpModuleId,\n request.params.name,\n );\n\n if (!handler) {\n throw new McpError(\n ErrorCode.MethodNotFound,\n `Handler not found for dynamic tool: ${request.params.name}`,\n );\n }\n\n result = await handler(\n request.params.arguments || {},\n context,\n httpRequest.raw as McpRequestWithUser,\n );\n } else {\n // Decorator-based tool - resolve provider instance and call method\n const toolInstance = await this.moduleRef.resolve(\n toolInfo.providerClass,\n contextId,\n { strict: false },\n );\n\n if (!toolInstance) {\n throw new McpError(\n ErrorCode.MethodNotFound,\n `Unknown tool: ${request.params.name}`,\n );\n }\n\n result = await toolInstance[toolInfo.methodName].call(\n toolInstance,\n request.params.arguments,\n context,\n httpRequest.raw as McpRequestWithUser,\n );\n }\n\n const transformedResult = this.formatToolResult(\n result,\n toolInfo.metadata.outputSchema,\n );\n\n this.logger.debug('CallToolRequestSchema result', transformedResult);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return transformedResult;\n } catch (error) {\n // We are assuming error as at least a message property\n return this.handleError(error as Error, toolInfo, httpRequest);\n }\n },\n );\n }\n}\n"]}
1
+ {"version":3,"file":"mcp-tools.handler.js","sourceRoot":"","sources":["../../../../src/mcp/services/handlers/mcp-tools.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,iEAM4C;AAC5C,2CAOwB;AACxB,uCAAsE;AACtE,sFAG2C;AAE3C,yDAAoD;AAIpD,8EAAyE;AACzE,0GAAgG;AAChG,kFAAuF;AAEvF,kFAGyC;AAGlC,IAAM,eAAe,uBAArB,MAAM,eAAgB,SAAQ,iCAAc;IAGjD,YACE,SAAoB,EACpB,QAAqC,EACrC,SAAoB,EACsB,WAAmB,EACrB,OAAmB,EAC1C,WAAqC;QAEtD,KAAK,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,iBAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAJ3B,gBAAW,GAAX,WAAW,CAAQ;QACrB,YAAO,GAAP,OAAO,CAAY;QAC1C,gBAAW,GAAX,WAAW,CAA0B;QAGtD,IAAI,CAAC,eAAe;YAClB,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CA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ema,\n McpError,\n} from '@modelcontextprotocol/sdk/types.js';\nimport {\n CanActivate,\n ExecutionContext,\n Inject,\n Injectable,\n Scope,\n Type,\n} from '@nestjs/common';\nimport { ContextIdFactory, ModuleRef, Reflector } from '@nestjs/core';\nimport {\n DiscoveredCapability,\n McpRegistryDiscoveryService,\n} from '../mcp-registry-discovery.service';\nimport { ToolGuardExecutionContext, ToolMetadata } from '../../decorators';\nimport { McpHandlerBase } from './mcp-handler.base';\nimport { ZodType } from 'zod';\nimport { HttpRequest } from '../../interfaces/http-adapter.interface';\nimport { McpRequestWithUser } from 'src/authz';\nimport { ToolAuthorizationService } from '../tool-authorization.service';\nimport { toJsonSchemaCompat } from '@modelcontextprotocol/sdk/server/zod-json-schema-compat.js';\nimport { normalizeObjectSchema } from '@modelcontextprotocol/sdk/server/zod-compat.js';\nimport type { McpOptions } from '../../interfaces/mcp-options.interface';\nimport {\n McpRegistryService,\n DYNAMIC_TOOL_HANDLER_TOKEN,\n} from '../mcp-dynamic-registry.service';\n\n@Injectable({ scope: Scope.REQUEST })\nexport class McpToolsHandler extends McpHandlerBase {\n private readonly moduleHasGuards: boolean;\n\n constructor(\n moduleRef: ModuleRef,\n registry: McpRegistryDiscoveryService,\n reflector: Reflector,\n @Inject('MCP_MODULE_ID') private readonly mcpModuleId: string,\n @Inject('MCP_OPTIONS') private readonly options: McpOptions,\n private readonly authService: ToolAuthorizationService,\n ) {\n super(moduleRef, registry, reflector, McpToolsHandler.name, options);\n this.moduleHasGuards =\n this.options.guards !== undefined && this.options.guards.length > 0;\n }\n\n private buildDefaultContentBlock(result: any) {\n return [\n {\n type: 'text',\n text: JSON.stringify(result),\n },\n ];\n }\n\n private formatToolResult(result: any, outputSchema?: ZodType): any {\n if (result && typeof result === 'object' && Array.isArray(result.content)) {\n return result;\n }\n\n if (outputSchema) {\n const validation = outputSchema.safeParse(result);\n if (!validation.success) {\n throw new McpError(\n ErrorCode.InternalError,\n `Tool result does not match outputSchema: ${validation.error.message}`,\n );\n }\n return {\n structuredContent: validation.data,\n content: this.buildDefaultContentBlock(result),\n };\n }\n\n return {\n content: this.buildDefaultContentBlock(result),\n };\n }\n\n protected override createErrorResponse(\n errorText: string,\n ): CallToolResult | never {\n return {\n content: [{ type: 'text', text: errorText }],\n isError: true,\n };\n }\n\n /**\n * Creates an ExecutionContext for @ToolGuards() evaluation.\n *\n * Only the fields documented in ToolGuardExecutionContext are available.\n * Invalid fields throw with a descriptive message rather than silently\n * returning garbage.\n */\n private createToolGuardExecutionContext(\n httpRequest: HttpRequest,\n tool: DiscoveredCapability<ToolMetadata>,\n ): ToolGuardExecutionContext & ExecutionContext {\n const providerClass = tool.providerClass as Type;\n const methodHandler =\n providerClass.prototype?.[tool.methodName] ?? (() => {});\n\n const unavailable = (method: string): never => {\n throw new Error(\n `${method} is not available in @ToolGuards() context. ` +\n `MCP tools share a single HTTP endpoint, so only a limited API is available.` +\n `See ToolGuardExecutionContext for the supported API.`,\n );\n };\n\n return {\n switchToHttp: () => ({\n getRequest: <T = unknown>() => httpRequest.raw as T,\n getResponse: () => unavailable('switchToHttp().getResponse()'),\n getNext: () => unavailable('switchToHttp().getNext()'),\n }),\n getClass: <T = unknown>() => providerClass as Type<T>,\n getHandler: () => methodHandler as () => void,\n getArgs: () => unavailable('getArgs()'),\n getArgByIndex: () => unavailable('getArgByIndex()'),\n getType: <TContext extends string = string>() => 'http' as TContext,\n switchToRpc: () => unavailable('switchToRpc()'),\n switchToWs: () => unavailable('switchToWs()'),\n };\n }\n\n /**\n * Evaluates all @ToolGuards() for a tool.\n * Returns true if the tool has no guards or all guards pass.\n */\n private async checkToolGuards(\n tool: DiscoveredCapability<ToolMetadata>,\n httpRequest: HttpRequest,\n ): Promise<boolean> {\n const guards = tool.metadata.guards;\n if (!guards || guards.length === 0) {\n return true;\n }\n\n // Guards require HTTP context - not available on STDIO\n if (!httpRequest.raw) {\n this.logger.warn(\n `@ToolGuards() on tool '${tool.metadata.name}' cannot be evaluated without HTTP context (STDIO transport). ` +\n `The tool will be hidden. Use HTTP transport to support guarded tools.`,\n );\n return false;\n }\n\n const context = this.createToolGuardExecutionContext(httpRequest, tool);\n\n for (const GuardClass of guards) {\n try {\n const guard = this.moduleRef.get<CanActivate>(GuardClass, {\n strict: false,\n });\n const result = guard.canActivate(context);\n const canActivate = result instanceof Promise ? await result : result;\n if (!canActivate) {\n return false;\n }\n } catch (error) {\n this.logger.warn(\n `@ToolGuards() guard ${GuardClass.name} threw on tool '${tool.metadata.name}': ${error.message}. ` +\n `The tool will be hidden. If this is unexpected, ensure the guard only uses ` +\n `the API available in ToolGuardExecutionContext.`,\n );\n return false;\n }\n }\n\n return true;\n }\n registerHandlers(mcpServer: McpServer, httpRequest: HttpRequest) {\n if (this.registry.getTools(this.mcpModuleId).length === 0) {\n this.logger.debug('No tools registered, skipping tool handlers');\n return;\n }\n\n mcpServer.server.setRequestHandler(ListToolsRequestSchema, async () => {\n // Extract user from request (may be undefined if not authenticated or STDIO)\n // For STDIO transport, httpRequest.raw is undefined, so bypass auth entirely\n const user = httpRequest.raw\n ? (httpRequest.raw as McpRequestWithUser).user\n : undefined;\n\n // Get all tools and filter based on user permissions\n // STDIO: If no httpRequest.raw, disable guards (local dev mode)\n const allTools = this.registry.getTools(this.mcpModuleId);\n const effectiveModuleHasGuards = httpRequest.raw\n ? this.moduleHasGuards\n : false;\n const allowUnauthenticatedAccess =\n this.options.allowUnauthenticatedAccess ?? false;\n\n // Filter by JWT-based authorization (scopes, roles, public)\n const jwtAuthorizedTools = allTools.filter((tool) =>\n this.authService.canAccessTool(\n user,\n tool,\n effectiveModuleHasGuards,\n allowUnauthenticatedAccess,\n ),\n );\n\n // Filter by @ToolGuards() - evaluate each tool's guards\n const authorizedTools: typeof jwtAuthorizedTools = [];\n for (const tool of jwtAuthorizedTools) {\n if (await this.checkToolGuards(tool, httpRequest)) {\n authorizedTools.push(tool);\n }\n }\n\n const tools = authorizedTools.map((tool) => {\n // Create base schema\n const toolSchema = {\n name: tool.metadata.name,\n description: tool.metadata.description,\n annotations: tool.metadata.annotations,\n _meta: tool.metadata._meta,\n };\n\n // Add security schemes\n const securitySchemes = this.authService.generateSecuritySchemes(\n tool,\n effectiveModuleHasGuards,\n );\n if (securitySchemes.length > 0) {\n toolSchema['securitySchemes'] = securitySchemes;\n // Note: Currently securitySchemes are not supported in MCP sdk, adding to _meta as workaround\n // (see https://developers.openai.com/apps-sdk/reference/)\n toolSchema._meta = {\n ...toolSchema._meta,\n securitySchemes,\n };\n }\n\n // Add input schema if defined\n const normalizedInputParameters = normalizeObjectSchema(\n tool.metadata.parameters,\n );\n if (normalizedInputParameters) {\n toolSchema['inputSchema'] = toJsonSchemaCompat(\n normalizedInputParameters,\n );\n }\n\n // Add output schema if defined, ensuring it has type: 'object'\n const normalizedOutputSchema = normalizeObjectSchema(\n tool.metadata.outputSchema,\n );\n if (normalizedOutputSchema) {\n const outputSchema = toJsonSchemaCompat(normalizedOutputSchema);\n\n // Create a new object that explicitly includes type: 'object'\n const jsonSchema = {\n ...outputSchema,\n type: 'object',\n };\n\n toolSchema['outputSchema'] = jsonSchema;\n }\n\n return toolSchema;\n });\n\n return {\n tools,\n };\n });\n\n mcpServer.server.setRequestHandler(\n CallToolRequestSchema,\n async (request) => {\n this.logger.debug('CallToolRequestSchema is being called');\n\n const toolInfo = this.registry.findTool(\n this.mcpModuleId,\n request.params.name,\n );\n\n if (!toolInfo) {\n throw new McpError(\n ErrorCode.MethodNotFound,\n `Unknown tool: ${request.params.name}`,\n );\n }\n\n // Validate authorization before execution\n // For STDIO transport, bypass auth entirely (local dev mode)\n const user = httpRequest.raw\n ? (httpRequest.raw as McpRequestWithUser).user\n : undefined;\n const effectiveModuleHasGuards = httpRequest.raw\n ? this.moduleHasGuards\n : false;\n const allowUnauthenticatedAccess =\n this.options.allowUnauthenticatedAccess ?? false;\n this.authService.validateToolAccess(\n user,\n toolInfo,\n effectiveModuleHasGuards,\n allowUnauthenticatedAccess,\n );\n\n // Validate @ToolGuards()\n const guardsPassed = await this.checkToolGuards(toolInfo, httpRequest);\n if (!guardsPassed) {\n throw new McpError(\n ErrorCode.InvalidRequest,\n `Access denied: insufficient permissions for tool '${request.params.name}'`,\n );\n }\n\n try {\n // Validate input parameters against the tool's schema\n if (toolInfo.metadata.parameters) {\n const validation = toolInfo.metadata.parameters.safeParse(\n request.params.arguments || {},\n );\n if (!validation.success) {\n const issues = validation.error.issues\n .map((issue) => {\n const path =\n issue.path.length > 0 ? issue.path.join('.') : '';\n const location = path ? `[${path}]: ` : '';\n return `${location}${issue.message}`;\n })\n .join('; ');\n return {\n content: [\n {\n type: 'text',\n text: `Invalid parameters: ${issues}`,\n },\n ],\n isError: true,\n };\n }\n // Use validated arguments to ensure defaults and transformations are applied\n request.params.arguments = validation.data as Record<\n string,\n unknown\n >;\n }\n\n const contextId = ContextIdFactory.getByRequest(httpRequest);\n this.moduleRef.registerRequestByContextId(httpRequest, contextId);\n\n const context = this.createContext(mcpServer, request);\n let result: any;\n\n // Check if this is a dynamic tool (registered via McpRegistryService)\n if (toolInfo.providerClass === DYNAMIC_TOOL_HANDLER_TOKEN) {\n // Dynamic tool - get handler using static method with the correct moduleId\n const handler = McpRegistryService.getHandlerByModuleId(\n this.mcpModuleId,\n request.params.name,\n );\n\n if (!handler) {\n throw new McpError(\n ErrorCode.MethodNotFound,\n `Handler not found for dynamic tool: ${request.params.name}`,\n );\n }\n\n result = await handler(\n request.params.arguments || {},\n context,\n httpRequest.raw as McpRequestWithUser,\n );\n } else {\n // Decorator-based tool - resolve provider instance and call method\n const toolInstance = await this.moduleRef.resolve(\n toolInfo.providerClass,\n contextId,\n { strict: false },\n );\n\n if (!toolInstance) {\n throw new McpError(\n ErrorCode.MethodNotFound,\n `Unknown tool: ${request.params.name}`,\n );\n }\n\n result = await toolInstance[toolInfo.methodName].call(\n toolInstance,\n request.params.arguments,\n context,\n httpRequest.raw as McpRequestWithUser,\n );\n }\n\n const transformedResult = this.formatToolResult(\n result,\n toolInfo.metadata.outputSchema,\n );\n\n this.logger.debug('CallToolRequestSchema result', transformedResult);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return transformedResult;\n } catch (error) {\n // We are assuming error as at least a message property\n return this.handleError(error as Error, toolInfo, httpRequest);\n }\n },\n );\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rekog/mcp-nest",
3
- "version": "1.9.7-alpha.0",
3
+ "version": "1.9.7",
4
4
  "description": "NestJS module for creating Model Context Protocol (MCP) servers",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -95,9 +95,8 @@
95
95
  },
96
96
  "overrides": {
97
97
  "qs": "^6.14.1",
98
- "body-parser":"^2.2.1",
99
- "jws":"^3.2.3",
98
+ "body-parser": "^2.2.1",
99
+ "jws": "^3.2.3",
100
100
  "hono": "^4.11.4"
101
-
102
101
  }
103
102
  }
@@ -0,0 +1,41 @@
1
+ import { McpError } from '@modelcontextprotocol/sdk/types.js';
2
+ import { z } from 'zod';
3
+ import { McpToolsHandler } from './mcp-tools.handler';
4
+
5
+ const formatToolResult = McpToolsHandler.prototype['formatToolResult'].bind({
6
+ buildDefaultContentBlock: McpToolsHandler.prototype['buildDefaultContentBlock'],
7
+ });
8
+
9
+ const schema = z.object({ name: z.string(), age: z.number() });
10
+
11
+ describe('formatToolResult', () => {
12
+ it('strips extra keys from structuredContent when outputSchema is set', () => {
13
+ const result = formatToolResult({ name: 'Alice', age: 30, extra: true }, schema);
14
+
15
+ expect(result.structuredContent).toEqual({ name: 'Alice', age: 30 });
16
+ expect(result.structuredContent).not.toHaveProperty('extra');
17
+ });
18
+
19
+ it('keeps the original result (with extra keys) in the content text block', () => {
20
+ const result = formatToolResult({ name: 'Alice', age: 30, extra: true }, schema);
21
+ const text = JSON.parse(result.content[0].text);
22
+
23
+ expect(text).toHaveProperty('extra', true);
24
+ });
25
+
26
+ it('throws McpError when result does not match outputSchema', () => {
27
+ expect(() => formatToolResult({ name: 'Alice' }, schema)).toThrow(McpError);
28
+ });
29
+
30
+ it('wraps result in content block when no outputSchema is provided', () => {
31
+ const result = formatToolResult({ anything: 42 });
32
+
33
+ expect(result.structuredContent).toBeUndefined();
34
+ expect(result.content[0].text).toBe('{"anything":42}');
35
+ });
36
+
37
+ it('returns as-is when result already has a content array', () => {
38
+ const existing = { content: [{ type: 'text', text: 'hi' }] };
39
+ expect(formatToolResult(existing, schema)).toBe(existing);
40
+ });
41
+ });
@@ -73,7 +73,7 @@ export class McpToolsHandler extends McpHandlerBase {
73
73
  );
74
74
  }
75
75
  return {
76
- structuredContent: result,
76
+ structuredContent: validation.data,
77
77
  content: this.buildDefaultContentBlock(result),
78
78
  };
79
79
  }
@@ -1,38 +0,0 @@
1
- import { Logger } from '@nestjs/common';
2
- import type { Response } from 'express';
3
- import type { ElicitationEndpointConfiguration, ResolvedElicitationOptions } from './interfaces/elicitation-options.interface';
4
- import { ElicitationService } from './services/elicitation.service';
5
- interface ApiKeyFormBody {
6
- elicitationId: string;
7
- apiKey: string;
8
- }
9
- interface ConfirmationFormBody {
10
- elicitationId: string;
11
- action: 'confirm' | 'cancel';
12
- }
13
- export declare function createElicitationController(endpoints?: ElicitationEndpointConfiguration, elicitationModuleId?: string): {
14
- new (options: ResolvedElicitationOptions, elicitationService: ElicitationService): {
15
- readonly logger: Logger;
16
- readonly options: ResolvedElicitationOptions;
17
- readonly elicitationService: ElicitationService;
18
- getStatus(elicitationId: string): Promise<{
19
- elicitationId: string;
20
- status: "pending" | "complete" | "expired";
21
- createdAt: Date;
22
- expiresAt: Date;
23
- completed: boolean;
24
- result: {
25
- success: boolean;
26
- action: "cancel" | "confirm";
27
- completedAt: Date;
28
- } | undefined;
29
- }>;
30
- renderApiKeyForm(elicitationId: string, res: Response): Promise<void>;
31
- submitApiKeyForm(elicitationId: string, body: ApiKeyFormBody, res: Response): Promise<void>;
32
- renderConfirmationForm(elicitationId: string, res: Response): Promise<void>;
33
- submitConfirmationForm(elicitationId: string, body: ConfirmationFormBody, res: Response): Promise<void>;
34
- renderError(res: Response, message: string): void;
35
- };
36
- };
37
- export {};
38
- //# sourceMappingURL=elicitation.controller.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"elicitation.controller.d.ts","sourceRoot":"","sources":["../../src/elicitation/elicitation.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,MAAM,EAKP,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,gCAAgC,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AAC/H,OAAO,EAAE,kBAAkB,EAA8B,MAAM,gCAAgC,CAAC;AAYhG,UAAU,cAAc;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAKD,UAAU,oBAAoB;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;CAC9B;AAKD,wBAAgB,2BAA2B,CACzC,SAAS,GAAE,gCAAqC,EAChD,mBAAmB,CAAC,EAAE,MAAM;kBAgBN,0BAA0B,sBAMf,kBAAkB;;0BAN7B,0BAA0B;qCAMf,kBAAkB;iCAOL,MAAM;;;;;;;;;;;;wCA4BpB,MAAM,OACtB,QAAQ;wCAiCQ,MAAM,QACpB,cAAc,OAChB,QAAQ;8CA0CQ,MAAM,OACtB,QAAQ;8CAkCQ,MAAM,QACpB,oBAAoB,OACtB,QAAQ;yBAkDL,QAAQ,WAAW,MAAM,GAAG,IAAI;;EAapD"}
@@ -1,222 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.createElicitationController = createElicitationController;
16
- const common_1 = require("@nestjs/common");
17
- const elicitation_service_1 = require("./services/elicitation.service");
18
- const templates_1 = require("./templates");
19
- function createElicitationController(endpoints = {}, elicitationModuleId) {
20
- var ElicitationController_1;
21
- const apiPrefix = endpoints.apiKey?.replace(/^\//, '') ?? 'api-key';
22
- const confirmPrefix = endpoints.confirm?.replace(/^\//, '') ?? 'confirm';
23
- const statusPrefix = endpoints.status?.replace(/^\//, '') ?? 'status';
24
- let ElicitationController = ElicitationController_1 = class ElicitationController {
25
- constructor(options, elicitationService) {
26
- this.options = options;
27
- this.elicitationService = elicitationService;
28
- this.logger = new common_1.Logger(ElicitationController_1.name);
29
- }
30
- async getStatus(elicitationId) {
31
- const elicitation = await this.elicitationService.getElicitation(elicitationId);
32
- if (!elicitation) {
33
- throw new common_1.NotFoundException('Elicitation not found or expired');
34
- }
35
- const result = await this.elicitationService.getResult(elicitationId);
36
- return {
37
- elicitationId,
38
- status: elicitation.status,
39
- createdAt: elicitation.createdAt,
40
- expiresAt: elicitation.expiresAt,
41
- completed: result !== undefined,
42
- result: result ? {
43
- success: result.success,
44
- action: result.action,
45
- completedAt: result.completedAt,
46
- } : undefined,
47
- };
48
- }
49
- async renderApiKeyForm(elicitationId, res) {
50
- const elicitation = await this.elicitationService.getElicitation(elicitationId);
51
- if (!elicitation) {
52
- return this.renderError(res, 'Elicitation not found or expired');
53
- }
54
- if (elicitation.status === 'complete') {
55
- return this.renderError(res, 'This elicitation has already been completed');
56
- }
57
- const metadata = elicitation.metadata ?? {};
58
- const html = (0, templates_1.apiKeyFormTemplate)({
59
- elicitationId,
60
- message: metadata.message ?? 'Please enter your API key to continue.',
61
- fieldLabel: metadata.fieldLabel ?? 'API Key',
62
- placeholder: metadata.placeholder ?? 'Enter your API key',
63
- description: metadata.description,
64
- actionUrl: this.elicitationService.buildElicitationUrl(elicitationId, apiPrefix),
65
- options: this.options.templateOptions,
66
- });
67
- res.setHeader('Content-Type', 'text/html');
68
- res.send(html);
69
- }
70
- async submitApiKeyForm(elicitationId, body, res) {
71
- const elicitation = await this.elicitationService.getElicitation(elicitationId);
72
- if (!elicitation) {
73
- return this.renderError(res, 'Elicitation not found or expired');
74
- }
75
- if (elicitation.status === 'complete') {
76
- return this.renderError(res, 'This elicitation has already been completed');
77
- }
78
- const apiKey = body.apiKey;
79
- if (!apiKey || typeof apiKey !== 'string' || apiKey.trim().length === 0) {
80
- return this.renderError(res, 'API key is required');
81
- }
82
- this.logger.log(`API key submitted for elicitation ${elicitationId}`);
83
- await this.elicitationService.completeElicitation({
84
- elicitationId,
85
- success: true,
86
- action: 'confirm',
87
- data: { apiKey: apiKey.trim() },
88
- });
89
- const html = (0, templates_1.successPageTemplate)({
90
- title: 'API Key Received',
91
- message: 'Your API key has been securely received.',
92
- options: this.options.templateOptions,
93
- });
94
- res.setHeader('Content-Type', 'text/html');
95
- res.send(html);
96
- }
97
- async renderConfirmationForm(elicitationId, res) {
98
- const elicitation = await this.elicitationService.getElicitation(elicitationId);
99
- if (!elicitation) {
100
- return this.renderError(res, 'Elicitation not found or expired');
101
- }
102
- if (elicitation.status === 'complete') {
103
- return this.renderError(res, 'This elicitation has already been completed');
104
- }
105
- const metadata = elicitation.metadata ?? {};
106
- const html = (0, templates_1.confirmationFormTemplate)({
107
- elicitationId,
108
- title: metadata.title ?? 'Confirm Action',
109
- message: metadata.message ?? 'Please confirm you want to proceed.',
110
- warning: metadata.warning,
111
- confirmLabel: metadata.confirmLabel ?? 'Confirm',
112
- cancelLabel: metadata.cancelLabel ?? 'Cancel',
113
- actionUrl: this.elicitationService.buildElicitationUrl(elicitationId, confirmPrefix),
114
- options: this.options.templateOptions,
115
- });
116
- res.setHeader('Content-Type', 'text/html');
117
- res.send(html);
118
- }
119
- async submitConfirmationForm(elicitationId, body, res) {
120
- const elicitation = await this.elicitationService.getElicitation(elicitationId);
121
- if (!elicitation) {
122
- return this.renderError(res, 'Elicitation not found or expired');
123
- }
124
- if (elicitation.status === 'complete') {
125
- return this.renderError(res, 'This elicitation has already been completed');
126
- }
127
- const action = body.action;
128
- if (action !== 'confirm' && action !== 'cancel') {
129
- return this.renderError(res, 'Invalid action');
130
- }
131
- const isConfirmed = action === 'confirm';
132
- this.logger.log(`Confirmation ${action} for elicitation ${elicitationId}`);
133
- await this.elicitationService.completeElicitation({
134
- elicitationId,
135
- success: isConfirmed,
136
- action,
137
- data: {},
138
- });
139
- let html;
140
- if (isConfirmed) {
141
- html = (0, templates_1.successPageTemplate)({
142
- title: 'Confirmed',
143
- message: 'Your action has been confirmed.',
144
- options: this.options.templateOptions,
145
- });
146
- }
147
- else {
148
- html = (0, templates_1.cancelledPageTemplate)({
149
- title: 'Cancelled',
150
- message: 'The action has been cancelled.',
151
- options: this.options.templateOptions,
152
- });
153
- }
154
- res.setHeader('Content-Type', 'text/html');
155
- res.send(html);
156
- }
157
- renderError(res, message) {
158
- const html = (0, templates_1.errorPageTemplate)({
159
- title: 'Error',
160
- message,
161
- options: this.options.templateOptions,
162
- });
163
- res.setHeader('Content-Type', 'text/html');
164
- res.status(400).send(html);
165
- }
166
- };
167
- __decorate([
168
- (0, common_1.Get)(`:id/${statusPrefix}`),
169
- __param(0, (0, common_1.Param)('id')),
170
- __metadata("design:type", Function),
171
- __metadata("design:paramtypes", [String]),
172
- __metadata("design:returntype", Promise)
173
- ], ElicitationController.prototype, "getStatus", null);
174
- __decorate([
175
- (0, common_1.Get)(`:id/${apiPrefix}`),
176
- __param(0, (0, common_1.Param)('id')),
177
- __param(1, (0, common_1.Res)()),
178
- __metadata("design:type", Function),
179
- __metadata("design:paramtypes", [String, Object]),
180
- __metadata("design:returntype", Promise)
181
- ], ElicitationController.prototype, "renderApiKeyForm", null);
182
- __decorate([
183
- (0, common_1.Post)(`:id/${apiPrefix}`),
184
- (0, common_1.HttpCode)(200),
185
- __param(0, (0, common_1.Param)('id')),
186
- __param(1, (0, common_1.Body)()),
187
- __param(2, (0, common_1.Res)()),
188
- __metadata("design:type", Function),
189
- __metadata("design:paramtypes", [String, Object, Object]),
190
- __metadata("design:returntype", Promise)
191
- ], ElicitationController.prototype, "submitApiKeyForm", null);
192
- __decorate([
193
- (0, common_1.Get)(`:id/${confirmPrefix}`),
194
- __param(0, (0, common_1.Param)('id')),
195
- __param(1, (0, common_1.Res)()),
196
- __metadata("design:type", Function),
197
- __metadata("design:paramtypes", [String, Object]),
198
- __metadata("design:returntype", Promise)
199
- ], ElicitationController.prototype, "renderConfirmationForm", null);
200
- __decorate([
201
- (0, common_1.Post)(`:id/${confirmPrefix}`),
202
- (0, common_1.HttpCode)(200),
203
- __param(0, (0, common_1.Param)('id')),
204
- __param(1, (0, common_1.Body)()),
205
- __param(2, (0, common_1.Res)()),
206
- __metadata("design:type", Function),
207
- __metadata("design:paramtypes", [String, Object, Object]),
208
- __metadata("design:returntype", Promise)
209
- ], ElicitationController.prototype, "submitConfirmationForm", null);
210
- ElicitationController = ElicitationController_1 = __decorate([
211
- (0, common_1.Controller)(),
212
- __param(0, (0, common_1.Inject)(elicitationModuleId
213
- ? `ELICITATION_MODULE_OPTIONS_${elicitationModuleId}`
214
- : elicitation_service_1.ELICITATION_MODULE_OPTIONS)),
215
- __param(1, (0, common_1.Inject)(elicitationModuleId
216
- ? `ElicitationService_${elicitationModuleId}`
217
- : elicitation_service_1.ElicitationService)),
218
- __metadata("design:paramtypes", [Object, elicitation_service_1.ElicitationService])
219
- ], ElicitationController);
220
- return ElicitationController;
221
- }
222
- //# sourceMappingURL=elicitation.controller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"elicitation.controller.js","sourceRoot":"","sources":["../../src/elicitation/elicitation.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AA2CA,kEA6OC;AAxRD,2CAYwB;AAGxB,wEAAgG;AAChG,2CAMqB;AAqBrB,SAAgB,2BAA2B,CACzC,YAA8C,EAAE,EAChD,mBAA4B;;IAE5B,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC;IACpE,MAAM,aAAa,GAAG,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC;IACzE,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAC;IAEtE,IACM,qBAAqB,6BAD3B,MACM,qBAAqB;QAGzB,YAME,OAA4C,EAM5C,kBAA+C;YANtC,YAAO,GAAP,OAAO,CAA4B;YAMnC,uBAAkB,GAAlB,kBAAkB,CAAoB;YAdxC,WAAM,GAAG,IAAI,eAAM,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;QAetD,CAAC;QAME,AAAN,KAAK,CAAC,SAAS,CAAc,aAAqB;YAChD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;YAEhF,IAAI,CAAC,WAAW,EAAE,CAAC;gBACjB,MAAM,IAAI,0BAAiB,CAAC,kCAAkC,CAAC,CAAC;YAClE,CAAC;YAED,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;YAEtE,OAAO;gBACL,aAAa;gBACb,MAAM,EAAE,WAAW,CAAC,MAAM;gBAC1B,SAAS,EAAE,WAAW,CAAC,SAAS;gBAChC,SAAS,EAAE,WAAW,CAAC,SA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NG,qBAAqB;QAD1B,IAAA,mBAAU,GAAE;QAKR,WAAA,IAAA,eAAM,EACL,mBAAmB;YACjB,CAAC,CAAC,8BAA8B,mBAAmB,EAAE;YACrD,CAAC,CAAC,gDAA0B,CAC/B,CAAA;QAEA,WAAA,IAAA,eAAM,EACL,mBAAmB;YACjB,CAAC,CAAC,sBAAsB,mBAAmB,EAAE;YAC7C,CAAC,CAAC,wCAAkB,CACvB,CAAA;iDAC4B,wCAAkB;OAf7C,qBAAqB,CAiO1B;IAED,OAAO,qBAAqB,CAAC;AAC/B,CAAC","sourcesContent":["import {\n BadRequestException,\n Body,\n Controller,\n Get,\n HttpCode,\n Inject,\n Logger,\n NotFoundException,\n Param,\n Post,\n Res,\n} from '@nestjs/common';\nimport type { Response } from 'express';\nimport type { ElicitationEndpointConfiguration, ResolvedElicitationOptions } from './interfaces/elicitation-options.interface';\nimport { ElicitationService, ELICITATION_MODULE_OPTIONS } from './services/elicitation.service';\nimport {\n apiKeyFormTemplate,\n confirmationFormTemplate,\n successPageTemplate,\n cancelledPageTemplate,\n errorPageTemplate,\n} from './templates';\n\n/**\n * Request body for API key form submission.\n */\ninterface ApiKeyFormBody {\n elicitationId: string;\n apiKey: string;\n}\n\n/**\n * Request body for confirmation form submission.\n */\ninterface ConfirmationFormBody {\n elicitationId: string;\n action: 'confirm' | 'cancel';\n}\n\n/**\n * Factory function to create the elicitation controller with configured endpoints.\n */\nexport function createElicitationController(\n endpoints: ElicitationEndpointConfiguration = {},\n elicitationModuleId?: string,\n) {\n const apiPrefix = endpoints.apiKey?.replace(/^\\//, '') ?? 'api-key';\n const confirmPrefix = endpoints.confirm?.replace(/^\\//, '') ?? 'confirm';\n const statusPrefix = endpoints.status?.replace(/^\\//, '') ?? 'status';\n\n @Controller()\n class ElicitationController {\n readonly logger = new Logger(ElicitationController.name);\n\n constructor(\n @Inject(\n elicitationModuleId\n ? `ELICITATION_MODULE_OPTIONS_${elicitationModuleId}`\n : ELICITATION_MODULE_OPTIONS,\n )\n readonly options: ResolvedElicitationOptions,\n @Inject(\n elicitationModuleId\n ? `ElicitationService_${elicitationModuleId}`\n : ElicitationService,\n )\n readonly elicitationService: ElicitationService,\n ) {}\n\n /**\n * GET /:id/status - Get elicitation status\n */\n @Get(`:id/${statusPrefix}`)\n async getStatus(@Param('id') elicitationId: string) {\n const elicitation = await this.elicitationService.getElicitation(elicitationId);\n\n if (!elicitation) {\n throw new NotFoundException('Elicitation not found or expired');\n }\n\n const result = await this.elicitationService.getResult(elicitationId);\n\n return {\n elicitationId,\n status: elicitation.status,\n createdAt: elicitation.createdAt,\n expiresAt: elicitation.expiresAt,\n completed: result !== undefined,\n result: result ? {\n success: result.success,\n action: result.action,\n completedAt: result.completedAt,\n } : undefined,\n };\n }\n\n /**\n * GET /:id/api-key - Render API key form\n */\n @Get(`:id/${apiPrefix}`)\n async renderApiKeyForm(\n @Param('id') elicitationId: string,\n @Res() res: Response,\n ) {\n const elicitation = await this.elicitationService.getElicitation(elicitationId);\n\n if (!elicitation) {\n return this.renderError(res, 'Elicitation not found or expired');\n }\n\n if (elicitation.status === 'complete') {\n return this.renderError(res, 'This elicitation has already been completed');\n }\n\n const metadata = elicitation.metadata ?? {};\n const html = apiKeyFormTemplate({\n elicitationId,\n message: (metadata.message as string) ?? 'Please enter your API key to continue.',\n fieldLabel: (metadata.fieldLabel as string) ?? 'API Key',\n placeholder: (metadata.placeholder as string) ?? 'Enter your API key',\n description: metadata.description as string | undefined,\n actionUrl: this.elicitationService.buildElicitationUrl(elicitationId, apiPrefix),\n options: this.options.templateOptions,\n });\n\n res.setHeader('Content-Type', 'text/html');\n res.send(html);\n }\n\n /**\n * POST /:id/api-key - Handle API key form submission\n */\n @Post(`:id/${apiPrefix}`)\n @HttpCode(200)\n async submitApiKeyForm(\n @Param('id') elicitationId: string,\n @Body() body: ApiKeyFormBody,\n @Res() res: Response,\n ) {\n const elicitation = await this.elicitationService.getElicitation(elicitationId);\n\n if (!elicitation) {\n return this.renderError(res, 'Elicitation not found or expired');\n }\n\n if (elicitation.status === 'complete') {\n return this.renderError(res, 'This elicitation has already been completed');\n }\n\n const apiKey = body.apiKey;\n if (!apiKey || typeof apiKey !== 'string' || apiKey.trim().length === 0) {\n return this.renderError(res, 'API key is required');\n }\n\n this.logger.log(`API key submitted for elicitation ${elicitationId}`);\n\n // Complete the elicitation\n await this.elicitationService.completeElicitation({\n elicitationId,\n success: true,\n action: 'confirm',\n data: { apiKey: apiKey.trim() },\n });\n\n const html = successPageTemplate({\n title: 'API Key Received',\n message: 'Your API key has been securely received.',\n options: this.options.templateOptions,\n });\n\n res.setHeader('Content-Type', 'text/html');\n res.send(html);\n }\n\n /**\n * GET /:id/confirm - Render confirmation page\n */\n @Get(`:id/${confirmPrefix}`)\n async renderConfirmationForm(\n @Param('id') elicitationId: string,\n @Res() res: Response,\n ) {\n const elicitation = await this.elicitationService.getElicitation(elicitationId);\n\n if (!elicitation) {\n return this.renderError(res, 'Elicitation not found or expired');\n }\n\n if (elicitation.status === 'complete') {\n return this.renderError(res, 'This elicitation has already been completed');\n }\n\n const metadata = elicitation.metadata ?? {};\n const html = confirmationFormTemplate({\n elicitationId,\n title: (metadata.title as string) ?? 'Confirm Action',\n message: (metadata.message as string) ?? 'Please confirm you want to proceed.',\n warning: metadata.warning as string | undefined,\n confirmLabel: (metadata.confirmLabel as string) ?? 'Confirm',\n cancelLabel: (metadata.cancelLabel as string) ?? 'Cancel',\n actionUrl: this.elicitationService.buildElicitationUrl(elicitationId, confirmPrefix),\n options: this.options.templateOptions,\n });\n\n res.setHeader('Content-Type', 'text/html');\n res.send(html);\n }\n\n /**\n * POST /:id/confirm - Handle confirmation form submission\n */\n @Post(`:id/${confirmPrefix}`)\n @HttpCode(200)\n async submitConfirmationForm(\n @Param('id') elicitationId: string,\n @Body() body: ConfirmationFormBody,\n @Res() res: Response,\n ) {\n const elicitation = await this.elicitationService.getElicitation(elicitationId);\n\n if (!elicitation) {\n return this.renderError(res, 'Elicitation not found or expired');\n }\n\n if (elicitation.status === 'complete') {\n return this.renderError(res, 'This elicitation has already been completed');\n }\n\n const action = body.action;\n if (action !== 'confirm' && action !== 'cancel') {\n return this.renderError(res, 'Invalid action');\n }\n\n const isConfirmed = action === 'confirm';\n this.logger.log(`Confirmation ${action} for elicitation ${elicitationId}`);\n\n // Complete the elicitation\n await this.elicitationService.completeElicitation({\n elicitationId,\n success: isConfirmed,\n action,\n data: {},\n });\n\n let html: string;\n if (isConfirmed) {\n html = successPageTemplate({\n title: 'Confirmed',\n message: 'Your action has been confirmed.',\n options: this.options.templateOptions,\n });\n } else {\n html = cancelledPageTemplate({\n title: 'Cancelled',\n message: 'The action has been cancelled.',\n options: this.options.templateOptions,\n });\n }\n\n res.setHeader('Content-Type', 'text/html');\n res.send(html);\n }\n\n /**\n * Helper to render error pages.\n */\n renderError(res: Response, message: string): void {\n const html = errorPageTemplate({\n title: 'Error',\n message,\n options: this.options.templateOptions,\n });\n\n res.setHeader('Content-Type', 'text/html');\n res.status(400).send(html);\n }\n }\n\n return ElicitationController;\n}\n"]}
@@ -1,13 +0,0 @@
1
- export { McpElicitationModule } from './mcp-elicitation.module';
2
- export type { Elicitation, ElicitationResult, CreateElicitationParams, CompleteElicitationParams, } from './interfaces/elicitation.interface';
3
- export type { IElicitationStore } from './interfaces/elicitation-store.interface';
4
- export { ELICITATION_STORE_TOKEN } from './interfaces/elicitation-store.interface';
5
- export type { ElicitationModuleOptions, ElicitationEndpointConfiguration, ElicitationStoreConfiguration, ElicitationTemplateOptions, ResolvedElicitationOptions, } from './interfaces/elicitation-options.interface';
6
- export { DEFAULT_ELICITATION_OPTIONS } from './interfaces/elicitation-options.interface';
7
- export { ElicitationService, ELICITATION_MODULE_OPTIONS, COMPLETION_NOTIFIER_REGISTRY, } from './services/elicitation.service';
8
- export type { CompletionNotifier, CompletionNotifierRegistry } from './services/elicitation.service';
9
- export { MemoryElicitationStore } from './stores/memory-elicitation.store';
10
- export { createElicitationController } from './elicitation.controller';
11
- export { baseTemplate, escapeHtml, apiKeyFormTemplate, confirmationFormTemplate, successPageTemplate, cancelledPageTemplate, errorPageTemplate, } from './templates';
12
- export type { BaseTemplateParams, ApiKeyFormParams, ConfirmationFormParams, SuccessPageParams, CancelledPageParams, ErrorPageParams, } from './templates';
13
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/elicitation/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,oCAAoC,CAAC;AAE5C,YAAY,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAEnF,YAAY,EACV,wBAAwB,EACxB,gCAAgC,EAChC,6BAA6B,EAC7B,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAGzF,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,4BAA4B,GAC7B,MAAM,gCAAgC,CAAC;AACxC,YAAY,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAGrG,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAG3E,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAGvE,OAAO,EACL,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,GAChB,MAAM,aAAa,CAAC"}
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.errorPageTemplate = exports.cancelledPageTemplate = exports.successPageTemplate = exports.confirmationFormTemplate = exports.apiKeyFormTemplate = exports.escapeHtml = exports.baseTemplate = exports.createElicitationController = exports.MemoryElicitationStore = exports.COMPLETION_NOTIFIER_REGISTRY = exports.ELICITATION_MODULE_OPTIONS = exports.ElicitationService = exports.DEFAULT_ELICITATION_OPTIONS = exports.ELICITATION_STORE_TOKEN = exports.McpElicitationModule = void 0;
4
- var mcp_elicitation_module_1 = require("./mcp-elicitation.module");
5
- Object.defineProperty(exports, "McpElicitationModule", { enumerable: true, get: function () { return mcp_elicitation_module_1.McpElicitationModule; } });
6
- var elicitation_store_interface_1 = require("./interfaces/elicitation-store.interface");
7
- Object.defineProperty(exports, "ELICITATION_STORE_TOKEN", { enumerable: true, get: function () { return elicitation_store_interface_1.ELICITATION_STORE_TOKEN; } });
8
- var elicitation_options_interface_1 = require("./interfaces/elicitation-options.interface");
9
- Object.defineProperty(exports, "DEFAULT_ELICITATION_OPTIONS", { enumerable: true, get: function () { return elicitation_options_interface_1.DEFAULT_ELICITATION_OPTIONS; } });
10
- var elicitation_service_1 = require("./services/elicitation.service");
11
- Object.defineProperty(exports, "ElicitationService", { enumerable: true, get: function () { return elicitation_service_1.ElicitationService; } });
12
- Object.defineProperty(exports, "ELICITATION_MODULE_OPTIONS", { enumerable: true, get: function () { return elicitation_service_1.ELICITATION_MODULE_OPTIONS; } });
13
- Object.defineProperty(exports, "COMPLETION_NOTIFIER_REGISTRY", { enumerable: true, get: function () { return elicitation_service_1.COMPLETION_NOTIFIER_REGISTRY; } });
14
- var memory_elicitation_store_1 = require("./stores/memory-elicitation.store");
15
- Object.defineProperty(exports, "MemoryElicitationStore", { enumerable: true, get: function () { return memory_elicitation_store_1.MemoryElicitationStore; } });
16
- var elicitation_controller_1 = require("./elicitation.controller");
17
- Object.defineProperty(exports, "createElicitationController", { enumerable: true, get: function () { return elicitation_controller_1.createElicitationController; } });
18
- var templates_1 = require("./templates");
19
- Object.defineProperty(exports, "baseTemplate", { enumerable: true, get: function () { return templates_1.baseTemplate; } });
20
- Object.defineProperty(exports, "escapeHtml", { enumerable: true, get: function () { return templates_1.escapeHtml; } });
21
- Object.defineProperty(exports, "apiKeyFormTemplate", { enumerable: true, get: function () { return templates_1.apiKeyFormTemplate; } });
22
- Object.defineProperty(exports, "confirmationFormTemplate", { enumerable: true, get: function () { return templates_1.confirmationFormTemplate; } });
23
- Object.defineProperty(exports, "successPageTemplate", { enumerable: true, get: function () { return templates_1.successPageTemplate; } });
24
- Object.defineProperty(exports, "cancelledPageTemplate", { enumerable: true, get: function () { return templates_1.cancelledPageTemplate; } });
25
- Object.defineProperty(exports, "errorPageTemplate", { enumerable: true, get: function () { return templates_1.errorPageTemplate; } });
26
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/elicitation/index.ts"],"names":[],"mappings":";;;AACA,mEAAgE;AAAvD,8HAAA,oBAAoB,OAAA;AAW7B,wFAAmF;AAA1E,sIAAA,uBAAuB,OAAA;AAShC,4FAAyF;AAAhF,4IAAA,2BAA2B,OAAA;AAGpC,sEAIwC;AAHtC,yHAAA,kBAAkB,OAAA;AAClB,iIAAA,0BAA0B,OAAA;AAC1B,mIAAA,4BAA4B,OAAA;AAK9B,8EAA2E;AAAlE,kIAAA,sBAAsB,OAAA;AAG/B,mEAAuE;AAA9D,qIAAA,2BAA2B,OAAA;AAGpC,yCAQqB;AAPnB,yGAAA,YAAY,OAAA;AACZ,uGAAA,UAAU,OAAA;AACV,+GAAA,kBAAkB,OAAA;AAClB,qHAAA,wBAAwB,OAAA;AACxB,gHAAA,mBAAmB,OAAA;AACnB,kHAAA,qBAAqB,OAAA;AACrB,8GAAA,iBAAiB,OAAA","sourcesContent":["// Main module\nexport { McpElicitationModule } from './mcp-elicitation.module';\n\n// Interfaces\nexport type {\n Elicitation,\n ElicitationResult,\n CreateElicitationParams,\n CompleteElicitationParams,\n} from './interfaces/elicitation.interface';\n\nexport type { IElicitationStore } from './interfaces/elicitation-store.interface';\nexport { ELICITATION_STORE_TOKEN } from './interfaces/elicitation-store.interface';\n\nexport type {\n ElicitationModuleOptions,\n ElicitationEndpointConfiguration,\n ElicitationStoreConfiguration,\n ElicitationTemplateOptions,\n ResolvedElicitationOptions,\n} from './interfaces/elicitation-options.interface';\nexport { DEFAULT_ELICITATION_OPTIONS } from './interfaces/elicitation-options.interface';\n\n// Services\nexport {\n ElicitationService,\n ELICITATION_MODULE_OPTIONS,\n COMPLETION_NOTIFIER_REGISTRY,\n} from './services/elicitation.service';\nexport type { CompletionNotifier, CompletionNotifierRegistry } from './services/elicitation.service';\n\n// Stores\nexport { MemoryElicitationStore } from './stores/memory-elicitation.store';\n\n// Controller factory (for advanced usage)\nexport { createElicitationController } from './elicitation.controller';\n\n// Templates (for customization)\nexport {\n baseTemplate,\n escapeHtml,\n apiKeyFormTemplate,\n confirmationFormTemplate,\n successPageTemplate,\n cancelledPageTemplate,\n errorPageTemplate,\n} from './templates';\nexport type {\n BaseTemplateParams,\n ApiKeyFormParams,\n ConfirmationFormParams,\n SuccessPageParams,\n CancelledPageParams,\n ErrorPageParams,\n} from './templates';\n"]}
@@ -1,36 +0,0 @@
1
- import type { CanActivate, Type } from '@nestjs/common';
2
- import type { IElicitationStore } from './elicitation-store.interface';
3
- export interface ElicitationEndpointConfiguration {
4
- status?: string;
5
- complete?: string;
6
- apiKey?: string;
7
- confirm?: string;
8
- }
9
- export interface ElicitationTemplateOptions {
10
- customCss?: string;
11
- logoUrl?: string;
12
- appName?: string;
13
- primaryColor?: string;
14
- }
15
- export type ElicitationStoreConfiguration = {
16
- type: 'memory';
17
- } | {
18
- type: 'custom';
19
- store: IElicitationStore;
20
- };
21
- export interface ElicitationModuleOptions {
22
- serverUrl: string;
23
- apiPrefix?: string;
24
- elicitationTtlMs?: number;
25
- cleanupIntervalMs?: number;
26
- storeConfiguration?: ElicitationStoreConfiguration;
27
- endpoints?: ElicitationEndpointConfiguration;
28
- guards?: Type<CanActivate>[];
29
- templateOptions?: ElicitationTemplateOptions;
30
- }
31
- export interface ResolvedElicitationOptions extends Required<Omit<ElicitationModuleOptions, 'guards' | 'storeConfiguration'>> {
32
- guards?: Type<CanActivate>[];
33
- storeConfiguration: ElicitationStoreConfiguration;
34
- }
35
- export declare const DEFAULT_ELICITATION_OPTIONS: Omit<ResolvedElicitationOptions, 'serverUrl'>;
36
- //# sourceMappingURL=elicitation-options.interface.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"elicitation-options.interface.d.ts","sourceRoot":"","sources":["../../../src/elicitation/interfaces/elicitation-options.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAKvE,MAAM,WAAW,gCAAgC;IAE/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,MAAM,WAAW,0BAA0B;IAEzC,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAKD,MAAM,MAAM,6BAA6B,GACrC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAKjD,MAAM,WAAW,wBAAwB;IAKvC,SAAS,EAAE,MAAM,CAAC;IAOlB,SAAS,CAAC,EAAE,MAAM,CAAC;IAMnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAM1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAM3B,kBAAkB,CAAC,EAAE,6BAA6B,CAAC;IAKnD,SAAS,CAAC,EAAE,gCAAgC,CAAC;IAM7C,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;IAK7B,eAAe,CAAC,EAAE,0BAA0B,CAAC;CAC9C;AAKD,MAAM,WAAW,0BACf,SAAQ,QAAQ,CACd,IAAI,CAAC,wBAAwB,EAAE,QAAQ,GAAG,oBAAoB,CAAC,CAChE;IACD,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;IAC7B,kBAAkB,EAAE,6BAA6B,CAAC;CACnD;AAKD,eAAO,MAAM,2BAA2B,EAAE,IAAI,CAC5C,0BAA0B,EAC1B,WAAW,CAgBZ,CAAC"}
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_ELICITATION_OPTIONS = void 0;
4
- exports.DEFAULT_ELICITATION_OPTIONS = {
5
- apiPrefix: 'elicitation',
6
- elicitationTtlMs: 60 * 60 * 1000,
7
- cleanupIntervalMs: 10 * 60 * 1000,
8
- storeConfiguration: { type: 'memory' },
9
- endpoints: {
10
- status: '/status',
11
- complete: '/complete',
12
- apiKey: '/api-key',
13
- confirm: '/confirm',
14
- },
15
- templateOptions: {
16
- appName: 'MCP Server',
17
- primaryColor: '#007bff',
18
- },
19
- };
20
- //# sourceMappingURL=elicitation-options.interface.js.map