| 1 | import { SetMetadata } from '@nestjs/common' |
| 2 | import { MCP_RESOURCE_METADATA_KEY } from './constants' |
| 3 | |
| 4 | export interface ResourceOptions { |
| 5 | uri: string // Unique identifier for the resource |
| 6 | name?: string // Human-readable name |
| 7 | description?: string // Optional description |
| 8 | mimeType?: string // Optional MIME type |
| 9 | _meta?: Record<string, any> |
| 10 | } |
| 11 | |
| 12 | export interface ResourceMetadata { |
| 13 | uri: string // Unique identifier for the resource |
| 14 | name: string // Human-readable name |
| 15 | description?: string // Optional description |
| 16 | mimeType?: string // Optional MIME type |
| 17 | _meta?: Record<string, any> |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * Decorator that marks a controller method as an MCP resource. |
| 22 | * @param {object} options - The options for the decorator |
| 23 | * @param {string} options.name - The name of the resource |
| 24 | * @param {string} options.uri - The URI of the resource |
| 25 | * @returns {MethodDecorator} - The decorator |
| 26 | */ |
| 27 | export function Resource(options: ResourceOptions) { |
| 28 | return SetMetadata(MCP_RESOURCE_METADATA_KEY, options) |
| 29 | } |
| 30 |