auth-security
Best practices for implementing JWT, API Keys, OAuth 2.1, and RBAC in a NitroStack application.
Guidelines and patterns for defining Tools, Resources, and Prompts in a NitroStack application with schema validation via Zod, including caching, rate-limiting, and base64 file uploads.
$ npx -y skills add nitrocloudofficial/nitrostack --skill tools-resources-prompts --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/tools-resources-promptsContext preview
The summary Claude sees to decide when to auto-load this skill.
Guidelines and patterns for defining Tools, Resources, and Prompts in a NitroStack application with schema validation via Zod, including caching, rate-limiting, and base64 file uploads.
name: nitrostack-tools-resources-prompts description: Guidelines and patterns for defining Tools, Resources, and Prompts in a NitroStack application with schema validation via Zod, including caching, rate-limiting, and base64 file uploads.
Use this skill whenever you are defining, editing, or validating tools, resources, or prompts on a NitroStack MCP server.
An MCP tool exposes a function that an AI client can invoke. Decorate a service or controller method with `@Tool`.
import { ToolDecorator as Tool, ControllerDecorator as Controller, InitialTool, z, ExecutionContext } from '@nitrostack/core';
@Controller('weather')
export class WeatherService {
@Tool({
name: 'get_current_weather',
description: 'Get the current weather forecast for a specific city.',
inputSchema: z.object({
city: z.string().describe('The name of the city, e.g., San Francisco'),
unit: z.enum(['celsius', 'fahrenheit']).default('celsius'),
}),
})
@InitialTool() // Auto-invoked when the AI client initializes/starts
async getWeather(
input: { city: string; unit: 'celsius' | 'fahrenheit' },
ctx: ExecutionContext
) {
ctx.logger.info(`Fetching weather for ${input.city}`);
// implementation
return {
city: input.city,
temp: 22,
condition: 'Sunny',
};
}
}An MCP resource exposes static or dynamic data files/URIs that the AI client can read.
import { Resource, ExecutionContext } from '@nitrostack/core';
export class ConfigResources {
@Resource({
uri: 'app://settings',
name: 'Application Settings',
description: 'System-wide configuration settings and parameters.',
mimeType: 'application/json',
})
async getSettings(ctx: ExecutionContext) {
return {
environment: 'development',
debugMode: true,
};
}
}An MCP prompt exposes reusable templates or instruction sets that guide LLMs.
import { Prompt, ExecutionContext } from '@nitrostack/core';
export class PromptTemplates {
@Prompt({
name: 'code_review',
description: 'Provide an intensive code review for a given code snippet.',
arguments: [
{ name: 'language', description: 'The programming language, e.g., TypeScript', required: true },
{ name: 'code', description: 'The code snippet to review', required: true },
],
})
async getCodeReviewPrompt(
args: { language: string; code: string },
ctx: ExecutionContext
) {
return {
messages: [
{
role: 'user',
content: `You are an expert software engineer. Review this ${args.language} code:\n\n${args.code}`,
},
],
};
}
}---
You can control tool execution behaviors (such as performance optimization and throttling) using method decorators.
Use `@Cache` to cache tool execution outputs for a specified duration (TTL in seconds). This reduces database or API overhead for frequent identical requests.
import { ToolDecorator as Tool, Cache, z } from '@nitrostack/core';
export class StationTools {
@Tool({
name: 'get_system_status',
description: 'Fetch real-time station metrics. Response is cached.',
inputSchema: z.object({}),
})
@Cache({ ttl: 60 }) // Caches status for 60 seconds
async getSystemStatus() {
return { temperature: 21.5, oxygen: 0.98 };
}
@Tool({
name: 'get_crew_status',
description: 'Fetch status of a crew member. Cached by crew ID.',
inputSchema: z.object({ id: z.string() }),
})
@Cache({
ttl: 300,
key: (input) => `crew:status:${input.id}`
})
async getCrewStatus(input: { id: string }) {
// ...
}
}Use `@RateLimit` to restrict the number of tool invocations within a specified time window to prevent client abuse.
import { ToolDecorator as Tool, RateLimit, z, ExecutionContext } from '@nitrostack/core';
export class DiagnosticTools {
@Tool({
name: 'run_deep_diagnostic',
description: 'Run intensive diagnostics. Rate limited.',
inputSchema: z.object({}),
})
@RateLimit({ requests: 3, window: '1m' }) // Max 3 requests per minute globally
async runDeepDiagnostic() {
return { diagnosticReport: 'All systems operational.' };
}
@Tool({
name: 'request_supply_drop',
desThe full-stack TypeScript framework to build, test, and deploy production-ready MCP servers and AI-native apps.
Repo: nitrocloudofficial/nitrostack
Best practices for implementing JWT, API Keys, OAuth 2.1, and RBAC in a NitroStack application.
Best practices and guidelines for bootstrapping, defining modules, using dependency injection, managing server lifecycles, and handling events in the…
Best practices for implementing and applying Guards, Interceptors, Middleware, Pipes, and Exception Filters in the NitroStack SDK.
Best practices for linking tools to interactive frontend widgets using @Widget and @nitrostack/widgets SDK (including state sync, tool calling, display modes,…
Prisma ORM CLI commands reference covering init, generate, migrate, db, dev, studio, validate, format, debug, and mcp. Use for ORM/database CLI workflows, not…
Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering…