Skip to main content
registerPrompt adds a prompt to your server: a named, parameterized message template the user picks from the host’s prompt menu. The handler returns the messages the host inserts into the conversation.

Example

A prompt that takes one argument and returns a single user message.
server.ts

Signature

The config-object form returns the server, so it chains alongside registerTool and registerResource.

Config

name, title, description

name identifies the prompt; title and description are what the host shows in its prompt menu.

argsSchema

A Zod raw shape whose fields become the prompt’s arguments. It validates what the host passes and types the handler’s input. Wrap a field in completable() to autocomplete it as the user types, see Completions.

Handler

Receives the validated arguments and returns the messages to insert.
Each message’s content is a standard MCP ContentBlock, most often { type: "text", text }.

Register Prompts

The guide, with completions

registerResource

Expose readable content

McpServer

The server you register on