@jrmc/adonis-mcp 1.0.0-alpha.13 → 1.0.0-alpha.14

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 (90) hide show
  1. package/README.md +223 -21
  2. package/build/commands/commands.json +1 -1
  3. package/build/commands/inspector.d.ts +16 -0
  4. package/build/commands/inspector.d.ts.map +1 -0
  5. package/build/commands/inspector.js +54 -0
  6. package/build/src/server/contents/audio.d.ts +1 -1
  7. package/build/src/server/contents/audio.d.ts.map +1 -1
  8. package/build/src/server/contents/blob.d.ts +1 -1
  9. package/build/src/server/contents/blob.d.ts.map +1 -1
  10. package/build/src/server/contents/embedded_resource.d.ts +1 -1
  11. package/build/src/server/contents/embedded_resource.d.ts.map +1 -1
  12. package/build/src/server/contents/error.d.ts +1 -1
  13. package/build/src/server/contents/error.d.ts.map +1 -1
  14. package/build/src/server/contents/image.d.ts +1 -1
  15. package/build/src/server/contents/image.d.ts.map +1 -1
  16. package/build/src/server/contents/resource_link.d.ts +1 -1
  17. package/build/src/server/contents/resource_link.d.ts.map +1 -1
  18. package/build/src/server/contents/structured.d.ts +1 -1
  19. package/build/src/server/contents/structured.d.ts.map +1 -1
  20. package/build/src/server/contents/text.d.ts +1 -1
  21. package/build/src/server/contents/text.d.ts.map +1 -1
  22. package/build/src/server/context.d.ts +5 -1
  23. package/build/src/server/context.d.ts.map +1 -1
  24. package/build/src/server/context.js +26 -0
  25. package/build/src/server/{content.d.ts → contracts/content.d.ts} +4 -4
  26. package/build/src/server/contracts/content.d.ts.map +1 -0
  27. package/build/src/server/contracts/context.d.ts +29 -0
  28. package/build/src/server/contracts/context.d.ts.map +1 -0
  29. package/build/src/{types → server/contracts}/transport.d.ts +1 -1
  30. package/build/src/server/contracts/transport.d.ts.map +1 -0
  31. package/build/src/server/contracts/transport.js +7 -0
  32. package/build/src/server/methods/call_tool.d.ts +1 -1
  33. package/build/src/server/methods/call_tool.d.ts.map +1 -1
  34. package/build/src/server/methods/get_prompt.d.ts +1 -1
  35. package/build/src/server/methods/get_prompt.d.ts.map +1 -1
  36. package/build/src/server/methods/initialize.d.ts +1 -1
  37. package/build/src/server/methods/initialize.d.ts.map +1 -1
  38. package/build/src/server/methods/list_prompts.d.ts +1 -1
  39. package/build/src/server/methods/list_prompts.d.ts.map +1 -1
  40. package/build/src/server/methods/list_prompts.js +1 -16
  41. package/build/src/server/methods/list_resource_templates.d.ts +12 -0
  42. package/build/src/server/methods/list_resource_templates.d.ts.map +1 -0
  43. package/build/src/server/methods/list_resource_templates.js +31 -0
  44. package/build/src/server/methods/list_resources.d.ts +1 -1
  45. package/build/src/server/methods/list_resources.d.ts.map +1 -1
  46. package/build/src/server/methods/list_resources.js +2 -9
  47. package/build/src/server/methods/list_tools.d.ts +1 -1
  48. package/build/src/server/methods/list_tools.d.ts.map +1 -1
  49. package/build/src/server/methods/list_tools.js +1 -16
  50. package/build/src/server/methods/ping.d.ts +1 -1
  51. package/build/src/server/methods/ping.d.ts.map +1 -1
  52. package/build/src/server/methods/read_resource.d.ts +1 -1
  53. package/build/src/server/methods/read_resource.d.ts.map +1 -1
  54. package/build/src/server/methods/read_resource.js +13 -1
  55. package/build/src/server/prompt.d.ts +13 -9
  56. package/build/src/server/prompt.d.ts.map +1 -1
  57. package/build/src/server/prompt.js +17 -0
  58. package/build/src/server/resource.d.ts +11 -8
  59. package/build/src/server/resource.d.ts.map +1 -1
  60. package/build/src/server/resource.js +23 -0
  61. package/build/src/server/tool.d.ts +13 -9
  62. package/build/src/server/tool.d.ts.map +1 -1
  63. package/build/src/server/tool.js +17 -0
  64. package/build/src/server/transports/fake_transport.d.ts +2 -2
  65. package/build/src/server/transports/fake_transport.d.ts.map +1 -1
  66. package/build/src/server/transports/http_transport.d.ts +2 -2
  67. package/build/src/server/transports/http_transport.d.ts.map +1 -1
  68. package/build/src/server/transports/stdio_transport.d.ts +1 -1
  69. package/build/src/server/transports/stdio_transport.d.ts.map +1 -1
  70. package/build/src/server.d.ts +2 -1
  71. package/build/src/server.d.ts.map +1 -1
  72. package/build/src/server.js +1 -0
  73. package/build/src/types/content.d.ts +1 -1
  74. package/build/src/types/content.d.ts.map +1 -1
  75. package/build/src/types/context.d.ts +9 -22
  76. package/build/src/types/context.d.ts.map +1 -1
  77. package/build/src/types/method.d.ts +1 -1
  78. package/build/src/types/method.d.ts.map +1 -1
  79. package/build/src/utils/uri_template.d.ts +25 -0
  80. package/build/src/utils/uri_template.d.ts.map +1 -0
  81. package/build/src/utils/uri_template.js +240 -0
  82. package/build/stubs/make/mcp/prompts/main.ts.stub +3 -4
  83. package/build/stubs/make/mcp/resources/main.ts.stub +1 -1
  84. package/build/stubs/make/mcp/tools/main.ts.stub +3 -5
  85. package/build/tsconfig.tsbuildinfo +1 -1
  86. package/package.json +2 -1
  87. package/build/src/server/content.d.ts.map +0 -1
  88. package/build/src/types/transport.d.ts.map +0 -1
  89. /package/build/src/server/{content.js → contracts/content.js} +0 -0
  90. /package/build/src/{types/transport.js → server/contracts/context.js} +0 -0
