Decorators API Reference
@Tool
Define MCP tools.
@Tool(options: ToolOptions)
interface ToolOptions {
name: string;
description: string;
inputSchema?: ZodObject;
examples?: {
request?: any;
response?: any;
};
}
@Resource
Define MCP resources.
@Resource(options: ResourceOptions)
interface ResourceOptions {
uri: string;
name: string;
description: string;
mimeType?: string;
examples?: {
response?: any;
};
}
@Prompt
Define MCP prompts.
@Prompt(options: PromptOptions)
interface PromptOptions {
name: string;
description: string;
arguments?: Array<{
name: string;
description: string;
required?: boolean;
}>;
}
@Module
Define modules.
@Module(options: ModuleOptions)
interface ModuleOptions {
name: string;
description?: string;
controllers?: any[];
providers?: any[];
imports?: any[];
exports?: any[];
}
@UseGuards
Apply guards.
@UseGuards(...guards: any[])
@UseMiddleware
Apply middleware.
@UseMiddleware(...middleware: any[])
@UseInterceptors
Apply interceptors.
@UseInterceptors(...interceptors: any[])
@Cache
Cache responses.
@Cache(options: CacheOptions)
interface CacheOptions {
ttl: number; // seconds
key?: (input: any) => string;
}
@RateLimit
Rate limit requests.
@RateLimit(options: RateLimitOptions)
interface RateLimitOptions {
requests: number;
window: string; // '1m', '1h', etc.
key?: (ctx: ExecutionContext) => string;
}
@Injectable
Mark for dependency injection.
@Injectable()
@Widget
Attach UI widget.
@Widget(widgetName: string)