Use pre-defined prompts from MCP servers to structure agent interactions
MCP Prompts allow you to use pre-defined prompt templates provided by MCP servers. These prompts can include structured messages, resources, and arguments, making it easy to leverage domain-specific expertise packaged by MCP server developers.
# prompts/greeting.yamlname: greetingdescription: A friendly greeting promptarguments: - name: user_name type: string required: truemessages: - role: user content: "Hello {{user_name}}! How can I help you today?"
# In interactive mode> /promptAvailable prompts:1. simple - A simple greeting prompt2. code_review - Review code for quality3. bug_analysis - Analyze bug reportsSelect prompt number or type /prompt <name>
Combine prompts with use_history=False for specialized agents:
@fast.agent( name="specialist", instruction="Base instruction", use_history=False, # No conversation history servers=["prompts"])async def main(): async with fast.run() as agent: # Apply domain-specific prompt as template await agent.specialist.apply_prompt( "domain_expertise", as_template=True ) # Agent now acts as fine-tuned specialist result = await agent.specialist("Analyze this case")
@fast.agent(name="agent1", servers=["prompts"])@fast.agent(name="agent2", servers=["prompts"])@fast.chain( name="chain", sequence=["agent1", "agent2"])async def main(): async with fast.run() as agent: # Initialize each agent with specific prompts await agent.agent1.apply_prompt("step1_setup") await agent.agent2.apply_prompt("step2_setup") # Run chain with initialized context await agent.chain("Process this data")
@mcp.prompt()async def generate_report( report_type: str, # "daily", "weekly", or "monthly" include_charts: bool = True, # Include visualizations format: str = "pdf" # Output format: "pdf", "html", or "md"): ...
Version Your Prompts
Consider versioning for breaking changes:
@mcp.prompt(name="analysis_v2")async def analysis_v2(...): """Updated analysis with improved structure""" ...
Test Thoroughly
Test prompts with various argument combinations:
# Test with minimal argsawait agent.apply_prompt("report", {"type": "daily"})# Test with all argsawait agent.apply_prompt("report", { "type": "daily", "include_charts": False, "format": "html"})