By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
You're building an MCP server and need to hand data to clients, let users pick from templates, or pause a tool mid-execution to ask a question. The protocol gives you three mechanisms for each scenario, and picking the wrong one breaks the flow.
A resource is read-only content identified by a URI—think a file path, database row, or API response. The host (the application running your server) decides when to attach it to a request, which is why resources are application-controlled, not user-controlled.
Resources come in two forms. A concrete resource has a fixed URI like file:///project/README.md. A resource template has variables the client fills in, like notes://{note_id}. Each resource declares a MIME type so the client knows how to render it: text/markdown, application/json, and so on.
When a client requests a resource that doesn't exist, your server returns error code -32602 (Invalid params) as of 2026-07-28. Both list and read operations include ttlMs and cacheScope fields so clients know how long they can cache the data. If you need live updates, clients can opt in through subscriptions and listen.
A prompt is a named template with arguments. The host surfaces prompts as slash commands or menu items, letting the user select and run them. You define a prompt by decorating a function and returning a string.
@mcp.prompt()
def review_code(language: str, code: str) -> str:
return f"Review this {language} code for bugs and security issues:\n\n{code}"The decorator registers the prompt with its name and arguments. When a user picks it from the menu, the host calls your function with the arguments they provided, and you return the rendered template—often a system message or instruction for an LLM.
Sometimes a tool cannot finish without a human answer: 'which branch should I deploy?', 'are you sure you want to delete this?'. This is where input_required comes in. Instead of blocking forever, your server returns an interim result that tells the host what information you need.
The flow is a multi round-trip request. First, the tool call arrives. Your server inspects it, realizes it needs user input, and returns a result with resultType set to input_required. You include inputRequests describing what you're asking for, and a requestState token (opaque to you, used by the host to match the retry to this request).
The host collects the user's answer, then retries the same tool call. This time it includes inputResponses with the answers and the requestState token. Your server validates the token, processes the response, and either returns the final result or asks for more input.
// 1) Server answers the first call (illustrative shape)
{ "jsonrpc": "2.0", "id": 5,
"result": {
"resultType": "input_required",
"inputRequests": { "confirm": { "message": "Delete project demo permanently?" } },
"requestState": "opaque-token-for-the-retry"
} }
// 2) Client asks the user, then RETRIES the same call with the answers
{ "jsonrpc": "2.0", "id": 6, "method": "tools/call",
"params": { "name": "delete_project", "arguments": { "name": "demo" },
"inputResponses": { "confirm": { "action": "accept" } },
"requestState": "opaque-token-for-the-retry" } }The exact field layout is defined in the spec's Multi Round-Trip Requests page—treat the JSON above as an illustration of the flow, not a copy-paste contract.
| You want to... | Use |
|---|---|
| Let the model DO something | Tool |
| Give the app read-only context | Resource |
| Offer a reusable workflow to the user | Prompt |
| Get a confirmation or missing detail | input_required (elicitation) |
Use resources when the host needs to attach existing data to your context. Use prompts when you want to offer the user a pre-built template they can select and customize. Use input_required when your tool is already running and hits a decision point that only the user can answer.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.