package/README.md CHANGED
@@ -5,17 +5,32 @@
5
5
 
6
6
  AdonisJS MCP - Server MCP for your AdonisJS applications.
7
7
 
8
+ > **Note:** This documentation has been generated by AI and has not been fully verified yet. Please report any inaccuracies or issues you encounter.
9
+
8
10
  ## Roadmap
9
11
 
10
12
  - [x] MCP tools support
11
13
  - [x] MCP resources support
12
- - [ ] MCP prompts support
14
+ - [x] MCP prompts support
13
15
  - [x] HTTP transport
14
16
  - [x] Stdio transport
15
17
  - [x] Fake transport (for testing)
16
18
  - [x] Advanced pagination support
19
+ - [x] Resource templates
20
+ - [ ] Meta
21
+ - [ ] Annotation
22
+ - [ ] Output tool
23
+ - [ ] Completion
24
+ - [ ] Error(review)
25
+ - [ ] Stream
26
+ - [ ] Session
27
+ - [ ] Vine
28
+ - [ ] Bounce
29
+ - [ ] Auth
30
+ - [ ] Inject
17
31
  - [ ] Alternative transports support SSE
18
- - [ ] Automatic schema validation with Vine ??
32
+ - [ ] JSON Schema with Vine ??
33
+ - [ ] Login
19
34
  - [ ] Documentation
20
35
 
21
36
  ## Installation & Configuration
@@ -32,10 +47,17 @@ import { defineConfig } from '@jrmc/adonis-mcp'
32
47
  export default defineConfig({
33
48
  name: 'adonis-mcp-server',
34
49
  version: '1.0.0',
35
- path: 'app/mcp', // Path where your tools will be stored
36
50
  })
37
51
  ```
38
52
 
53
+ By default, your MCP tools, resources, and prompts will be stored in `app/mcp`. If you want to use a different path, you need to configure it in your `adonisrc.ts` file:
54
+
55
+ ```typescript
56
+ directories: {
57
+ mcp: 'app/custom/mcp', // Optional: custom path for MCP files (defaults to 'app/mcp')
58
+ }
59
+ ```
60
+
39
61
  ## Usage
40
62
 
41
63
  ### Creating a Tool
@@ -49,8 +71,8 @@ node ace make:mcp-tool my_tool
49
71
  This command will create a file in `app/mcp/tools/my_tool.ts` with a base template:
50
72
 
51
73
  ```typescript
52
- import type { McpContext } from '@jrmc/adonis-mcp/types/context'
53
- import type { BaseSchema, InferJSONSchema } from '@jrmc/adonis-mcp/types/method'
74
+ import type { ToolContext } from '@jrmc/adonis-mcp/types/context'
75
+ import type { BaseSchema } from '@jrmc/adonis-mcp/types/method'
54
76
 
55
77
  import { Tool } from '@jrmc/adonis-mcp'
56
78
 
@@ -58,15 +80,14 @@ type Schema = BaseSchema<{
58
80
  text: { type: "string" }
59
81
  }>
60
82
 
61
- type Context = McpContext & { args: InferJSONSchema<Schema> }
62
-
63
- export default class MyToolTool implements Tool<Schema> {
83
+ export default class MyToolTool extends Tool<Schema> {
64
84
  name = 'tool_name'
65
85
  title = 'Tool title'
66
86
  description = 'Tool description'
67
87
 
68
- async handle({ args }: Context) {
88
+ async handle({ args, response }: ToolContext<Schema>) {
69
89
  console.log(args.text)
90
+ return response.text('Hello, world!')
70
91
  }
71
92
 
72
93
  schema() {
@@ -130,7 +151,7 @@ schema() {
130
151
  The `handle` method contains your tool's logic. It receives a typed context with validated arguments:
131
152
 
132
153
  ```typescript
133
- async handle({ args, response, auth, bouncer }: Context) {
154
+ async handle({ args, response, auth, bouncer }: ToolContext<Schema>) {
134
155
  // Your logic here
135
156
  const result = await SomeModel.query().where('id', args.id)
136
157
 
@@ -140,7 +161,7 @@ async handle({ args, response, auth, bouncer }: Context) {
140
161
 
141
162
  ### Setting up Authentication and Bouncer
142
163
 
143
- To use `auth` and `bouncer` in your MCP tools, add the following TypeScript declaration in your middleware (e.g., in your Bouncer initialization middleware):
164
+ To use `auth` and `bouncer` in your MCP tools, prompts, and resources, add the following TypeScript declaration in your middleware (e.g., in your Bouncer initialization middleware):
144
165
 
145
166
  ```typescript
146
167
  declare module '@jrmc/adonis-mcp/types/context' {
@@ -182,7 +203,7 @@ router.mcp('/custom-mcp-path').use(middleware.auth())
182
203
  The MCP context automatically includes the `auth` instance from the `HttpContext` if available. You can use it to access the authenticated user:
183
204
 
184
205
  ```typescript
185
- async handle({ args, auth }: Context) {
206
+ async handle({ args, auth, response }: ToolContext<Schema>) {
186
207
  const user = auth?.user
187
208
 
188
209
  if (!user) {
@@ -204,7 +225,7 @@ async handle({ args, auth }: Context) {
204
225
  The MCP context automatically includes the `bouncer` instance from the `HttpContext` if available. You can use it to check permissions:
205
226
 
206
227
  ```typescript
207
- async handle({ args, bouncer }: Context) {
228
+ async handle({ args, bouncer, response }: ToolContext<Schema>) {
208
229
  // Check a permission
209
230
  await bouncer.authorize('viewUsers')
210
231
 
@@ -231,7 +252,7 @@ For tools, you can use:
231
252
  - `response.send(content: Content | Content[])`: Send custom content objects
232
253
 
233
254
  ```typescript
234
- async handle({ args, response }: Context) {
255
+ async handle({ args, response }: ToolContext<Schema>) {
235
256
  // Return text
236
257
  return response.text(JSON.stringify({ success: true }))
237
258
 
@@ -263,8 +284,8 @@ async handle({ response }: ResourceContext) {
263
284
  Here is a complete example of a tool that creates a bookmark:
264
285
 
265
286
  ```typescript
266
- import type { McpContext } from '@jrmc/adonis-mcp/types/context'
267
- import type { BaseSchema, InferJSONSchema } from '@jrmc/adonis-mcp/types/method'
287
+ import type { ToolContext } from '@jrmc/adonis-mcp/types/context'
288
+ import type { BaseSchema } from '@jrmc/adonis-mcp/types/method'
268
289
 
269
290
  import { Tool } from '@jrmc/adonis-mcp'
270
291
  import Bookmark from '#models/bookmark'
@@ -274,14 +295,12 @@ type Schema = BaseSchema<{
274
295
  url: { type: "string" }
275
296
  }>
276
297
 
277
- type Context = McpContext & { args: InferJSONSchema<Schema> }
278
-
279
- export default class AddBookmarkTool implements Tool<Schema> {
298
+ export default class AddBookmarkTool extends Tool<Schema> {
280
299
  name = 'create_bookmark'
281
300
  title = 'Create Bookmark'
282
301
  description = 'Create a new bookmark'
283
302
 
284
- async handle({ args, response, auth }: Context) {
303
+ async handle({ args, response, auth }: ToolContext<Schema>) {
285
304
  const bookmark = await Bookmark.create({
286
305
  title: args.title,
287
306
  text: args.url,
@@ -325,7 +344,7 @@ import type { ResourceContext } from '@jrmc/adonis-mcp/types/context'
325
344
 
326
345
  import { Resource } from '@jrmc/adonis-mcp'
327
346
 
328
- export default class MyResourceResource implements Resource {
347
+ export default class MyResourceResource extends Resource {
329
348
  name = 'example.txt'
330
349
  uri = 'file:///example.txt'
331
350
  mimeType = 'text/plain'
@@ -363,6 +382,189 @@ async handle({ response }: ResourceContext) {
363
382
  }
364
383
  ```
365
384
 
385
+ ### URI Templates
386
+
387
+ Resources support URI templates (RFC 6570) to create dynamic resources. This allows you to define resources with variable parts in their URIs:
388
+
389
+ ```typescript
390
+ import type { ResourceContext } from '@jrmc/adonis-mcp/types/context'
391
+ import { Resource } from '@jrmc/adonis-mcp'
392
+
393
+ type Args = {
394
+ name: string
395
+ }
396
+
397
+ export default class RobotsResource extends Resource<Args> {
398
+ name = 'robots.txt'
399
+ uri = 'file:///{name}.txt'
400
+ mimeType = 'text/plain'
401
+ title = 'Robots file'
402
+ description = 'Dynamic robots.txt file'
403
+
404
+ async handle({ args, response }: ResourceContext<Args>) {
405
+ this.size = 1000
406
+ return response.text(`Hello World ${args?.name}`)
407
+ }
408
+ }
409
+ ```
410
+
411
+ When a client requests `file:///robots.txt`, the template `file:///{name}.txt` will match and extract `name: "robots"` as an argument, which will be available in the `handle` method via `args.name`.
412
+
413
+ URI templates support various operators:
414
+ - `{name}` - Simple variable substitution
415
+ - `{/name}` - Path segment
416
+ - `{?name}` - Query parameter
417
+ - `{&name}` - Additional query parameter
418
+ - `{#name}` - Fragment identifier
419
+ - `{+name}` - Reserved characters allowed
420
+ - `{.name}` - Dot-prefixed segment
421
+
422
+ For more information, see [RFC 6570](https://www.rfc-editor.org/rfc/rfc6570).
423
+
424
+ ### Creating a Prompt
425
+
426
+ To create a new prompt, use the Ace command:
427
+
428
+ ```bash
429
+ node ace make:mcp-prompt my_prompt
430
+ ```
431
+
432
+ This command will create a file in `app/mcp/prompts/my_prompt.ts` with a base template:
433
+
434
+ ```typescript
435
+ import type { PromptContext } from '@jrmc/adonis-mcp/types/context'
436
+ import type { BaseSchema } from '@jrmc/adonis-mcp/types/method'
437
+
438
+ import { Prompt } from '@jrmc/adonis-mcp'
439
+
440
+ type Schema = BaseSchema<{
441
+ text: { type: "string" }
442
+ }>
443
+
444
+ export default class MyPromptPrompt extends Prompt<Schema> {
445
+ name = 'my_prompt'
446
+ title = 'Prompt title'
447
+ description = 'Prompt description'
448
+
449
+ async handle({ args, response }: PromptContext<Schema>) {
450
+ return [
451
+ response.text('Hello, world!')
452
+ ]
453
+ }
454
+
455
+ schema() {
456
+ return {
457
+ type: "object",
458
+ properties: {
459
+ text: {
460
+ type: "string",
461
+ description: "Description text argument"
462
+ },
463
+ },
464
+ required: ["text"]
465
+ } as Schema
466
+ }
467
+ }
468
+ ```
469
+
470
+ ### Prompt Schema
471
+
472
+ Prompts use the same schema definition system as tools, following the [JSON Schema](https://json-schema.org/) specification. You can also use Zod to define your schema:
473
+
474
+ ```typescript
475
+ import * as z from 'zod'
476
+
477
+ const zodSchema = z.object({
478
+ code: z.string(),
479
+ language: z.string().optional()
480
+ })
481
+
482
+ schema() {
483
+ return z.toJSONSchema(
484
+ zodSchema,
485
+ { io: "input" }
486
+ ) as Schema
487
+ }
488
+ ```
489
+
490
+ ### Prompt Handler
491
+
492
+ The `handle` method for prompts returns an array of content objects. This allows you to return multiple pieces of content, including embedded resources:
493
+
494
+ ```typescript
495
+ async handle({ args, response }: PromptContext<Schema>) {
496
+ return [
497
+ response.text(`Please review this code:\n\n${args.code}`),
498
+ response.embeddedResource('file:///example.txt')
499
+ ]
500
+ }
501
+ ```
502
+
503
+ ### Prompt Response Methods
504
+
505
+ For prompts, you can use the same response methods as tools, but you must return an array:
506
+
507
+ - `response.text(text: string)`: Return plain text content
508
+ - `response.image(data: string, mimeType: string)`: Return image content (base64 encoded)
509
+ - `response.audio(data: string, mimeType: string)`: Return audio content (base64 encoded)
510
+ - `response.embeddedResource(uri: string)`: Embed another resource in the prompt response
511
+
512
+ ```typescript
513
+ async handle({ args, response }: PromptContext<Schema>) {
514
+ return [
515
+ response.text('Here is the code to review:'),
516
+ response.embeddedResource('file:///code.py'),
517
+ response.text('Please provide feedback.')
518
+ ]
519
+ }
520
+ ```
521
+
522
+ ### Complete Prompt Example
523
+
524
+ Here is a complete example of a prompt for code review:
525
+
526
+ ```typescript
527
+ import type { PromptContext } from '@jrmc/adonis-mcp/types/context'
528
+ import type { BaseSchema } from '@jrmc/adonis-mcp/types/method'
529
+
530
+ import { Prompt } from '@jrmc/adonis-mcp'
531
+
532
+ type Schema = BaseSchema<{
533
+ code: { type: "string" }
534
+ language: { type: "string" }
535
+ }>
536
+
537
+ export default class CodeReviewPrompt extends Prompt<Schema> {
538
+ name = 'code_review'
539
+ title = 'Code Review'
540
+ description = 'Review code and provide feedback'
541
+
542
+ async handle({ args, response }: PromptContext<Schema>) {
543
+ return [
544
+ response.text(`Please review this ${args.language} code:\n\n${args.code}`),
545
+ response.text('Provide feedback on code quality, potential bugs, and improvements.')
546
+ ]
547
+ }
548
+
549
+ schema() {
550
+ return {
551
+ type: "object",
552
+ properties: {
553
+ code: {
554
+ type: "string",
555
+ description: "The code to review"
556
+ },
557
+ language: {
558
+ type: "string",
559
+ description: "Programming language"
560
+ }
561
+ },
562
+ required: ["code", "language"]
563
+ } as Schema
564
+ }
565
+ }
566
+ ```
567
+
366
568
  ### Transports
367
569
 
368
570
  The package supports multiple transport mechanisms:
@@ -1 +1 @@
1
- {"commands":[{"commandName":"make:mcp-prompt","description":"Create a new MCP prompt","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the prompt","type":"string"}],"options":{"startApp":true},"filePath":"make/prompt.js"},{"commandName":"make:mcp-resource","description":"Create a new MCP resource","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the resource","type":"string"}],"options":{"startApp":true},"filePath":"make/resource.js"},{"commandName":"make:mcp-tool","description":"Create a new MCP tool","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the tool","type":"string"}],"options":{"startApp":true},"filePath":"make/tool.js"},{"commandName":"mcp:start","description":"Start the MCP server stdio transport","help":"","namespace":"mcp","aliases":[],"flags":[],"args":[],"options":{"startApp":true},"filePath":"start.js"}],"version":1}
1
+ {"commands":[{"commandName":"mcp:inspector","description":"Open the MCP Inspector tool to debug and test MCP Servers.","help":"","namespace":"mcp","aliases":[],"flags":[],"args":[{"name":"transport","argumentName":"transport","required":true,"description":"Transport type","default":"http","type":"string"}],"options":{"startApp":true},"filePath":"inspector.js"},{"commandName":"make:mcp-prompt","description":"Create a new MCP prompt","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the prompt","type":"string"}],"options":{"startApp":true},"filePath":"make/prompt.js"},{"commandName":"make:mcp-resource","description":"Create a new MCP resource","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the resource","type":"string"}],"options":{"startApp":true},"filePath":"make/resource.js"},{"commandName":"make:mcp-tool","description":"Create a new MCP tool","help":"","namespace":"make","aliases":[],"flags":[],"args":[{"name":"name","argumentName":"name","required":true,"description":"Name of the tool","type":"string"}],"options":{"startApp":true},"filePath":"make/tool.js"},{"commandName":"mcp:start","description":"Start the MCP server stdio transport","help":"","namespace":"mcp","aliases":[],"flags":[],"args":[],"options":{"startApp":true},"filePath":"start.js"}],"version":1}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @jrmc/adonis-mcp
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ import type { CommandOptions } from '@adonisjs/core/types/ace';
8
+ import { BaseCommand } from '@adonisjs/core/ace';
9
+ export default class Inspector extends BaseCommand {
10
+ static commandName: string;
11
+ static description: string;
12
+ static options: CommandOptions;
13
+ transport: string;
14
+ run(): Promise<void>;
15
+ }
16
+ //# sourceMappingURL=inspector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspector.d.ts","sourceRoot":"","sources":["../../commands/inspector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAG9D,OAAO,EAAQ,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEtD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,WAAW;IAChD,MAAM,CAAC,WAAW,SAAkB;IACpC,MAAM,CAAC,WAAW,SAA+D;IAEjF,MAAM,CAAC,OAAO,EAAE,cAAc,CAE7B;IAGO,SAAS,EAAE,MAAM,CAAA;IAEnB,GAAG;CAoCV"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @jrmc/adonis-mcp
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
7
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
8
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10
+ 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;
11
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
12
+ };
13
+ import { $ } from 'execa';
14
+ import { args, BaseCommand } from '@adonisjs/core/ace';
15
+ export default class Inspector extends BaseCommand {
16
+ static commandName = 'mcp:inspector';
17
+ static description = 'Open the MCP Inspector tool to debug and test MCP Servers.';
18
+ static options = {
19
+ startApp: true,
20
+ };
21
+ async run() {
22
+ if (this.app.inProduction) {
23
+ this.logger.error('Cannot open MCP inspector in production environment');
24
+ return;
25
+ }
26
+ if (this.transport !== 'http' && this.transport !== 'stdio') {
27
+ this.logger.error('Invalid transport type');
28
+ return;
29
+ }
30
+ if (this.transport === 'http') {
31
+ const router = await this.app.container.make('router');
32
+ const serverUrl = router
33
+ .builder()
34
+ .prefixUrl(`http://${process.env.HOST}:${process.env.PORT}`)
35
+ .disableRouteLookup()
36
+ .make('/mcp');
37
+ const inspectorProcess = $({
38
+ stdio: 'inherit',
39
+ }) `npx @modelcontextprotocol/inspector --transport http --server-url ${serverUrl}`;
40
+ await inspectorProcess;
41
+ }
42
+ else {
43
+ const nodeBinary = process.execPath;
44
+ const acePath = this.app.makePath('ace.js');
45
+ const inspectorProcess = $({
46
+ stdio: 'inherit',
47
+ }) `npx @modelcontextprotocol/inspector --transport stdio ${nodeBinary} ${acePath} mcp:start`;
48
+ await inspectorProcess;
49
+ }
50
+ }
51
+ }
52
+ __decorate([
53
+ args.string({ description: 'Transport type', default: 'http' })
54
+ ], Inspector.prototype, "transport", void 0);
@@ -4,7 +4,7 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- import type { Content } from '../content.js';
7
+ import type { Content } from '../contracts/content.js';
8
8
  import type { AudioContent } from '../../types/jsonrpc.js';
9
9
  import type { AnyTool as Tool } from '../tool.js';
10
10
  import type { AnyPrompt as Prompt } from '../prompt.js';
@@ -1 +1 @@
1
- {"version":3,"file":"audio.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/audio.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAG9C,OAAO,IAAI,MAAM,qBAAqB,CAAA;AAEtC,MAAM,CAAC,OAAO,OAAO,KAAM,YAAW,OAAO;;gBAM/B,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAOrE,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAS1C,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAShD,UAAU,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;IAIrD,WAAW,IAAI,IAAI;IAKnB,MAAM,IAAI,IAAI;IAKd,IAAI,IAAI,SAEP;CACF"}
1
+ {"version":3,"file":"audio.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/audio.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAG9C,OAAO,IAAI,MAAM,qBAAqB,CAAA;AAEtC,MAAM,CAAC,OAAO,OAAO,KAAM,YAAW,OAAO;;gBAM/B,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAOrE,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAS1C,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAShD,UAAU,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;IAIrD,WAAW,IAAI,IAAI;IAKnB,MAAM,IAAI,IAAI;IAKd,IAAI,IAAI,SAEP;CACF"}
@@ -4,7 +4,7 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- import type { Content } from '../content.js';
7
+ import type { Content } from '../contracts/content.js';
8
8
  import type { BlobResourceContents } from '../../types/jsonrpc.js';
9
9
  import type { Resource } from '../resource.js';
10
10
  import type { AnyTool as Tool } from '../tool.js';
@@ -1 +1 @@
1
- {"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/blob.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AAGvD,MAAM,CAAC,OAAO,OAAO,IAAK,YAAW,OAAO;;gBAG9B,IAAI,EAAE,MAAM,GAAG,MAAM;IAQ3B,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC;IAInC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAIzC,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAOpE"}
1
+ {"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/blob.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AAGvD,MAAM,CAAC,OAAO,OAAO,IAAK,YAAW,OAAO;;gBAG9B,IAAI,EAAE,MAAM,GAAG,MAAM;IAQ3B,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC;IAInC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAIzC,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAOpE"}
@@ -4,7 +4,7 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- import type { Content } from '../content.js';
7
+ import type { Content } from '../contracts/content.js';
8
8
  import type { EmbeddedResource as EmbeddedResourceContent } from '../../types/jsonrpc.js';
9
9
  import type { AnyTool as Tool } from '../tool.js';
10
10
  import type { AnyPrompt as Prompt } from '../prompt.js';
@@ -1 +1 @@
1
- {"version":3,"file":"embedded_resource.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/embedded_resource.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,gBAAgB,IAAI,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AACzF,OAAO,KAAK,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAI7D,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,OAAO;;gBAM1C,GAAG,EAAE,MAAM;IAKjB,UAAU,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAc3E,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAYrD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAY3D,UAAU,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;IAOrD,WAAW,IAAI,IAAI;IAKnB,MAAM,IAAI,IAAI;IAKd,IAAI,IAAI,yBAEP;CACF"}
1
+ {"version":3,"file":"embedded_resource.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/embedded_resource.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,KAAK,EAAE,gBAAgB,IAAI,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AACzF,OAAO,KAAK,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAI7D,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,OAAO;;gBAM1C,GAAG,EAAE,MAAM;IAKjB,UAAU,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAc3E,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAYrD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAY3D,UAAU,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;IAOrD,WAAW,IAAI,IAAI;IAKnB,MAAM,IAAI,IAAI;IAKd,IAAI,IAAI,yBAEP;CACF"}
@@ -4,7 +4,7 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- import type { Content } from '../content.js';
7
+ import type { Content } from '../contracts/content.js';
8
8
  import type { AnyPrompt as Prompt } from '../prompt.js';
9
9
  import type { Resource } from '../resource.js';
10
10
  import Text from './text.js';
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,IAAI,MAAM,WAAW,CAAA;AAG5B,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,IAAK,YAAW,OAAO;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK;IAIhC,UAAU,CAAC,SAAS,EAAE,QAAQ,GAAG,KAAK;CAGvC"}
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,IAAI,MAAM,WAAW,CAAA;AAG5B,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,IAAK,YAAW,OAAO;IACxD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK;IAIhC,UAAU,CAAC,SAAS,EAAE,QAAQ,GAAG,KAAK;CAGvC"}
@@ -4,7 +4,7 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- import type { Content } from '../content.js';
7
+ import type { Content } from '../contracts/content.js';
8
8
  import type { ImageContent } from '../../types/jsonrpc.js';
9
9
  import type { AnyTool as Tool } from '../tool.js';
10
10
  import type { AnyPrompt as Prompt } from '../prompt.js';
@@ -1 +1 @@
1
- {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/image.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAG9C,OAAO,IAAI,MAAM,qBAAqB,CAAA;AAEtC,MAAM,CAAC,OAAO,OAAO,KAAM,YAAW,OAAO;;gBAM/B,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAOrE,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAS1C,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAShD,UAAU,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;IAIrD,WAAW,IAAI,IAAI;IAKnB,MAAM,IAAI,IAAI;IAKd,IAAI,IAAI,SAEP;CACF"}
1
+ {"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/image.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAG9C,OAAO,IAAI,MAAM,qBAAqB,CAAA;AAEtC,MAAM,CAAC,OAAO,OAAO,KAAM,YAAW,OAAO;;gBAM/B,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAOrE,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC;IAS1C,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAShD,UAAU,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;IAIrD,WAAW,IAAI,IAAI;IAKnB,MAAM,IAAI,IAAI;IAKd,IAAI,IAAI,SAEP;CACF"}
@@ -4,7 +4,7 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- import type { Content } from '../content.js';
7
+ import type { Content } from '../contracts/content.js';
8
8
  import type { ResourceLink as ResourceLinkContent } from '../../types/jsonrpc.js';
9
9
  import type { AnyTool as Tool } from '../tool.js';
10
10
  import type { AnyPrompt as Prompt } from '../prompt.js';
@@ -1 +1 @@
1
- {"version":3,"file":"resource_link.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/resource_link.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACjF,OAAO,KAAK,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAIzD,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,OAAO;;gBAItC,GAAG,EAAE,MAAM;IAKjB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAarD,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAgBjD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAOzC,UAAU,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;CAMtD"}
1
+ {"version":3,"file":"resource_link.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/resource_link.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACjF,OAAO,KAAK,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAIzD,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,OAAO;;gBAItC,GAAG,EAAE,MAAM;IAKjB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAarD,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAgBjD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAOzC,UAAU,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;CAMtD"}
@@ -4,7 +4,7 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- import type { Content } from '../content.js';
7
+ import type { Content } from '../contracts/content.js';
8
8
  import type { TextContent } from '../../types/jsonrpc.js';
9
9
  import type { Resource } from '../resource.js';
10
10
  import type { AnyTool as Tool } from '../tool.js';
@@ -1 +1 @@
1
- {"version":3,"file":"structured.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/structured.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AAIvD,MAAM,CAAC,OAAO,OAAO,UAAW,YAAW,OAAO;;gBAGpC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAI3C,IAAI,iBAAiB,4BAEpB;IAEK,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC;IAIzC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAIzC,UAAU,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;CAGtD"}
1
+ {"version":3,"file":"structured.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/structured.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AAIvD,MAAM,CAAC,OAAO,OAAO,UAAW,YAAW,OAAO;;gBAGpC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAI3C,IAAI,iBAAiB,4BAEpB;IAEK,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC;IAIzC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAOzC,UAAU,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;CAMtD"}
@@ -4,7 +4,7 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- import type { Content } from '../content.js';
7
+ import type { Content } from '../contracts/content.js';
8
8
  import type { TextContent, TextResourceContents } from '../../types/jsonrpc.js';
9
9
  import type { AnyTool as Tool } from '../tool.js';
10
10
  import type { AnyPrompt as Prompt } from '../prompt.js';
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/text.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC/E,OAAO,KAAK,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,OAAO,IAAI,MAAM,qBAAqB,CAAA;AAEtC,MAAM,CAAC,OAAO,OAAO,IAAK,YAAW,OAAO;;gBAI9B,IAAI,EAAE,MAAM,GAAG,OAAO;IAS5B,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC;IAOzC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAO/C,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAQnE,WAAW,IAAI,IAAI;IAKnB,MAAM,IAAI,IAAI;IAKd,IAAI,IAAI,SAEP;CACF"}
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../../src/server/contents/text.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC/E,OAAO,KAAK,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,IAAI,MAAM,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,OAAO,IAAI,MAAM,qBAAqB,CAAA;AAEtC,MAAM,CAAC,OAAO,OAAO,IAAK,YAAW,OAAO;;gBAI9B,IAAI,EAAE,MAAM,GAAG,OAAO;IAS5B,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC;IAOzC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAO/C,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAQnE,WAAW,IAAI,IAAI;IAKnB,MAAM,IAAI,IAAI;IAKd,IAAI,IAAI,SAEP;CACF"}
@@ -4,11 +4,13 @@
4
4
  * @license MIT
5
5
  * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
6
  */
7
- import type { McpContext, ServerContextOptions } from '../types/context.js';
7
+ import type { McpContext } from './contracts/context.js';
8
+ import type { ServerContextOptions } from '../types/context.js';
8
9
  import type { ToolList, ResourceList, PromptList } from '../types/method.js';
9
10
  import type { McpRequest, McpRequestType } from '../types/request.js';
10
11
  import type { McpToolResponse, McpResourceResponse, McpPromptResponse } from '../types/response.js';
11
12
  export default class ServerContext implements McpContext {
13
+ #private;
12
14
  readonly requestType: McpRequestType;
13
15
  supportedProtocolVersions: string[];
14
16
  serverCapabilities: Record<string, any>;
@@ -24,5 +26,7 @@ export default class ServerContext implements McpContext {
24
26
  response: this['requestType'] extends 'resource' ? McpResourceResponse : this['requestType'] extends 'prompt' ? McpPromptResponse : McpToolResponse;
25
27
  constructor(options: ServerContextOptions);
26
28
  getPerPage(requestedPerPage?: number): number;
29
+ getResources(): Promise<ResourceList>;
30
+ getResourceTemplates(): Promise<ResourceList>;
27
31
  }
28
32
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/server/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC3E,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAKnG,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,UAAU;IACtD,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAA;IAEpC,yBAAyB,EAAE,MAAM,EAAE,CAAA;IACnC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,uBAAuB,EAAE,MAAM,CAAA;IAC/B,KAAK,EAAE,QAAQ,CAAA;IACf,SAAS,EAAE,YAAY,CAAA;IACvB,OAAO,EAAE,UAAU,CAAA;IACnB,OAAO,EAAE,UAAU,CAAA;IACnB,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,SAAS,UAAU,GAC5C,mBAAmB,GACnB,IAAI,CAAC,aAAa,CAAC,SAAS,QAAQ,GAClC,iBAAiB,GACjB,eAAe,CAAA;gBAET,OAAO,EAAE,oBAAoB;IAyBlC,UAAU,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM;CAGrD"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/server/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAMnG,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,UAAU;;IACtD,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAA;IAEpC,yBAAyB,EAAE,MAAM,EAAE,CAAA;IACnC,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,uBAAuB,EAAE,MAAM,CAAA;IAC/B,KAAK,EAAE,QAAQ,CAAA;IACf,SAAS,EAAE,YAAY,CAAA;IACvB,OAAO,EAAE,UAAU,CAAA;IACnB,OAAO,EAAE,UAAU,CAAA;IACnB,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,SAAS,UAAU,GAC5C,mBAAmB,GACnB,IAAI,CAAC,aAAa,CAAC,SAAS,QAAQ,GAClC,iBAAiB,GACjB,eAAe,CAAA;gBAET,OAAO,EAAE,oBAAoB;IAyBzC,UAAU,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM;IAIvC,YAAY,IAAI,OAAO,CAAC,YAAY,CAAC;IAIrC,oBAAoB,IAAI,OAAO,CAAC,YAAY,CAAC;CA2BpD"}
@@ -1,5 +1,12 @@
1
+ /**
2
+ * @jrmc/adonis-mcp
3
+ *
4
+ * @license MIT
5
+ * @copyright Jeremy Chaufourier <jeremy@chaufourier.fr>
6
+ */
1
7
  import Request from '../request.js';
2
8
  import McpResponse from '../response.js';
9
+ import { UriTemplate } from '../utils/uri_template.js';
3
10
  export default class ServerContext {
4
11
  requestType;
5
12
  supportedProtocolVersions;
@@ -42,4 +49,23 @@ export default class ServerContext {
42
49
  getPerPage(requestedPerPage) {
43
50
  return Math.min(requestedPerPage ?? this.defaultPaginationLength, this.maxPaginationLength);
44
51
  }
52
+ async getResources() {
53
+ return this.#filterResources({ includeTemplates: false });
54
+ }
55
+ async getResourceTemplates() {
56
+ return this.#filterResources({ includeTemplates: true });
57
+ }
58
+ async #filterResources({ includeTemplates, }) {
59
+ const resourceEntries = Object.entries(this.resources);
60
+ const filteredEntries = await Promise.all(resourceEntries.map(async ([key, resource]) => {
61
+ const { default: Resource } = await import(resource);
62
+ const resourceInstance = new Resource();
63
+ const isTemplate = this.#isResourceTemplate(resourceInstance);
64
+ return (includeTemplates ? isTemplate : !isTemplate) ? [key, resource] : null;
65
+ }));
66
+ return Object.fromEntries(filteredEntries.filter((entry) => entry !== null));
67
+ }
68
+ #isResourceTemplate(resource) {
69
+ return UriTemplate.isTemplate(resource.uri);
70
+ }
45
71
  }