server.prompt() signatures, callback types, completion overloads, and return shapes.
Use prompts for reusable model instructions
Use prompts when the client needs a structured instruction with optional arguments. Use tools when the server should run code, call an API, or change state.
A good prompt has a task-shaped name, a clear description, typed arguments, and output that is ready for the model.
Register a prompt
Define a prompt withserver.prompt(). The schema describes arguments the client can collect before requesting the prompt.
Return prompt content
You can return MCP prompt messages directly or use response helpers. Prefer helpers for simple text or structured context; use direct messages when you need full control over message roles and content blocks.Design prompt arguments for clients
Prompt arguments should be easy for a client or user to fill in. Use enums for constrained choices, descriptions for ambiguous fields, and defaults only when the default is safe.Add autocomplete for prompt arguments
Usecompletable() when clients can suggest valid values while the user fills in prompt arguments.
Use authenticated context when needed
When OAuth is configured, prompt callbacks can read verified user information fromctx.auth.
ctx.auth only for verified identity from server authentication. Throw when the prompt request should fail instead of returning prompt content. See User Context for guide-level patterns and Tool context API reference for exact context fields.
Notify clients when prompts change
If your server adds or removes prompts at runtime, notify connected clients so they can refresh their prompt list.Test prompts locally
Run the development server and request the prompt from the Inspector.http://localhost:3000/mcp/inspector, select the Prompts tab, enter argument values, and verify the generated prompt content.
Next steps
Prompts API reference
Look up prompt definitions, callback signatures, completion helpers, and
return types.
Response Helpers
Choose helpers for text, JSON, Markdown, and mixed prompt content.
Tools
Use tools when the server should run code or call external systems.
Resources
Expose readable content by URI.