Prerequisites:
- A working FrontMCP project (see Installation)
- Understanding of basic tool creation (see Your First Tool)
What You’ll Build
An expense management app with:- A prompt that generates expense reports
- A resource template that fetches expense details by ID
- A static resource that returns expense policies
Prompts
Prompts provide pre-built instructions that LLMs can use. They’re perfect for consistent formatting, complex workflows, or domain-specific guidance.Creating a Basic Prompt
Prompt Arguments
Define the inputs your prompt accepts:Prompt Return Value
Prompts return an object with:| Property | Type | Description |
|---|---|---|
description | string | Human-readable summary of the prompt |
messages | PromptMessage[] | Array of messages to send to the LLM |
role:'user'or'assistant'content: Object withtype: 'text'andtext: string
Resources
Resources expose data that LLMs can read. There are two types:Static Resources
Fixed content at a specific URI:Resource Templates
Dynamic resources with URI parameters:{expenseId} in the URI template becomes a parameter passed to execute().
Combining Everything in an App
Register prompts and resources alongside tools:Example: Categorization Prompt
Here’s a prompt that helps LLMs categorize expenses:Example: Categories Resource
A static resource listing available categories:File Organization
Recommended structure:index.ts files:
Best Practices
Use clear, descriptive names
Use clear, descriptive names
Names should indicate what the prompt/resource does:
Provide detailed descriptions
Provide detailed descriptions
Help LLMs understand when to use each prompt/resource:
Use appropriate MIME types
Use appropriate MIME types
Match the content type:
text/markdownfor formatted textapplication/jsonfor structured datatext/plainfor simple text
Validate URI template parameters
Validate URI template parameters
Add validation in your execute method:
Next Steps
Role-Based Authorization
Control access to prompts and resources
Prompts Reference
Full @Prompt decorator documentation
Resources Reference
Full @Resource decorator documentation
Testing
Test prompts and resources