Use this file to discover all available pages before exploring further.
Prompts are reusable prompt templates that MCP servers expose to clients. They allow pre-configured prompt patterns to be shared and invoked with different parameters.
Use the [McpServerPrompt] attribute to mark methods as MCP prompts:
SimplePromptType.cs
using ModelContextProtocol.Server;using System.ComponentModel;[McpServerPromptType]public class SimplePromptType{ [McpServerPrompt( Name = "simple_prompt", IconSource = "https://example.com/lightbulb.svg" )] [Description("A prompt without arguments")] public static string SimplePrompt() => "This is a simple prompt without arguments";}
Prompts can accept parameters for dynamic content:
ComplexPromptType.cs
using Microsoft.Extensions.AI;using ModelContextProtocol.Server;using System.ComponentModel;[McpServerPromptType]public class ComplexPromptType{ [McpServerPrompt(Name = "complex_prompt")] [Description("A prompt with arguments")] public static IEnumerable<ChatMessage> ComplexPrompt( [Description("Temperature setting")] int temperature, [Description("Output style")] string? style = null) { return [ new ChatMessage( ChatRole.User, $"This is a complex prompt with arguments: temperature={temperature}, style={style}" ), new ChatMessage( ChatRole.Assistant, "I understand. You've provided a complex prompt with temperature and style arguments. How would you like me to proceed?" ) ]; }}
[McpServerPrompt][Description("Expert system prompt for technical analysis")]public static IEnumerable<PromptMessage> ExpertAnalysis( [Description("Domain expertise required")] string domain, [Description("Question to analyze")] string question){ return [ new PromptMessage { Role = Role.User, Content = new TextContentBlock { Text = $"You are an expert in {domain}. Please analyze the following question with detailed technical insights." } }, new PromptMessage { Role = Role.Assistant, Content = new TextContentBlock { Text = "I understand. I'll provide a detailed technical analysis drawing on my expertise. What would you like me to analyze?" } }, new PromptMessage { Role = Role.User, Content = new TextContentBlock { Text = question } } ];}
// Register by type.WithPrompts<MyPrompts>()// Register from assembly.WithPromptsFromAssembly()// Register from types collection.WithPrompts([typeof(Prompt1), typeof(Prompt2)])// Register with custom serializer.WithPrompts<CustomPrompts>(serializerOptions)