DS DevShelfHub Projects · AI tools
Tutorials / MCP / Reference / Methods / prompts/get
Method Client → Server

prompts/get

By DevShelfHub

Invoke a prompt by name with arguments, receiving a list of messages.

What it does

The client sends a prompts/get request with a required name field identifying the prompt and an optional arguments map of string key-value pairs. Before sending the request, the client must confirm the server declared a prompts capability during initialize negotiation — if the server omitted that capability block, prompts/get will return a JSON-RPC -32601 MethodNotFound error. The server looks up the named prompt template, interpolates the provided arguments into the template slots, and synchronously returns a GetPromptResult containing an optional human-readable description and a required messages array of PromptMessage objects. Each PromptMessage carries a role (user or assistant) and a content block that can be TextContent, ImageContent, or EmbeddedResource. The client injects these messages directly into the conversation context before the next model turn. \n\nArgument validation is the server's responsibility. If the caller omits a required argument or passes an argument of the wrong type, the server should return -32602 InvalidParams with a descriptive message field — not silently inject a partially-rendered template. Clients should treat a missing or empty messages array as a soft error and avoid injecting blank turns into the context, which can confuse the model. \n\nTiming matters: prompts/get is a synchronous request-response pair with no streaming. For prompts that involve expensive template rendering (e.g., fetching live data to embed), the server should complete the full render before replying rather than streaming partial results. If the prompt list changed between a prompts/list call and a prompts/get call — signalled by notifications/prompts/list_changed — the server may return -32602 if the named prompt no longer exists. Clients should be prepared to re-list and re-present choices to the user in that scenario.

When to use

When the user clicks/types a prompt (slash command).

When NOT to use

For model-driven workflows — use tools/call.

Notes

Capability gate is mandatory

The server must include a non-null prompts key in its capabilities object during initialize. If it does not, the client must not send prompts/get and should surface a configuration error rather than attempting the call and handling a MethodNotFound response at runtime.

Error codes to handle explicitly

Return -32602 (InvalidParams) when a required argument is missing or the named prompt no longer exists after a list change. Return -32601 (MethodNotFound) only if the capability was never advertised. Clients should distinguish these two codes: -32602 can be surfaced to the user as a fixable input error, while -32601 indicates a server configuration mismatch that the user cannot resolve at the argument level.

No pagination — messages array is atomic

Unlike prompts/list, prompts/get has no cursor or pagination mechanism. The entire PromptMessage[] is returned in a single response. If a prompt template would produce an extremely large context (e.g., embedding a full document), the server should truncate or summarize content internally rather than returning a payload that exceeds the client's context window limits.

Race condition after list_changed

Between receiving a notifications/prompts/list_changed notification and completing a new prompts/list round-trip, any in-flight or queued prompts/get calls that reference a stale prompt name may receive -32602. Design your client to queue a re-list and retry rather than surfacing this as a terminal error to the user.

Arguments map is strings only

The spec defines arguments as Record<string, string> — every value must be serialized to a string before sending. SDKs like the TypeScript MCP SDK enforce this at the type level, but Python implementations may silently coerce integers or booleans. Explicitly stringify all argument values on the client side to avoid subtle cross-SDK interoperability failures when servers perform strict type checks on received arguments.

Request parameters

NameTypePurpose
namestringPrompt name.
argumentsobject?Map of argument name → string value.

Response fields

NameTypePurpose
descriptionstring?Human description.
messagesPromptMessage[]Messages to inject.

Examples

Get a prompt

json
{ "method": "prompts/get", "params": { "name": "plan_vacation", "arguments": { "destination": "Barcelona" } } }

Common mistakes

❌ Returning a single string

✅ Always return messages: PromptMessage[].

Related

prompts/get FAQ

What does the prompts/get method do in MCP?

prompts/get is an MCP JSON-RPC 2.0 method used for structured communication between MCP clients and servers. It is part of the Model Context Protocol message layer.

Who calls prompts/get in an MCP session?

prompts/get is called by the Client → Server. Refer to the capability negotiation docs to confirm the required capabilities.

What request type does prompts/get use?

See the Request Parameters section on this page for the request type and fields accepted by prompts/get. All MCP method requests use JSON-RPC 2.0 format with an id field for correlation.

What does prompts/get return?

See the Result section on this page for the response type returned by prompts/get. Errors are returned as JSON-RPC 2.0 error objects with a code and message.

Where can I find more MCP method documentation?

The complete MCP API reference on DevShelfHub documents all JSON-RPC methods with request/result types, examples, and common mistakes. Visit the MCP API Reference index to browse all methods.