Decorator Inventory
| Decorator | Purpose | Base Class |
|---|---|---|
@FrontMcp | Server entry point | — |
@App | Capability container | — |
@Tool | AI-callable action | ToolContext |
@Resource / @ResourceTemplate | Data endpoint | ResourceContext |
@Prompt | Message template | PromptContext |
@Agent | LLM-powered actor | AgentContext |
@Skill | Workflow guide | SkillContext |
@Provider | DI service | — |
@Plugin | Extension | DynamicPlugin |
@Channel | Notification stream | ChannelContext |
@Adapter | Dynamic capabilities | DynamicAdapter |
@Flow | Lifecycle pipeline | FlowBase |
One Snippet Per Decorator
@FrontMcp — Server Entry Point
import 'reflect-metadata';
import { FrontMcp } from '@frontmcp/sdk';
@FrontMcp({
info: { name: 'My Server', version: '1.0.0' },
apps: [MyApp],
http: { port: 3000 },
})
export default class Server {}
@App — Capability Container
import { App } from '@frontmcp/sdk';
@App({
id: 'crm',
name: 'CRM App',
tools: [CreateLeadTool, GetContactsTool],
resources: [LeadResource],
prompts: [OutreachPrompt],
})
class CrmApp {}
@Tool — AI-Callable Action
@Tool({
name: 'greet',
description: 'Greets a user by name',
inputSchema: { name: z.string() },
})
class GreetTool extends ToolContext {
async execute({ name }: { name: string }) {
return `Hello, ${name}!`;
}
}
const GreetTool = tool({
name: 'greet',
description: 'Greets a user by name',
inputSchema: { name: z.string() },
})(({ name }) => `Hello, ${name}!`);
@Resource — Data Endpoint
@Resource({
name: 'config',
uri: 'config://app',
mimeType: 'application/json',
})
class ConfigResource extends ResourceContext {
async execute(uri: string) {
return { contents: [{ uri, mimeType: 'application/json', text: '{}' }] };
}
}
@ResourceTemplate({
name: 'user',
uriTemplate: 'users://{userId}',
mimeType: 'application/json',
})
class UserResource extends ResourceContext {
async execute(uri: string, params: Record<string, string>) {
return { contents: [{ uri, text: JSON.stringify({ id: params.userId }) }] };
}
}
@Prompt — Message Template
@Prompt({
name: 'summarize',
arguments: [
{ name: 'topic', description: 'Topic to summarize', required: true },
],
})
class SummarizePrompt extends PromptContext {
async execute(args: Record<string, string>): Promise<GetPromptResult> {
return {
messages: [{ role: 'user', content: { type: 'text', text: `Summarize: ${args.topic}` } }],
};
}
}
@Agent — LLM-Powered Actor
@Agent({
name: 'researcher',
description: 'Research agent that gathers information',
llm: {
provider: 'anthropic',
model: 'claude-sonnet-4-20250514',
apiKey: { env: 'ANTHROPIC_API_KEY' },
},
tools: [WebSearchTool, SummarizeTool],
systemInstructions: 'You are a thorough research assistant.',
})
class ResearcherAgent extends AgentContext {
async execute(input: unknown) { /* ... */ }
}
@Skill — Workflow Guide
@Skill({
name: 'review-pr',
description: 'Review a GitHub pull request',
instructions: `## Steps\n1. Fetch PR details\n2. Review files\n3. Submit review`,
tools: [
{ name: 'github_get_pr', purpose: 'Fetch PR metadata', required: true },
{ name: 'github_submit_review', purpose: 'Submit review verdict' },
],
})
class ReviewPRSkill extends SkillContext {}
@Provider — DI Service
import { Provider, ProviderScope } from '@frontmcp/sdk';
@Provider({ name: 'DatabaseProvider', scope: ProviderScope.GLOBAL })
export class DatabaseProvider {
async query(sql: string) { /* ... */ }
}
@Plugin — Extension
import { Plugin, DynamicPlugin } from '@frontmcp/sdk';
interface AuditOptions { destination: string }
@Plugin({ name: 'audit', description: 'Audit logging plugin' })
export default class AuditPlugin extends DynamicPlugin<AuditOptions> {
constructor(private readonly options: AuditOptions) {
super();
}
}
// Usage: register via the static init() method
@FrontMcp({
info: { name: 'Server', version: '1.0.0' },
apps: [MyApp],
plugins: [AuditPlugin.init({ destination: 's3://logs' })],
})
class Server {}
@Flow — Lifecycle Pipeline
@Flow({
name: 'tools:call-tool',
plan: {
pre: ['parseInput', 'authorize'],
execute: ['runTool'],
post: ['validateOutput'],
finalize: ['respond'],
},
inputSchema: callToolInputSchema,
outputSchema: callToolOutputSchema,
access: 'authorized',
})
class CallToolFlow extends FlowBase<'tools:call-tool'> {
@Stage('parseInput') async parseInput() { /* validate */ }
@Stage('authorize') async authorize() { /* check access */ }
@Stage('runTool') async runTool() { /* execute */ }
@Stage('validateOutput') async validateOutput() { /* validate output */ }
@Stage('respond') async respond() { /* respond */ }
}
Learn More
Decorator Reference
Complete API reference for every decorator
Context Classes
Base classes that provide DI, logging, and auth