@rekog/mcp-nest 1.5.1 → 1.5.2-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.
Files changed (30) hide show
  1. package/.github/workflows/pipeline.yml +1 -1
  2. package/README.md +10 -5
  3. package/coverage/clover.xml +378 -368
  4. package/coverage/coverage-final.json +20 -20
  5. package/coverage/lcov-report/decorators/constants.ts.html +1 -1
  6. package/coverage/lcov-report/decorators/index.html +14 -14
  7. package/coverage/lcov-report/decorators/index.ts.html +1 -1
  8. package/coverage/lcov-report/decorators/prompt.decorator.ts.html +1 -1
  9. package/coverage/lcov-report/decorators/resource.decorator.ts.html +1 -1
  10. package/coverage/lcov-report/decorators/tool.decorator.ts.html +56 -8
  11. package/coverage/lcov-report/index.html +51 -51
  12. package/coverage/lcov-report/services/index.html +1 -1
  13. package/coverage/lcov-report/services/mcp-registry.service.ts.html +1 -1
  14. package/coverage/lcov-report/tests/index.html +21 -21
  15. package/coverage/lcov-report/tests/utils.ts.html +45 -45
  16. package/coverage/lcov.info +540 -529
  17. package/dist/decorators/tool.decorator.d.ts +12 -1
  18. package/dist/decorators/tool.decorator.d.ts.map +1 -1
  19. package/dist/decorators/tool.decorator.js +3 -0
  20. package/dist/decorators/tool.decorator.js.map +1 -1
  21. package/dist/services/handlers/mcp-tools.handler.d.ts.map +1 -1
  22. package/dist/services/handlers/mcp-tools.handler.js +19 -7
  23. package/dist/services/handlers/mcp-tools.handler.js.map +1 -1
  24. package/dist/transport/streamable-http.controller.factory.js +1 -1
  25. package/dist/transport/streamable-http.controller.factory.js.map +1 -1
  26. package/package.json +4 -3
  27. package/playground/resources/greeting.tool.ts +12 -3
  28. package/tests/mcp-tool.e2e.spec.ts +88 -0
  29. package/tests/sample/stdio-server.ts +50 -0
  30. package/tsconfig.build.tsbuildinfo +1 -1
@@ -1,4 +1,4 @@
1
- name: Testing
1
+ name: Tests
2
2
 
3
3
  on:
4
4
  push:
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  A NestJS module to effortlessly expose tools, resources, and prompts for AI, from your NestJS applications using the **Model Context Protocol (MCP)**.
15
15
 
16
- with `@rekog/mcp-nest` you define tools, resources, and prompts in a way that's familiar in NestJS and leverage the full power of dependency injection to utilize your existing codebase in building complex enterprise ready MCP servers.
16
+ With `@rekog/mcp-nest` you define tools, resources, and prompts in a way that's familiar in NestJS and leverage the full power of dependency injection to utilize your existing codebase in building complex enterprise ready MCP servers.
17
17
 
18
18
  ## Features
19
19
 
@@ -25,6 +25,7 @@ with `@rekog/mcp-nest` you define tools, resources, and prompts in a way that's
25
25
  - 💯 Zod-based tool call validation
26
26
  - 📊 Progress notifications
27
27
  - 🔒 Guard-based authentication
28
+ - 🌐 Access to HTTP Request information within MCP Resources (Tools, Resources, Prompts)
28
29
 
29
30
  ## Installation
30
31
 
@@ -58,6 +59,7 @@ export class AppModule {}
58
59
 
59
60
  ```typescript
60
61
  // greeting.tool.ts
62
+ import type { Request } from 'express';
61
63
  import { Injectable } from '@nestjs/common';
62
64
  import { Tool, Resource, Context } from '@rekog/mcp-nest';
63
65
  import { z } from 'zod';
@@ -75,12 +77,12 @@ export class GreetingTool {
75
77
  name: z.string().default('World'),
76
78
  }),
77
79
  })
78
- async sayHello({ name }, context: Context) {
79
- const greeting = `Hello, ${name}!`;
80
-
80
+ async sayHello({ name }, context: Context, request: Request) {
81
+ const userAgent = request.get('user-agent') || 'Unknown';
82
+ const greeting = `Hello, ${name}! Your user agent is: ${userAgent}`;
81
83
  const totalSteps = 5;
82
84
  for (let i = 0; i < totalSteps; i++) {
83
- await new Promise((resolve) => setTimeout(resolve, 500));
85
+ await new Promise((resolve) => setTimeout(resolve, 100));
84
86
 
85
87
  // Send a progress update.
86
88
  await context.reportProgress({
@@ -117,6 +119,9 @@ export class GreetingTool {
117
119
 
118
120
  You are done!
119
121
 
122
+ > [!TIP]
123
+ > The above example shows how HTTP `Request` headers are accessed within MCP Tools. This is useful for identifying users, adding client-specific logic, and many other use cases. For more examples, see the [Authentication Tests](./tests/mcp-tool-auth.spec.ts).
124
+
120
125
  ## Quick Start for STDIO
121
126
 
122
127
  The main difference is that you need to provide the `transport` option when importing the module.