Skip to main content
Prompts are reusable templates that MCP clients can request and send to a model. Use a prompt when you want to package a repeatable instruction, not when you want the server to perform an action. This guide focuses on prompt design and common patterns. Use the Prompts API reference for exact 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 with server.prompt(). The schema describes arguments the client can collect before requesting the prompt.
The server validates prompt arguments before the callback runs. TypeScript infers the callback parameter type from the Zod schema.

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.
For simple prompts, response helpers keep the callback shorter:
See Response Helpers for a chooser and Response helpers API reference for exact conversion behavior.

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.
Avoid using prompt arguments as hidden configuration. If the value affects model behavior, make the field name and description visible.

Add autocomplete for prompt arguments

Use completable() when clients can suggest valid values while the user fills in prompt arguments.
Use list-based completion for small fixed sets. Use callback-based completion when suggestions depend on live data or another argument.

Use authenticated context when needed

When OAuth is configured, prompt callbacks can read verified user information from ctx.auth.
Use 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.
See Notifications for server-to-client notification patterns.

Test prompts locally

Run the development server and request the prompt from the Inspector.
Open 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.