โ Model Context Protocol/M-050Build an MCP Prompt Template Server๐ Guide๐
Rank 06ยท The Distiller
๐งชTDD Challengeยทintermediateยทโฑ๏ธ 30โ45mยทโญ 175 XP
M-050Build an MCP Prompt Template Server
Description
Nebula Corp wants to share reusable prompt templates across all their AI assistants via MCP. Build a prompt template server that registers templates with argument placeholders, lists available prompts, and renders them with provided arguments. The server should support variable interpolation like {{customerName}} and validate that all required arguments are provided.
Test Cases (4)
Lists all prompts
Should list all registered prompt templates
Input:handleRequest({ method: 'prompts/list' })
Expected:CONTAINS:customer-support
Renders support prompt
Should render template with provided arguments
Input:handleRequest({ method: 'prompts/get', params: { name: 'customer-support', arguments: { companyName: 'Nebula', customerName: 'Alice', issue: 'billing error' } } })
Expected:CONTAINS:Nebula
Rejects missing required args
Should error when required arguments are missing
Input:handleRequest({ method: 'prompts/get', params: { name: 'customer-support', arguments: { companyName: 'Nebula' } } })
Expected:CONTAINS:Missing
Handles optional args gracefully
Should render even when optional args are omitted
Input:handleRequest({ method: 'prompts/get', params: { name: 'code-review', arguments: { language: 'Python', code: 'print(1)' } } })
Expected:CONTAINS:Python
Related Lessons
Click Run / Check to validate your solution